1

I have a Solr Full Text field with the following settings...

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
  <charFilter class="solr.MappingCharFilterFactory" mapping="accents_en.txt"/>
  <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_en.txt"/>
  <filter class="solr.WordDelimiterGraphFilterFactory" catenateNumbers="1" generateNumberParts="1" protected="protwords_en.txt" splitOnCaseChange="0" generateWordParts="1" preserveOriginal="1" catenateAll="0" catenateWords="1"/>
  <filter class="solr.LengthFilterFactory" min="1" max="100"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords_en.txt"/>
  <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
  <charFilter class="solr.MappingCharFilterFactory" mapping="accents_en.txt"/>
  <tokenizer class="solr.WhitespaceTokenizerFactory"/>
  <filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms_en.txt" expand="true" ignoreCase="true"/>
  <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_en.txt"/>
  <filter class="solr.WordDelimiterGraphFilterFactory" catenateNumbers="0" generateNumberParts="1" protected="protwords_en.txt" splitOnCaseChange="0" generateWordParts="1" preserveOriginal="1" catenateAll="0" catenateWords="0"/>
  <filter class="solr.LengthFilterFactory" min="1" max="100"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords_en.txt"/>
  <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>

When I search using quotes "cat fish" The document with "cats, fish," is returned in the response. But I want only the documents exactly matching "cat fish" with a space.

I tried to remove all of the tokenization except for "solr.WhitespaceTokenizerFactory" but it still did not work. Then I removed all of the filters and tokenizers and it didn't work as well.

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
</analyzer>
<analyzer type="query">
</analyzer>
</fieldType>

How do I make quote searches only return exact phrases?

This is the solr query i use in the solr Admin UI using Edismax...

select?defType=edismax&fl=tm_X3b_en_aggregated_field_title,tm_X3b_en_aggregated_field_title,tm_X3b_en_rendered_item&ps=0&q="cat%20fish"&qf=tm_X3b_en_rendered_item^1%20%20tm_X3b_und_rendered_item^1%20%20tm_X3b_en_aggregated_field^1%20%20tm_X3b_und_aggregated_field^1%20%20tm_X3b_zxx_aggregated_field^1%20%20tm_X3b_en_body^1%20%20tm_X3b_und_body^1%20%20tm_X3b_zxx_body^1&qs=0
Joel Raed
  • 11
  • 1
  • If you want exact searches your best bet is to use a `String` field rather than a `Text` field. Keep in mind that exact searches are tricky (see https://stackoverflow.com/a/60435956/446681 and https://stackoverflow.com/questions/29103155/solr-exact-match-boost-over-text-containing-the-exact-match/29105025#29105025) – Hector Correa May 28 '20 at 14:27
  • Thank you Hector, I think my way forward is to trim the body copy and use "String". Otherwise I run up against the maximum character restraint. – Joel Raed May 28 '20 at 17:50

0 Answers0