我有一个在Elasticsearch上建立索引的json文件,我需要一个查询来检索“_id_osm”。你能帮我一下吗
这是我的json文件的一行:
{
"index": {
"_index": "pariss",
"_type": "sig",
"_id": 1
}
}{
"fields": {
"_id_osm": 416747747,
"_categorie": "",
"_name": [
""
],
"_location": [
36.1941834,
5.3595221
]
}
}
最佳答案
根据答案中的评论更新了答案,
如果您在store
的映射中具有_id_osm
true,则可以使用以下查询来获取字段值。
{
"stored_fields" : ["_id_osm"],
"query": {
"match": {
"_id": 1
}
}
}
上面的调用返回下面的响应,您可以注意到响应中的fields
部分包含字段名称和值。 "hits": [
{
"_index": "intqu",
"_type": "_doc",
"_id": "1",
"_score": 1.0,
"fields": {
"_id_osm": [
416747747
]
}
}
]
如果您没有默认的store
true,请使用_source
过滤来获取数据。{
"_source": [ "_id_osm" ],
"query": {
"match": {
"_id": 1
}
}
}
它返回以下响应,您可以看到_source
包含数据。 "hits": [
{
"_index": "intqu",
"_type": "_doc",
"_id": "1",
"_score": 1.0,
"_source": {
"_id_osm": 416747747
}
}
]
关于elasticsearch - 用于在json文件中的字段中查找id的elasticsearch查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62713908/