Examine search: filter out nodes with umbracoNaviHide
Hi,
I am working a on combined search, which gets results from umbraco and from a custom table.
But i cant figure out how to filter out umbraco nodes with umbracoNaviHide set to 1. Also i would like to boost the Umbraco nodes so they appear first in the search results.
Can anyone help?
At the start of you query creation you have boolean.or setup and therefore the query generated will be too permissive so you have the part -umbracoNaviHide:1 however its part of an overall or. So change:
Any reason why you are creating the searcher on the fly in code rather than in examine.config? I didn't know you could do it this way you live and learn as they say lol
var searcherNamedCollection = new NameValueCollection();
searcherNamedCollection.Add("indexSets", "ExternalIndexSet");
searcherNamedCollection.Add("indexSets", "CustomIndexSet");
Examine search: filter out nodes with umbracoNaviHide
Hi,
I am working a on combined search, which gets results from umbraco and from a custom table.
But i cant figure out how to filter out umbraco nodes with umbracoNaviHide set to 1. Also i would like to boost the Umbraco nodes so they appear first in the search results.
Can anyone help?
Here a some code. Here is a link to the entire razor page: http://www.pcl.dk/searchumb.cshtml.zip
Hi Peter,
Add the following to your searchCriteria:
Cheers,
Marc
Hi Marc,
Yes, i have seen this code in other posts.
But for some reason it dosnt work when doing a combined search.
Is your custom index and umbraco index or something else? if it is something else it will not have umbracoNaviHide property
Hi,
Its only the Umbraco Index. Some pages has the umbracoNaviHide attribute set.
Wonder, if it could be as simple as adding a umbracoNaviHide attribute to the non Umbraco Index?
nah, thats not the solution.
Peter,
Can you write out the generated query you can do this by outputting:
searchCriteria.ToString()
Just before you call searchProvider.Search
This will output the lucene query
Regards
Ismail
Hi,
Then i get this:
{ SearchIndexType: , LuceneQuery: nodeName:test~0.5 grid:test Udbyder:test~0.5 Adresse:test~0.5 KursusType:test~0.5 -umbracoNaviHide:1 }
But i still see nodes with umbracoNaviHide set to false.
Peter,
At the start of you query creation you have boolean.or setup and therefore the query generated will be too permissive so you have the part -umbracoNaviHide:1 however its part of an overall or. So change:
searchProvider.CreateSearchCriteria(BooleanOperation.Or);
to
searchProvider.CreateSearchCriteria(BooleanOperation.And);
and try again also can you output the generated query again as well please.
Hi,
It gives me this query: { SearchIndexType: , LuceneQuery: +nodeName:test~0.5 grid:test Udbyder:test~0.5 Adresse:test~0.5 KursusType:test~0.5 -umbracoNaviHide:1 }
No i dont see any data which matches Udbyder:test~0.5 Adresse:test~0.5 KursusType:test~0.5
only umb pages, but it does not filtered out pages with umbracoNaviHide.
Peter,
The query needs to look like:
+(nodeName:test~0.5 grid:test Udbyder:test~0.5 Adresse:test~0.5 KursusType:test~0.5) -umbracoNaviHide:1
So whatever is in brackets is an OR and outside bracket which is the navihide part is an and. So I am guessing you need a GroupedOr then an And
Hi,
This criteria:
gives me:
But still the pages containing the word 'test' are include, even if they are set to true in umbracoNaviHide.
Its crazy.
Peter,
Any reason why you are creating the searcher on the fly in code rather than in examine.config? I didn't know you could do it this way you live and learn as they say lol
HI Ismail,
Do you mean this part?
var searcherNamedCollection = new NameValueCollection(); searcherNamedCollection.Add("indexSets", "ExternalIndexSet"); searcherNamedCollection.Add("indexSets", "CustomIndexSet");
Hi Peter
I haven't tried combining search collections, but does the setting
supportProtected="false"
in the examinesettings.config file do anything?Thanks
Muiris
Hi,
I found a solution:
I added a searchprovider in ExamineSettings.config, which combines my 2 indexsets, instead of doing it in code.
Then my query was changed to this:
Which gives me this ouput:
is working on a reply...