2014-03-26 37 views
0

我得到了2个querys,它们之间的差异仅仅是1个过滤条件。ElasticSeach查询不返回结果

第一个查询:

GET _search 
{ 
    "query": { 
     "filtered": { 
      "query": { 
       "query_string": { 
        "query": "*" 
       } 
      }, 
      "filter": { 
       "and": { 
        "filters": [ 
         { 
          "term": { 
           "type": "log" 
          } 
         }, 
         { 
          "term": { 
           "context.blueprint_id": "adv1" 
          } 
         }, 
         { 
          "term": { 
           "context.deployment_id": "deploy1" 
          } 
         } 
        ] 
       } 
      } 
     } 
    } 
} 

回报这样的结果:

{ 
      "_source": { 
       "level": "info", 
       "timestamp": "2014-03-24 10:12:41.925680", 
       "message_code": null, 
       "context": { 
        "blueprint_id": "Adv1", 
        "execution_id": "27efcba7-3a60-4270-bbe2-9f17d602dcef", 
        "deployment_id": "deploy1" 
       }, 
       "type": "log", 
       "@version": "1", 
       "@timestamp": "2014-03-24T10:12:41.927Z" 
      } 
     } 

第二个查询是:

{ 
    "query": { 
     "filtered": { 
      "query": { 
       "query_string": { 
        "query": "*" 
       } 
      }, 
      "filter": { 
       "and": { 
        "filters": [ 
         { 
          "term": { 
           "type": "log" 
          } 
         }, 
         { 
          "term": { 
           "context.blueprint_id": "adv1" 
          } 
         }, 
         { 
          "term": { 
           "context.deployment_id": "deploy1" 
          } 
         }, 
         { 
          "term": { 
           "context.execution_id": "27efcba7-3a60-4270-bbe2-9f17d602dcef" 
          } 
         } 
        ] 
       } 
      } 
     } 
    } 
} 

空车返回结果。

它们之间的不同是在第二个查询,我只需要添加此词条:

    { 
         "term": { 
          "context.execution_id": "27efcba7-3a60-4270-bbe2-9f17d602dcef" 
         } 
        } 

,并在结果我们可以看到,有结果匹配到该查询,但它仍然无法正常工作。

我在做什么错在这里?

谢谢。

+0

你的映射是什么样的?是分析'context.execution_id'吗? –

+0

我是elasticSearch的新手,你的意思是什么分析? –

+1

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-analyzers.html#default-analyzers –

回答

1

默认情况下,ElasticSearch会将字符串字段视为文本并对其进行分析(即在编制索引之前标记大小,词干等)。这意味着您在搜索其确切内容时可能无法找到它们。

您应该确保未分析execution_id字段的映射。从GET /_mappings开始并从那里开始工作。 :)

+0

谢谢,这是有帮助的:) –