Solr 7助推器

时间:2019-01-29 23:24:45

标签: solr boosting

使用SOLR 7.X,我正在寻找基于SKU匹配的搜索

select?fl = SKU&q = text:234 ^ 1或SKU:A234-TRIM-WH ^ 10

结果:

<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="q">text:234^1 OR SKU:A234-TRIM-WH^10</str>
<str name="fl">SKU</str>
</lst>

<result name="response" numFound="95" start="0">
<doc><str name="SKU">49-234</str></doc>
<doc><str name="SKU">A234-TRIM-PB</str></doc>
<doc><str name="SKU">A234-TRIM-VB</str></doc>
<doc><str name="SKU">A234-TRIM-SDB</str></doc>
<doc><str name="SKU">A234-TRIM-PG</str></doc>
<doc><str name="SKU">A234-TRIM-MBK</str></doc>
<doc><str name="SKU">A234-TRIM-TB</str></doc>
<doc><str name="SKU">A234-TRIM-WH</str></doc>
<doc><str name="SKU">A234-TRIM-SB</str></doc>
<doc><str name="SKU">A234-TRIM-BKN</str></doc>
</result>

我希望A234-TRIM-WH是我的第一个结果。知道我在做什么错吗?

1 个答案:

答案 0 :(得分:0)

通过按分数排序可以得到这些期望的结果。 ^ 5表示分数提高了5。您需要调整排序以实际调整结果。

/ select?fl = SKU,分数&q = text:234或SKU:A234-TRIM-BG ^ 5&sort = score desc

q=text:234 OR SKU:A234-TRIM-BG^5
sort=score desc

    <result name="response" numFound="95" start="0" maxScore="40.91652">
      <doc>
        <str name="SKU">A234-TRIM-BKN</str>
        <float name="score">40.91652</float></doc>
      <doc>
        <str name="SKU">A234-H-BKN</str>
        <float name="score">39.75939</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-ULB</str>
        <float name="score">37.286957</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-SCU</str>
        <float name="score">36.92577</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-PEW</str>
        <float name="score">33.346096</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-WH</str>
        <float name="score">33.346096</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-MBK</str>
        <float name="score">32.955338</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-PCH</str>
        <float name="score">32.955338</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-SC</str>
        <float name="score">32.955338</float></doc>
      <doc>
        <str name="SKU">A234-TRIM-JG</str>
        <float name="score">32.955338</float></doc>
    </result><lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">6</int>
  <lst name="params">
    <str name="q">text:234 OR SKU:A234-TRIM-BG^5</str>
    <str name="fl">SKU,score</str>
    <str name="sort">score desc</str>
    <str name="_">1548816346922</str>
  </lst>
</lst>
<result name="response" numFound="95" start="0" maxScore="74.61354">
  <doc>
    <str name="SKU">A234-TRIM-BG</str>
    <float name="score">74.61354</float></doc>
  <doc>
    <str name="SKU">93-234</str>
    <float name="score">14.38112</float></doc>
  <doc>
    <str name="SKU">SS234#01</str>
    <float name="score">13.502219</float></doc>
  <doc>
    <str name="SKU">A234-TRIM-ULB</str>
    <float name="score">13.497984</float></doc>
  <doc>
    <str name="SKU">A234-TRIM-SCU</str>
    <float name="score">13.194142</float></doc>
  <doc>
    <str name="SKU">THU234</str>
    <float name="score">13.194142</float></doc>
  <doc>
    <str name="SKU">A234-H-AB</str>
    <float name="score">13.09588</float></doc>
  <doc>
    <str name="SKU">A234-H-ACU</str>
    <float name="score">13.09588</float></doc>
  <doc>
    <str name="SKU">A234-H-BG</str>
    <float name="score">13.09588</float></doc>
  <doc>
    <str name="SKU">A234-H-BKN</str>
    <float name="score">13.09588</float></doc>
</result>