GautamD31
GautamD31

Reputation: 28763

Solr search is not working with BOTH LIKE

I'm using solr search to search my titles from database and in query tab I have given like

title : "a bloo"

And I have records for title feild like

"a blood river","a blood path"

they are not coming under the search with the "a bloo".It is not taking as both like as mysql does like

title like "%a bloo%"

Can anyone suggest me the right way to search it.

Upvotes: 1

Views: 31

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

It all depends on the tokens you are creating while you are indexing the field Title.

If you create the smaller token like for word "Blood" .. blo, bloo, blood then it would be searchable...

and to create such token you need to use the EdgeNGramFilterFactory

Try the below field type for you field Title and index it again...

Also to analyse more on the tokens you can use the solr web interface i.e. the analysis tool... it will give you the correct picture of the token benn created while indexing and whether there are been matched while quering ...

<fieldType name="text_reference" class="solr.TextField" sortMissingLast="true" omitNorms="true" positionIncrementGap="100">
   <analyzer type="index">
     <tokenizer class="solr.KeywordTokenizerFactory"/>
       <filter class="solr.LowerCaseFilterFactory"/>
       <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="50" side="front"/>
       <filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="50" side="back"/>
   </analyzer>
   <analyzer type="query">
      <tokenizer class="solr.KeywordTokenizerFactory"/>
         <filter class="solr.LowerCaseFilterFactory"/>
   </analyzer>
</fieldType>

Also to analyse more on the tokens you can use the solr web interface i.e. the analysis tool... it will give you the correct picture of the token benn created while indexing and whether there are been matched while quering ...

Upvotes: 1

Related Questions