Elasticsearch的意外结果

时间:2013-09-28 19:02:22

标签: nosql elasticsearch logstash

我有一些文件存储在ES中(通过logstash)。查询ES时的结果看起来不对:

第一个查询(请参阅下面的查询和结果)应该(意味着)返回不包含region字段的文档。

更进一步,根据第一个查询的结果,显然有一个文档包含字段region,但是,第二个查询的结果应该(至少)返回一个文档{{1} },不包含任何文件。

  • 我的查询有问题吗?
  • 我如何调查问题所在? (ES日志没有与这些查询相关的任何内容)

以下是查询:

region=IN

结果:

curl -X GET 'http://localhost:9200/logstash*/_search?pretty' -d '{
    "query" : {
        "match_all" : {}
    },
    filter : {
        "and" : [
            { "term" : { "type" : "xsys" } },
            { "missing" : { "field" : "region" } }
        ]
    }, size: 2
}'

此外,以下查询的结果:

{
  "took" : 40,
  "timed_out" : false,
  "_shards" : {
    "total" : 90,
    "successful" : 90,
    "failed" : 0
  },
  "hits" : {
    "total" : 5747,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "logstash-2013.09.28",
      "_type" : "logs",
      "_id" : "UMrz9bwKQgCq__TwBT0WmQ",
      "_score" : 1.0, 
      "_source" : {
        .....
        "type":"xsys",
        ....
        "region":"IN",
        }
    }, { ....
    } ]
  }
}

是:

curl -X GET 'http://localhost:9200/logstash*/_search?pretty' -d '{
    "query" : { "match_all" : {} },
    filter : { "term" : { "region" : "IN" } },
    size: 1
}'

使用以下映射:

{
  "took" : 55,
  "timed_out" : false,
  "_shards" : {
    "total" : 90,
    "successful" : 90,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }

映射(ES返回的内容 - curl -XPUT http://localhost:9200/_template/logstash_per_index -d ' { "template": "logstash*", "settings": { "index.query.default_field": "message", "index.cache.field.type": "soft", "index.store.compress.stored": true }, "mappings": { "_default_": { "_all": { "enabled": false }, "properties": { "message": { "type": "string", "index": "analyzed" }, "@version": { "type": "string", "index": "not_analyzed" }, "@timestamp": { "type": "date", "index": "not_analyzed" }, "type": { "type": "string", "index": "not_analyzed" }, .... "region": { "type": "string", "index": "not_analyzed" }, ... } } } }' ):

curl -XGET 'http://localhost:9200/logstash-2013.09.28/_mapping

0 个答案:

没有答案