#############批量获取#################
#获取所有数据 GET _mget { "docs": [ {"_index":"testdb", "_type":"job1", "_id":1 }, {"_index":"testdb", "_type":"job2", "_id":2 } ] } #查询某数据库下的数据 GET testdb/_mget { "docs": [ { "_type":"job1", "_id":1 }, { "_type":"job2", "_id":2 } ] } #查询某数据库下某表的数据 GET testdb/job1/_mget { "docs": [ { "_id":1 }, { "_id":2 } ] } #某表下数据更为简单的方法 GET testdb/job1/_mget { "ids": [1,2] }
############bulk批量操作##########
#批量导入可以合并多个操作,比如index,delete,update,create等等.也可以从一个索引导入到另外一个索引
action_and_meta_data\n optional_source\n action_and_meta_data\n optional_source\n ···· action_and_meta_data\n optional_source\n
#需要注意的是,每一条数据都由两行构成(delete)除外,其他的命令比如index和create都是由元信息行和数据行组成,update比较特殊,他的特殊行可能是doc也可能是upsert或者script,如果不了解的朋友可以参考前面的update的翻译
#例子 { "index" : { "_index" : "test" , "_type" : "type1" , "_id" : "1" } } {"field":"value1"} POST _bulk { "index" : { "_index" : "lagou" , "_type" : "job1" , "_id" : "1" } } {"title":"python分布式爬虫开发","salary_min":15000,"city":"北京","company":{"name":"百度","company_addr":"北京市软件园"},"publish_date":"2017-4-16","comments":15} { "index" : { "_index" : "lagou" , "_type" : "job2" , "_id" : "2" } } {"title":"python django 开发工程师","salary_min":30000,"city":"上海","company":{"name":"美团","company_addr":"北京市软件A园"},"publish_date":"2017-4-16","comments":20} #特殊提交方式的字段,delete只有一行,update有特殊字,另外,不要一次提交特别多, { "index" : { "_index" : "test" , "_type" : "type1" , "_id" : "1" } } { "field" : "value1" } { "delete" : { "_index" : "test", "_type" : "_type1", "_id" : "2" } } { "create" : { "_index" : "test", "_type" : "_type1", "_id" : "3" } } { "field" : "value3" } { "update" : { "_index" : "test" , "_type" : "type1" , "_id" : "1" } } { "doc" : { "field2" : "value2" } }
时间: 2024-11-05 22:57:38