Kibana多个关键字过滤器

时间:2018-09-14 01:01:54

标签: elasticsearch kibana

我需要数据的多重过滤方面的帮助。例如,对于下面的示例JSON,哪种查询最适合?如果我只需要搜索所有字段,例如“ Apple”和水果“ Y”

1)

{
  "_index": "abc",
  "_type": "123",
  {
  "field" : "Apple"
  "fruit" : "Y"
  },
  {
  "field" : "Tomato"
  "fruit"   : "N"
  },
 {
  "field" : "Mango"
  "fruit"   : "Y"
}

2)

{
  "_index": "abc",
  "_type": "123",
  {
  "field" : "Apple"
  "fruit" : "N"
  },
  {
  "field" : "Tomato"
  "fruit"   : "Y"
  },
 {
  "field" : "Mango"
  "fruit"   : "Y"
 }

1 个答案:

答案 0 :(得分:0)

可能您想研究ES search docsES Filters

希望这可以帮助您了解进行搜索的想法:

{
    "bool": {
        "must":     { "match": { "tweet": "elasticsearch" }},
        "must_not": { "match": { "name":  "mary" }},
        "should":   { "match": { "tweet": "full text" }},
        "filter":   { "range": { "age" : { "gt" : 30 }} }
    }
}

要完全匹配,您可以use 'term' from ES docs为:

{
    "bool": {
        "must": [ { "term": { "field": "Apple" }},
                  { "term": { "fruit":  "Y" }} ]
    }
}

在基巴纳语中使用:

GET index_name/_search
{
"query": { 
         # your search query here
         }
}

可能这不是最好的解决方案,但希望对您有帮助。

已更新

ES demo上尝试

TEST

要运行的示例代码:

GET kibana_sample_data_flights/_search
{
  "query": {
    "bool": {
      "must": [
        {"match": {
          "OriginWeather": "Sunny"
        }},
        {"match": {
          "Cancelled": false
        }}
      ]
    }
  }
}