Elasticsearch嵌套查询 - 自定义评分

时间:2014-03-06 00:46:51

标签: elasticsearch

我试图看看我是否可以找到所有年龄值不为空的记录 - 将它们提高1000,否则查找年龄值为null的所有记录,然后只查找censusyear大于1910的记录

GET _search
{
 "size":20, 
  "from":0, 
  "query" : {
      "custom_filters_score": {
         "query": {
         "filtered": {
            "query": {
                "match_all": {}
            },
            "filter": {
                "or":  [
                {"query":{"field": { "Age": "exists"}}},
                { "and":[
                    {"query":{"field": { "Age" : null}}},
                    {"range":{"CensusYear": {"gte":1910}}}
                    ]
                   }]
            }
         }
         },
         "filters": [
            {
               "filter": {"term":{"Age":"exists"}}, "boost":"1000"
            }
         ]
      }
  }
}

0 个答案:

没有答案