Solr exact word result come first

2019-04-02 03:19发布

问题:

In Solr-5.0.0, I have one product_name field. When I search for a word or more than words, its giving results with product names that contain the words. How can I make it as the exact match come first.

My Schema.xml is below:

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

and my field definition is also given below:

<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>

Any boosting needed at index time or query time? Or any thing else?