solrluceneedismaxdismaxsolr-boost

Exact word not boosting much Solr


As reference in the given link

https://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_make_exact-case_matches_score_higher

I tried one example . my schema.xml configuration given below.

     <field name="product_name" type="text_wslc" indexed="true" stored="true" required="true" multiValued="false"/>
        <field name="nameString" type="string_ci" indexed="true" stored="false" required="true" />
                <copyField source="product_name" dest="nameString"/>

<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
                <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
                <fieldType name="text_wslc" class="solr.TextField" positionIncrementGap="100">
                        <analyzer type="index">
                                  <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"
                             />
                <filter class="solr.LowerCaseFilterFactory"/>
                <filter class="solr.SnowballPorterFilterFactory" language="English" />
                <filter class="solr.PorterStemFilterFactory"/>
                <filter class="solr.KStemFilterFactory"/>
                <filter class="solr.EnglishMinimalStemFilterFactory"/>
                        </analyzer>
                        <analyzer type="query">
                                <tokenizer class="solr.WhitespaceTokenizerFactory"/>
                <filter class="solr.WordDelimiterFilterFactory"
                             generateWordParts="1"
                             generateNumberParts="1"
                             catenateWords="1"
                             catenateNumbers="1"
                             catenateAll="1"
                             preserveOriginal="1"
                             />
                                <filter class="solr.LowerCaseFilterFactory"/>
                <filter class="solr.SnowballPorterFilterFactory" language="English" />
                <filter class="solr.PorterStemFilterFactory"/>
                <filter class="solr.KStemFilterFactory"/>
                <filter class="solr.EnglishMinimalStemFilterFactory"/>
                        </analyzer>
                </fieldType>

<fieldType name="string_ci" class="solr.TextField" tMissingLast="true" omitNorms="true">
            <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            </analyzer>
        </fieldType>

Exact word search works fine with this.

But fuzzy search with exact match boost doesn't give expected result. This is my query

/select?q=(laptop bag)&defType=dismax&qf=nameString^22+product_name^0.1

Any Help?


Solution

  • You need to create a new field type this way...

    <fieldType name="string_ci" class="solr.TextField"
        sortMissingLast="true" omitNorms="true">
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>           
            <filter class="solr.LowerCaseFilterFactory" />
        </analyzer>
    </fieldType>
    

    Now create the field nameSrting like this:

    <field name="nameSrting" type="string_ci" indexed="true" stored="true"/>
    

    and copy the content of product_name to nameSrting like this:

    <copyField source="product_name" dest="nameSrting"/>
    

    Now you need to run a query specifying you want to get exact phrase using double quotes like this:

    http://localhost:8983/solr/Dummy2/select?q="laptop+bag"&wt=json&defType=dismax&qf= nameSrting^222+product_name^0.1