Exclude node from umbraco search

I created a umbraco search in which I need some kind of node that I don't need to look for, so I can do something that I have to define in the search criteria or sholud, I do something in the settings or index settings for config files

 <IndexSet SetName="DemoIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/DemoIndex/">
<IndexAttributeFields/>
<IndexUserFields/>
<IncludeNodeTypes/>
<ExcludeNodeTypes>
<add Name="News" />
</ExcludeNodeTypes>
</IndexSet>

      

and check the settings file

<add name="DemoIndexer" type="UmbracoExamine.LuceneExamineIndexer, UmbracoExamine" runAsync="true"
     supportUnpublished="false"
     supportProtected="true"
     interval="10"
     analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" indexSet="DemoIndexSet"/>

      

and user control code

public static class SearchResultExtensions
    {
        public static string FullUrl(this SearchResult sr)
        {
            return umbraco.library.NiceUrl(sr.Id);
        }

    }

 SearchTerm = Request.QueryString["s"];

            if (string.IsNullOrEmpty(SearchTerm)) return;

            SearchResults = ExamineManager.Instance.SearchProviderCollection["DemoSearcher"].Search(SearchTerm,true).ToList();

            SearchResultListing.DataSource = SearchResults;
            SearchResultListing.DataBind();

      

+3


source to share


2 answers


If you want to exclude the node type, just put this between the IndexSet tag

<IndexSet ...>
  ...
  <ExcludeNodeTypes>
    <add Name="NameNodeType" />
  </ExcludeNodeTypes>
</IndexSet> 

      



Learn more about codeplex explore

+4


source


In your DocumentType add "includeInSearchIndex" field of type true / false. Then add this field to your Examine index config

<IndexUserFields>
  <add Name="includeInSearchIndex"/>
</IndexUserFields>

      

Then use the generated custom query to find everything where this field is not validated.



var Searcher = ExamineManager.Instance.SearchProviderCollection["WebsiteSearcher"];            
var query = searchCriteria.Field("includeInSearchIndex", "0").
    Or().Field("includeInSearchIndex", "").Compile();
var searchResults = Searcher.Search(query);

      

This page will open for more information on the Examine index and search terms

+3


source







All Articles