在 Elasticsearch 中,可以使用 GET API 根据文档 ID 查询文档。以下是使用 curl 命令从 Elasticsearch 中获取文档的示例:

curl -XGET 'http://localhost:9200/index_name/type_name/id'

其中,index_name 是索引名称,type_name 是文档类型名称,id 是要查询的文档的 ID。

例如,要查询索引名为 my_index、类型名为 my_type、ID 为 1 的文档,可以使用以下命令:

curl -XGET 'http://localhost:9200/my_index/my_type/1'

如果文档存在,则 Elasticsearch 返回文档的 JSON 表示。如果文档不存在,则返回 404 状态码。

elstaicsearch 根据id查询

原文地址: https://www.cveoy.top/t/topic/hw7d 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录