solr搜索按兰特在同一分数内排序

时间:2018-05-23 09:45:07

标签: sorting random solr

我正在使用solr 6.3我想在同一分数内按兰特对文档进行排序

请参阅结果回复:

{
  "numFound": 9796,
  "start": 0,
  "maxScore": 4.813048,
  "docs": [
    {
      "product_slno": "8343676",
      "product_name": "non basmati rice",
      "score": 4.813048
    },
    {
      "product_slno": "9272399",
      "product_name": "non basmati rice",
      "score": 4.813048
    },
    {
      "product_slno": "9117918",
      "product_name": "non basmati rice",
      "score": 4.813048
    },
    {
      "product_slno": "11992571",
      "product_name": "non basmati rice",
      "score": 4.813048
    },
    {
      "product_slno": "12226220",
      "product_name": "non basmati rice",
      "score": 4.813048
    },
    {
      "product_slno": "12239015",
      "product_name": "non basmati rice",
      "score": 4.813048
    },
    {
      "product_slno": "228513",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "382382",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "591419",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "11992574",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "12067342",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "12102172",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "12116777",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "12125565",
      "product_name": "basmati rice",
      "score": 4.6070313
    },
    {
      "product_slno": "4462552",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "6666626",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "7036941",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "7833234",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "7552192",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "8757321",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "9207159",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "9978281",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "11642035",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "12294941",
      "product_name": "non basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "12313470",
      "product_name": "non-basmati rice",
      "score": 4.424822
    },
    {
      "product_slno": "5457576",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "6666629",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "7552189",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "11476797",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "11642034",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "12209560",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "12230206",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "12233053",
      "product_name": "basmati rice",
      "score": 4.2188053
    },
    {
      "product_slno": "182609",
      "product_name": "non basmati rice",
      "score": 1.7452564
    },
    {
      "product_slno": "158848",
      "product_name": "non basmati parboiled rice",
      "score": 1.7452564
    },
    {
      "product_slno": "8439880",
      "product_name": "non basmati rice",
      "score": 1.7452564
    },
    {
      "product_slno": "10035413",
      "product_name": "non basmati rice",
      "score": 1.7452564
    }
  ]
}

我们有多个分数为“4.813048”,“4.6070313”,“4.424822”,“4.2188053”,“1.7452564”的文件我希望在同一分数内随机排序。

感谢

2 个答案:

答案 0 :(得分:0)

您可以按多个条目排序 - 即。首先按分数搜索,然后通过常规随机搜索。有关如何随机订购结果集,请参阅Solr - Return random results (Sort by Random)

sort=score desc,random_1234 asc

random_定义为<dynamicField name="random_*" type="random" />

在向Solr进行查询时,将1234的值更改为随机值。

答案 1 :(得分:0)

我正在使用solr建议者lookupImpl作为AnalyzingInfixLookupFactory,它工作正常,我无法解决的唯一问题是我希望在最上面显示准确的搜索关键字。 即,如果我搜索“皮革袋”,则该特定关键字应显示在顶部,但在显示“皮革袋”之后显示“男士皮袋”,“女士皮袋”。但我希望“皮革包”显示在顶部。

<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester</str>
<str name="lookupImpl">AnalyzingInfixLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">search_keyword</str>

<str name="suggestAnalyzerFieldType">text_general</str>
<str name="buildOnStartup">false</str>
</lst>     
</searchComponent>