栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在ElasticSearch中检索所有_id的有效方法

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在ElasticSearch中检索所有_id的有效方法

编辑:请也阅读@Aleck Landgraf的答案

您只想要elasticsearch-internal

_id
字段吗?还是
id
文档中的字段?

对于前者,请尝试

curl http://localhost:9200/index/type/_search?pretty=true -d '{     "query" : {         "match_all" : {}     },    "stored_fields": []}'

Note 2017更新: 该帖子最初包含在内,

"fields": []
但此后名称已更改,并且
stored_fields
是新值。

结果将仅包含文档的“元数据”

{  "took" : 7,  "timed_out" : false,  "_shards" : {    "total" : 5,    "successful" : 5,    "failed" : 0  },  "hits" : {    "total" : 4,    "max_score" : 1.0,    "hits" : [ {      "_index" : "index",      "_type" : "type",      "_id" : "36",      "_score" : 1.0    }, {      "_index" : "index",      "_type" : "type",      "_id" : "38",      "_score" : 1.0    }, {      "_index" : "index",      "_type" : "type",      "_id" : "39",      "_score" : 1.0    }, {      "_index" : "index",      "_type" : "type",      "_id" : "34",      "_score" : 1.0    } ]  }}

对于后者,如果要包括文档中的字段,只需将其添加到

fields
数组中

curl http://localhost:9200/index/type/_search?pretty=true -d '{     "query" : {         "match_all" : {}     },    "fields": ["document_field_to_be_returned"]}'


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/401419.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号