0
votes

I use Examine search in an Umbraco 7 application. Somehow, i do not get any results where searching for words containing a hyphen , for example "Tag-name".

I've set up Examine to use WhitespaceAnalyzer for both the ExamineSearchProvider and the ExamineIndexProvider. I've also removed the cache in the tempfolder, but still no result. I've checked the value in the database, and they are in the same format as the query, "XXX-xxx". I've also tried to escape the query, but that doesn't change the result.

Is there anything here that I'm not seeing?

In ExamineSettings.config:

<Examine>
    <ExamineIndexProviders>
        <providers>

  <!-- custom search index provider -->
  <add name="MySearchIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
   supportUnpublished="false"
   supportProtected="true"
   interval="10"
   analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"
   indexSet="MySearch"/>

   </providers>
</ExamineIndexProviders>

<ExamineSearchProviders defaultProvider="MySearchSearcher">
   <providers>

    <!-- custom search provider -->
     <add name="MySearchSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
       analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" indexSet="MySearch"  enableLeadingWildcards="true"/>


      </providers>
   </ExamineSearchProviders>

</Examine> 

And in ExamineIndex.config:

<ExamineLuceneIndexSets>

<IndexSet SetName="MySearch" IndexPath="~/App_Data/TEMP/ExamineIndexes/MySearch/">
<IndexAttributeFields>
  <add Name="id" />
  <add Name="nodeName"/>
  <add Name="updateDate" />
  <add Name="writerName" />
  <add Name="nodeTypeAlias" />
</IndexAttributeFields>
<IndexUserFields>
  <add Name="nodeName" />
  <add Name="content"/>
  <add Name="tags" />
  <add Name="category" />
</IndexUserFields> 
<IncludeNodeTypes>
  <add Name="article" />
  <add Name="note" />
</IncludeNodeTypes>
</IndexSet>
</ExamineLuceneIndexSets>
2

2 Answers

0
votes

It should treat the hyphen as part of the word. Try installing the examine inspector package and see what's being stored in the index: http://our.umbraco.org/projects/backoffice-extensions/examine-inspector

You can also write out the Raw Lucene query that's being generated by your search code in Examine to see if the hyphen is being escaped or modified.

0
votes

Actually it splits the word by '-'. The problem is not in the Index or the Settings. Try using UmbracoHelper class and the method TypedSearch(keywords, false, "YourSearcher"), note that useWildCards is set to be "false". For more info see the method Search here: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/PublishedContentExtensions.cs