Solr Exact match boost Reduce the results

710 views Asked by At

i have two fields, one is copy field.

  1. <field name="product_name" type="text_wslc" indexed="true" stored="true" required="true" multiValued="false"/>

  2. <field name="dummy_name" type="string_ci" indexed="true" stored="false" required="true" />

Its definition is given below

<fieldType name="text_wslc" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
 <filter class="solr.WordDelimiterFilterFactory"
                                 generateWordParts="1"
                                 generateNumberParts="1"
                                 catenateWords="1"
                                 catenateNumbers="1"
                                 catenateAll="1"
                                 preserveOriginal="1"
                                 />

    <filterclass="solr.LowerCaseFilterFactory"/>
<filter class="solr.SnowballPorterFilterFactory" language="English" />
                    <filter class="solr.PorterStemFilterFactory"/>
                    <filter class="solr.KStemFilterFactory"/>
                    <filter class="solr.EnglishMinimalStemFilterFactory"/>
                            </analyzer>


    <fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
          <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SnowballPorterFilterFactory" language="English" />
            <filter class="solr.KStemFilterFactory"/>
            <filter class="solr.EnglishMinimalStemFilterFactory"/>
        </analyzer>
    </fieldType>

the copy filed is to get exact matched results first. My query is like this

/select?q=("laptop+bag")&df=product_name&defType=edismax&qf=dummy_name^20000+product_name^0.01

it gives me around 8000 results

but for the actual results is around 20000

 /select?q=(laptop+bag)&df=product_name&defType=edismax&qf=dummy_name^20000+product_name^0.01 

but it won't list the exact result first. How can i resolve this issue? Is there any problem with my query? Here is my fields and definitions

1

There are 1 answers

3
nick_v1 On

You have a couple of things going on here.

First off, searching for "laptop bag" and laptop bag are two different things, that is why you are getting different results. The first one will search for the exact phrase, while the latter will find any of the keywords. So it makes sense that you are seeing less results when you have quotes around your search query.

Second, I think your field definition for string_ci field need a bit of tweaking, your stemming intentions are a bit of a mystery to me at this point. Also, make sure that your indexing settings and query settings for that field are relatively similar. Use the Solr Admin UI Analyzer to tweak the field and see how your changes effect data input/output.

Lastly, the last field config you posted is without the field label. Overall, it's hard to say where the problem is specifically. I would recommend starting with running some queries and setting debug to true to see how relevance is being evaluated. My bet would be that your indexing and query parameters for your string field are inconsistent. If that is true you can verify this in the Admin UI Analyzer.

Good luck figuring this out.