ES多子句查询

2020-04-10  本文已影响0人  郭彦超

dis_max

dis_max 支持多子句查询,子句之间是or的关系,如果两个子句都匹配到相同的文档,取最高子句分值作为文档分值。

GET search_data/_search
{
  "size": 120, 
   "_source": "title", 
  
  "query": {
        "dis_max" : {
            "queries" : [
                { "match": { "title" : "日历" }},
                { "term" : { "title": "青春" }}
            ],
            "tie_breaker" : 1
        }
    }
}

查询结果:

 {
        "_index" : "search_data",
        "_type" : "_doc",
        "_id" : "1016324",
        "_score" : 20.455635,
        "_ignored" : [
          "xk_last_create_time"
        ],
        "_source" : {
          "title" : "青春飞扬日历邀请函"
        }
      },
      {
        "_index" : "search_data",
        "_type" : "_doc",
        "_id" : "469400",
        "_score" : 14.045259,
        "_ignored" : [
          "xk_last_create_time"
        ],
        "_source" : {
          "title" : "2018新年日历音乐相册"
        }
      }

上一篇下一篇

猜你喜欢

热点阅读