我得到了两个查询,它们之间的区别仅仅是一个过滤项。
第一个查询:
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"
}
}在结果中,我们可以看到该查询有结果匹配,但仍然不能工作。
我在这里做错了什么?
谢谢。
发布于 2014-03-26 10:00:54
默认情况下,ElasticSearch会将字符串字段作为文本来处理,并对它们进行分析(即在索引之前对字符串字段进行标记化、词干等)。这意味着在搜索它们的确切内容时,您可能无法找到它们。
您应该确保没有分析execution_id字段的映射。从GET /_mappings开始,从那里开始工作。:)
https://stackoverflow.com/questions/22657017
复制相似问题