Carl Decks
Carl Decks

Reputation: 415

Case insensitive search in Examine Index (Lucene)

Is it possible to do a case insensitive search using Examine Index and Lucene without altering the data stored? I'm saving articles with Id, title, the text and a date. I don't want to index my data as lowercase since I want to read my data from the index and display it as it is. So I can skip the step going to the DB to get data. Saving the same data twice, once as it is and once as lower case, dosn't feel like the right way of doing it.

Any suggestions of how to aproach this?

ExamineIndex.config

 <IndexSet SetName="MySearchIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/MySearch/" >
<IndexUserFields>
  <add Name="Id" />
  <add Name="Title" />
  <add Name="Text" />
  <add Name="Date" />
</IndexUserFields>

ExamineSettings.config

   <add name="MySearchIndexer" type="Examine.LuceneEngine.Providers.SimpleDataIndexer, Examine"
      dataService="X.Service.MyIndexerService, X"
      indexTypes="CustomData"
      runAsync="false"
      enableDefaultEventHandler="true"
      analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>

     <add name="MySearchSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
             analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net" enableLeadingWildcard="true" />
    

Upvotes: 0

Views: 197

Answers (1)

hkn
hkn

Reputation: 1448

In lucene analyzers does not alter your data. They determine how data is indexed only. So you can index your data as you want (don't lowercase your data in your code), and retrieve values as they are.

As a side note in lucene you can have fields with different attributes (indexed/not indexed, stored/not stored). So you can add same field twice: one for retrieving only (stored & not indexed) and one for searching (indexed as lowercase but not stored). Check if examine supports these types of fields.

Upvotes: 0

Related Questions