0

我已将一些数据加载到 elasticsearch 并针对数据编写查询,但是结果包含匹配查询的所有数据。是否可以过滤结果以显示特定字段?

示例查询查找特定国家/地区的所有记录,但返回注册号列表。

所有数据都是可用的弹性搜索但是我得到了每场比赛的完整 json 记录。

我在 SENSE 中运行这个查询(在 Kibana 4.5.0 中)。

查询是...

GET _search
{
  filter_path=reg_no.*,
    "fields" : ["reg_no"],
    "query" : {
        "fields" : ["country_cd", "oprg_stat"],
        "query" : "956 AND 9074"
      }
}

如果我删除这两行

filter_path=reg_no.*,
"fields" : ["reg_no"],

查询运行但带回所有数据。

4

1 回答 1

1

试试这个查询:

POST _search
{
  "_source": [
    "reg_no"
  ],
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "country_cd": "956"
          }
        },{
          "term": {
            "oprg_stat": "9074"
          }
        }
      ]
    }
  }
}
于 2016-05-18T16:16:51.460 回答