elasticsearch - ElasticSearch查询未返回结果

标签 elasticsearch

我有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/

相关文章:

java - 将条目插入ElasticSearch的最佳方法是什么?

elasticsearch - 为多个 Elasticsearch 集群配置单个 Kibana 服务器

Elasticsearch匹配短语前缀不匹配所有术语

elasticsearch - 通过NEST进行Elasticsearch:连接到多个主机集群的推荐方法是什么

elasticsearch - 索引前如何预处理文档?

json - 使用 PHP 库仅获取 ElasticSearch 中的结果文档,排除其他元数据

search - Elasticsearch copy_to字段更新流程

elasticsearch - 在为大型数据建立索引时,如果我再次删除索引ElasticSearch并创建索引并为文档建立索引而不是给Index不存在

ElasticSearch - 每个节点的最佳分片数量

node.js - 启动插件应用程序时出现问题