如何根据内部匹配的得分排序

时间:2019-11-04 04:22:38

标签: elasticsearch

返回儿童分数,但是它没有按顺序排序。 我尝试添加“ function_score”和“ score_mode”:最大值。但是,它仍然没有按顺序排列。不太清楚我应该怎么做才能使其正常工作。 好心提醒。

POST _scripts/my_script
{

  "script" : {
    "lang" : "mustache",
    "source" : """
 {
  "size": 200,
  "query":{
    "function_score":{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "name": {
              "query": "{{query}}",
            }
          }
        },
        {
          "has_child": {
            "type": "phone",
            "score_mode": "max",
            "inner_hits": {
              "highlight": {
                "fields": {
                  "*": {

                  }
                }
              }
            },
            "query": {
              "match": {
                "phone_number": {
                  "query" :"{{query}}",
                }
              }
            }
          }
        },
        {
          "has_child": {
            "type": "product",
            "score_mode": "max",
            "inner_hits": {
              "highlight": {
                "fields": {
                  "*": {

                  }
                }
              }
            },
            "query": {
              "match": {
                "product_num": {
                  "query" :"{{query}}"
                }
              }
            }
          }
        }
      ]
    }
  }
    }
  }
}
    """
  }
}

预期的内部匹配项将按desc顺序排序,但未排序。

0 个答案:

没有答案
相关问题