Thursday 18 July 2013

Lucene concrete example

Lucene concrete example

Purpose:


I am building autocomplete search for umbraco. I need to get all pages that are searchable and not hidden from navigation.

Searchable and hiddenFromNavigation are my custom properties.

My seach examine index
  <IndexSet SetName="AutoCompleteLookupIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/AutoCompleteLookupIndexSet/">
    <IndexAttributeFields>
      <add Name="id" />
      <add Name="nodeName" />
      <add Name="updateDate" />
      <add Name="writerName" />
      <add Name="path" />
      <add Name="nodeTypeAlias" />
      <add Name="parentID" />
    </IndexAttributeFields>
    <IndexUserFields>
      <add Name="description"/>
      <add Name="hideFromNav"/>
      <add Name="searchable"/>
    </IndexUserFields>
    <IncludeNodeTypes>
    </IncludeNodeTypes>
    <ExcludeNodeTypes>
    </ExcludeNodeTypes>
  </IndexSet>

My examine settings:

      <add name="AutoCompleteLookupIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
           supportUnpublished="false"
           supportProtected="true"
          analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" />

 <!-- AutoComplete lookup search-->
      <add name="AutoCompleteLookupSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
           analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" enableLeadingWildcards="true"/>


My Lucene query

(hideFromNav:"0" AND searchable:"1" AND nodeName:searchTextAsWildCard*)


No comments:

Post a Comment