Solr Synonyms not matching as expected

340 Views Asked by At

I have added SynonymGraphFilter which points to file containing word forms Ex: 1, one ... 31, Thirty one ...

to support searching numbers in documents in their word form, However when I search for "Thirty One" search shows up docs containing numbers in the range of 31..39 , not just 31, how do I make sure it matches exact word form

Update :

Here is the complete filter and analyzer chain for the field

  <fieldType name="text_field" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
      <analyzer type="index">
        <tokenizer class="solr.ICUTokenizerFactory" rulefiles="Latn:Latin-whitespace.rbbi"/>
     
        <filter class="solr.StopFilterFactory" ignoreCase="false" words="stopwords.txt" />
        <filter class="solr.LengthFilterFactory" min="1" max="100"/>
        <filter class="solr.WordDelimiterFilterFactory" 
                generateWordParts="1" generateNumberParts="1" catenateWords="1" 
                catenateNumbers="1" catenateAll="0" splitOnCaseChange="1" preserveOriginal="1"/>
        <!-- Remove external punctuation; spell text does exact match -->
        <filter class="solr.PatternReplaceFilterFactory" pattern="^\p{Punct}*(.*?)\p{Punct}*$" 
          replacement="$1"/>
        <!-- acronyms should be case-sensitive at index time, otherwise common words get expanded (like 'it') -->
        <filter class="solr.SynonymFilterFactory" synonyms="acronym_synonyms_inline.txt" ignoreCase="false" />
        <!-- DIRE: be aggressive about folding diacritics; also normalizes -->
        <filter class="solr.ICUFoldingFilterFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="new_name_synonyms.txt" ignoreCase="true" />
<filter class="solr.SynonymGraphFilterFactory" synonyms="number_synonyms_inline.txt" />
        <!-- DIRE: Only do more aggressive synonyms at index time. -->
        <filter class="solr.SynonymFilterFactory" synonyms="text_synonyms.txt" ignoreCase="true" expand="true"/>
        <!-- DIRE: Multi-term synonyms break highlighting when searching on
             words after the first.  Here we treat each member term as a
             synonym in order to get proper highlighting. Then we boost via a
             hidden field to get the phrase matching -->
        <filter class="solr.SynonymFilterFactory" synonyms="expand_synonyms_inline.txt" />
        <filter class="solr.KeywordRepeatFilterFactory"/>
        <filter class="solr.StemmerOverrideFilterFactory" dictionary="stemdict.txt" />
        <filter class="solr.PorterStemFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>  
      <analyzer type="query">
        <tokenizer class="solr.ICUTokenizerFactory" rulefiles="Latn:Latin-whitespace.rbbi"/>
        <filter class="solr.StopFilterFactory" ignoreCase="false" words="stopwords.txt" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="^\p{Punct}*(.*?)\p{Punct}*$" 
          replacement="$1"/>
        <filter class="solr.LengthFilterFactory" min="1" max="100"/>
        <filter class="solr.WordDelimiterGraphFilterFactory" 
                generateWordParts="1" generateNumberParts="1" catenateWords="0" 
                catenateNumbers="0" catenateAll="0" splitOnCaseChange="1" preserveOriginal="1"/>
        <filter class="solr.ICUFoldingFilterFactory"/>
        <!-- DIRE: always do compound splitting on queries; we currently can't
             do multiword synonyms at index time unless we protect the terms from tokenization. -->
        <filter class="solr.SynonymGraphFilterFactory" synonyms="expand_synonyms.txt" ignoreCase="true" expand="true"/>
        <!-- acronyms should be case-insensitive at query time, since users often don't bother -->
        <filter class="solr.SynonymGraphFilterFactory" synonyms="acronym_synonyms_query.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.KeywordRepeatFilterFactory"/>
        <filter class="solr.StemmerOverrideFilterFactory" dictionary="stemdict.txt" />
        <filter class="solr.PorterStemFilterFactory"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>  
    </fieldType>   
0

There are 0 best solutions below