Excluding items from search
# help-with-umbraco
t
Hi everyone I have a simple class which retrieves items from Umbraco 13 using examine search and displays them. I was trying to exclude umbracoNaviHide pages by having the below var create = index.searcher.CreateQuery(Indextypes.Content).GroupedNot("umbracoNaviHide", "1") Using this it still returns pages which have been marked as hide. Is there a criteria I need this to meet or anyway to distinguish why this is occurring? Thank you
a
In following Paul's videos - the difference we have is that you're passing 2 strings - instead of 2 string arrays. EG:
.GroupedNot(["umbracoNaviHide"], ["1"])
Maybe that will work?
t
I changed it around and had a little bit of test to change between strings and string arrays but unfortunately that made no difference. Could this be something to do with the document type is setup? My document type has the Navi hide in the last tab of 6?
j
You aren't grouping multiple things so grouped not shouldnt be nessecary. Have you tried
Copy code
csharp
index.searcher.CreateQuery(Indextypes.Content).Not().Field("umbracoNaviHide",  "1")
Additionally its always a good idea to set a breakpoint when it executed the search and have a look at the final lucene string it generates
t
Hi I'll try that but I have GroupedNot as I left out the code thereafter to keep it looking simple. I have added it below which is following on from my original code above And().GroupedNot("__NodeTypeAlias", Main.ModelTypeAlias); I have been looking at the debugger but this is what I see LuceneQuery:{-umbracoNaviHide:1 -__NodeTypeAlias:main} Not sure if this gives enough information?
j
The query looks alright, the standard nodetypealias field is called
__NodeTypeAlias
though. In the backoffice under settings -> external index there is a search field, and that search field supports lucene syntax, so you can put in
-umbracoNaviHide:1 -NodeTypeAlias:main
and get the searchresult, you can then remove one part at a time to see when it works. And you can remove them all and search on a node name to see its fields. You can see fx on a site I have it has these fields among others https://cdn.discordapp.com/attachments/1285940073841295360/1286274340983406656/image.png?ex=66ed4fd4&is=66ebfe54&hm=b7eb3da437eaf673299f0a732386e6005dc12e7fd71cdead7acab46c7ca05706&
t
Thank you that helped me narrow down the issue...... There was a typo in the document type 🤬🤬
83 Views