gpt4 book ai didi

elasticsearch - 如何在一个查询中插入多条记录?

转载 作者:行者123 更新时间:2023-11-29 02:50:48 25 4
gpt4 key购买 nike

例如:

curl -XPUT 'http://localhost:9200/test/users/2' -d '{ "firstname"   : "test" }'

只插入一条记录。

如何在一个查询中插入多条记录?

最佳答案

你需要使用elasticsearch Bulk API .它允许您通过一个请求插入多个项目。请求被发布到特殊端点 /_bulk 并且看起来像这样:

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "field1" : "value2" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }

关于elasticsearch - 如何在一个查询中插入多条记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24778454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com