Solr如何按销售排序建议

时间:2015-03-14 15:37:05

标签: solr search-suggestion

我们正试图在我们的网站上使用solr作为搜索引擎,但我们遇到了问题,我们无法按销售数量对建议进行排序。

我尝试了组件Facet,Terms,FreeTextLookupFactory和拼写检查组件,但上述任何组件都无法获得我想要的结果。

如果我们可以对我们选择的体重的建议进行排序,我会理解最重要的事情。

我们使用的solr版本是5.0。

schema.xml:

<field name="name_complete" type="text_shingle" indexed="true" stored="true" required="false" multiValued="false" omitTermFreqAndPositions="true"/>

<fieldType name="text_shingle" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer> 
        <tokenizer class="solr.StandardTokenizerFactory"/> 
        <filter class="solr.LowerCaseFilterFactory"/> 
        <filter class="solr.ShingleFilterFactory" maxShingleSize="4" outputUnigrams="true"/> 
    </analyzer> 
</fieldType>

solrconfig.xml中   FreeTextLookupFactory:

<searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">suggest_product_free</str>
        <str name="lookupImpl">FreeTextLookupFactory</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">name_complete</str>
        <str name="indexPath">suggest_product_free</str>
        <str name="weightField">n_sales</str>
        <str name="buildOnCommit">true</str>

        <str name="suggestFreeTextAnalyzerFieldType">text_shingle</str>
    <int name="ngrams">3</int>
    </lst>
</searchComponent>

<requestHandler name="/suggest" class="solr.SearchHandler">
    <lst name="defaults">
        <str name="echoParams">explicit</str>
        <str name="wt">json</str>
        <str name="indent">true</str>
        <str name="suggest">true</str>
        <str name="suggest.count">10</str>
    </lst>

    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

拼写检查:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <lst name="spellchecker">
        <str name="queryAnalyzerFieldType">text_shingle</str>
        <str name="name">autocomplete</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.WFSTLookupFactory</str>
        <str name="field">name_complete</str>
        <str name="buildOnCommit">true</str>
        <float name="threshold">0.005</float>
       <str name="spellcheckIndexDir">./suggester_autocomplete</str>
    </lst>
</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <!-- Solr will use suggestions from both the 'default' spellchecker
           and from the 'wordbreak' spellchecker and combine them.
           collations (re-written queries) can include a combination of
           corrections from both spellcheckers -->
        <str name="spellcheck">true</str>
        <str name="spellcheck.count">10</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.dictionary">autocomplete</str>
        <!--str name="spellcheck.dictionary">wordbreak</str>
        <str name="spellcheck.extendedResults">true</str>
        <str name="spellcheck.alternativeTermCount">5</str>
        <str name="spellcheck.maxResultsForSuggest">5</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.collateExtendedResults">true</str>
        <str name="spellcheck.maxCollationTries">10</str>
        <str name="spellcheck.maxCollations">5</str-->
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
  </requestHandler>

我有什么想法可以订购重量的建议吗?

感谢所有人,祝你有个美好的一天。

例如: 假设我在solr上有这些保存的值:

1: Reflex canon eos 7d (weight: 1)
2: Reflex canon eos 6d (weight: 2)
3: Reflex canon eos 70d (weight: 3)

并请求字符串&#39; can&#39;。 我想要的结果:

canon eos
canon eos 70d
canon eos 6d
canon eos 7d

在实践中,它是一个自动完成,我可以订购重量。

0 个答案:

没有答案