如何根据术语的长度对solr建议进行排序

时间:2018-03-01 09:45:15

标签: solr

我在我的应用程序中使用了以下searchcomponent来提示

<searchComponent name="suggest" class="solr.SuggestComponent">
 <lst name="suggester">
    <str name="name">suggester</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="highlight">false</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">term</str>
    <str name="payloadField">payload</str>
    <str name="contextField">vendor</str>
    <str name="suggestAnalyzerFieldType">text_autocomplete</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">true</str>
  </lst>
</searchComponent>

当我尝试点击建议api http://localhost:8983/solr/primary/suggest?indent=on&suggest.q=apple&wt=json

我得到了像

这样的回复
{
"responseHeader":{
"status":0,
"QTime":6},
"suggest":{"suggester":{
  "apple":{
    "numFound":20,
    "suggestions":[{
        "term":"B Natural Apple Awe Juice",
        "weight":0,
        "payload":""},
      {
        "term":" Apple Awe Juice",
        "weight":0,
        "payload":""},
      {
        "term":" Apple",
        "weight":0,
        "payload":""},
      {
        "term":" B Natural Apple",
        "weight":0,
        "payload":""},
      {
        "term":" Apple Awe",
        "weight":0,
        "payload":""},
      {
        "term":" Apple Juice",
        "weight":0,
        "payload":""} ...

但我必须根据学期长度或分数得出。

apple
apple awe
apple juice
apple awe juice

我怎样才能做到这一点?

0 个答案:

没有答案