gpt4 book ai didi

_source 字段上的 Elasticsearch 搜索不起作用

转载 作者:行者123 更新时间:2023-12-02 22:49:19 24 4
gpt4 key购买 nike

我在elastic-search 5中有一个文档,如下

{
"_index": "my_index",
"_type": "json",
"_id": "document_id",
"_score": 1,
"_source": {
"message": "{\"the_id\": \"custom_id\", \"more\": \"Data\"}",
"type": "json",
"the_id": "custom_id",
"@timestamp": "2017-04-03T13:31:39.995Z",
"port": 48038,
"@version": "1",
"host": "127.0.0.1"
}
}

当我使用 Kibana 控制台查询 _id 时,它工作正常并获取记录

 GET _search
{
"query": {
"bool": {
"filter": [
{ "term": { "_id": "document_id" }}
]
}
}
}

但是,如果我正在查询 _source 级字段,在本例中为 the_id,则不会得到任何结果。

 GET _search
{
"query": {
"bool": {
"filter": [
{ "term": { "the_id": "custom_id" }}
]
}
}
}

如何确保我始终能够查询到 _source 级别。

最佳答案

作为本例中使用的默认映射,elasticsearch 为您的 the_id 字段创建多字段(the_idthe_id.keyword)。这里 the_id 将使用 text 类型映射创建,the_id.keyword 将使用 keyword 类型映射创建。

由于术语查询与字段的精确值匹配,您必须在查询中提供the_id.keyword

要阅读更多相关信息,请阅读官方文档中的Why doesn't the term query match my document?部分here

关于_source 字段上的 Elasticsearch 搜索不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43187753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com