簡體   English   中英

如何根據匹配屬性對彈性搜索查詢進行排序?

[英]How to sort on elastic search query based on a matching property?

{
    "users": [
        {
            "type": "admin",
            "date": "2016-03-02T12:34:00+08:00",
            "status": "2"
        },
        {
            "type": "staff",
            "date": "2016-03-02T12:34:00+08:00",
            "status": "2"
        } 
    ],
    "features": "1 2 3 4 5"
}

可以說我上面有Elasticsearch文檔結構。 我希望獲得該索引上的所有文檔,但是具有功能3那些文檔應該位於搜索結果的頂部/乞討處。 我瀏覽了Elasticsearch文檔,但我無法弄清楚如何做到這一點。 誰能幫我這個 ?

使用此查詢:

{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "features": "3"
          }
        },
        {
          "match_all": {}
        }
      ]
    }
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM