elasticsearch - 用于在 json 文件中的字段中查找 id 的弹性搜索查询
问题描述
我有一个在 elasticsearch 上编制索引的 json 文件,我需要一个查询来检索“_id_osm”。你能帮我吗?这是我的 json 文件的一行:
{
"index": {
"_index": "pariss",
"_type": "sig",
"_id": 1
}
}{
"fields": {
"_id_osm": 416747747,
"_categorie": "",
"_name": [
""
],
"_location": [
36.1941834,
5.3595221
]
}
}
解决方案
根据答案中的评论更新了答案,
如果您store
的映射为 true,_id_osm
那么您可以使用以下查询来获取字段值。
{
"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
}
}
]
推荐阅读
- node.js - 我使用 Node.js 的 Web 应用程序没有加载到我的本地主机上
- amazon-web-services - AWS CloudWatch 警报操作一次,触发 lambda 3 次
- ansible - 如何识别使用ansible安装的操作系统的硬盘分区?
- typescript - 如何使用动态确定的泛型类型调用 Typescript 泛型方法?
- javascript - Django/Python 将 content.innerHTML 更改为 src 页面
- reactjs - 当我在 Digital Ocean 服务器上使用 API 调用时,.NET Core CORS 策略块
- azure - Azure KeyVault 和 Scala 2.11 和 Spark 2.4.4
- chisel - 如何使用两个管理器将客户端连接到 IdentityNode?
- javascript - 如何在 react-id-swiper 中正确居中和对齐图像
- python - 熊猫评分系统;显示关系为“3-4”