I've got an Umbraco instance (7.6.4) and I'm attempting to use the Examine searcher to create a search (based on https://www.youtube.com/watch?v=B9NeqMN9jIw) but I'm having trouble filtering out results where umbracoNaviHide to set to true on the node.
Hide 'umbracoNaviHide' node/page or other property given from Examine Search Results
Depending on what you are doing with the search or the index. You could do something like this. (Umbraco 7+)
This is what we use in our View/Template
@{
var q = Request.QueryString["q"];
var Searcher = Examine.ExamineManager.Instance.SearchProviderCollection["MySearchSearcher"];
if(String.IsNullOrWhiteSpace(q))
{
q = "something if q is blank";
}
var searchResults = Searcher.Search(q, true).OrderByDescending(x => x.Score);
foreach(var item in results){
var node = Umbraco.Content(item.Id);
var url = node.Url;
@*don't show my things that have 'umbracoNaviHide' (or this can be some other value) *@
if(node.GetPropertyValue<bool>("searchEngineSiteMapHide") == false){
<div><a href="@url">@node.Name</a></div>
}
}@*end foreach*@
}
EXAMINESETTINGS.CONFIG
<Examine>
<ExamineIndexProviders>
<providers>
<!--Add your own to this provider extension -->
<add name="MySearchIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="false"
supportProtected="true" interval="10"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" indexSet="MySearch" directoryFactory="Examine.LuceneEngine.Directories.SyncTempEnvDirectoryFactory, Examine" />
</providers>
</ExamineIndexProviders>
<ExamineSearchProviders defaultProvider="ExternalSearcher">
<providers>
<!--Add your own. -->
<add name="MySearchSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" indexSet="MySearch" enableLeadingWildcards="true" />
</provider>
</ExamineSearchProviders>
</Examine>
EXAMINEINDEX.CONFIG
<!--Custom indexer setup-->
<!-- The index set used by mysite.com for site search -->
<IndexSet SetName="MySearch" IndexPath="~/App_Data/ExamineIndexes/MySearch/">
<IndexAttributeFields>
<add Name="id" />
<add Name="name" />
</IndexAttributeFields>
<IndexUserFields>
<add Name="SomePropertyIMade" />
<!--Add others if you want-->
</IndexUserFields>
<IncludeNodeTypes>
<add Name="NodeTypeIMade" />
<!--Add others if you want-->
</IncludeNodeTypes>
</IndexSet>
</ExamineLuceneIndexSets>
Examine search not filtering out umbracoNaviHide
Hi all,
I've got an Umbraco instance (7.6.4) and I'm attempting to use the Examine searcher to create a search (based on https://www.youtube.com/watch?v=B9NeqMN9jIw) but I'm having trouble filtering out results where umbracoNaviHide to set to true on the node.
Has anyone experienced this or see what I'm doing wrong please?
Thanks, C
Hi Craig,
I use this:
Cheers,
Marc
Thanks Marc,
Are you using an external index there?
Thanks, C
Hide 'umbracoNaviHide' node/page or other property given from Examine Search Results
Depending on what you are doing with the search or the index. You could do something like this. (Umbraco 7+)
This is what we use in our View/Template
EXAMINESETTINGS.CONFIG
EXAMINEINDEX.CONFIG
is working on a reply...