首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ElasticSeach查询不返回结果

ElasticSeach查询不返回结果
EN

Stack Overflow用户
提问于 2014-03-26 09:45:57
回答 1查看 51关注 0票数 0

我得到了两个查询,它们之间的区别仅仅是一个过滤项。

第一个查询:

代码语言:javascript
复制
GET _search
{
    "query": {
        "filtered": {
            "query": {
                "query_string": {
                    "query": "*"
                }
            },
            "filter": {
                "and": {
                    "filters": [
                        {
                            "term": {
                                "type": "log"
                            }
                        },
                        {
                            "term": {
                                "context.blueprint_id": "adv1"
                            }
                        },
                        {
                            "term": {
                                "context.deployment_id": "deploy1"
                            }
                        }
                    ]
                }
            }
        }
    }
}

返回此结果:

代码语言:javascript
复制
{
            "_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"
            }
         }

第二个查询是:

代码语言:javascript
复制
{
    "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"
                            }
                        }
                    ]
                }
            }
        }
    }
}

返回空结果。

在第二个查询中,它们之间的不同之处在于,我只是添加了这个术语:

代码语言:javascript
复制
                    {
                        "term": {
                            "context.execution_id": "27efcba7-3a60-4270-bbe2-9f17d602dcef"
                        }
                    }

在结果中,我们可以看到该查询有结果匹配,但仍然不能工作。

我在这里做错了什么?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-26 10:00:54

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22657017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档