【发布时间】:2017-04-03 14:49:00
【问题描述】:
我在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 级别。
【问题讨论】:
-
the_id字段的映射是什么?是text字段还是keyword字段? -
你试过
{ "term": { "_source.the_id": "custom_id" }} -
我试过 { "term": { "_source.the_id": "custom_id" }},没用。
-
我没有创建任何映射。 logstash正在生成数据。基本上它是将消息字段,即json本身转换为_source下的json。
-
@sudhanshu 您能否在第二个查询中将
the_id替换为the_id.keyword并检查结果?我进一步建议您阅读this
标签: elasticsearch