我有2个查询,它们之间的区别只是1个过滤条件。
第一个查询:
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"
}
}
并且在结果中我们可以看到该查询有结果匹配,但仍然无法正常工作。
我在这里做错了什么?
谢谢。
最佳答案
默认情况下,ElasticSearch会将字符串字段视为文本并进行分析(即在索引之前标记化,词干等)。这意味着您在搜索它们的确切内容时可能找不到它们。
您应确保未分析execution_id
字段的映射。从GET /_mappings
开始,然后从那里开始工作。 :)
关于elasticsearch - ElasticSearch查询未返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22657017/