Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of batch Operation of Elasticsearch documents

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "the method of batch operation of Elasticsearch documents". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Elasticsearch's document operation: add a new document # add a book with id 1 (both POST and PUT are OK) POST lqz/_doc/1/_create#POST lqz/_doc/1#POST lqz/_doc will automatically create an id, you must use Post {"title": "A Dream of Red Mansions", "price": 12, "publish_addr": {"province": "Heilongjiang", "city": "Hegang"} "publish_date": "2013-11-11", "read_num": 1999," tag ": [" Classical "," masterpiece "]} two query documents # query documents with id 7 under lqz index GET lqz/_doc/7# query documents with id 7 under lqz index As long as the title field GET lqz/_doc/7?_source=title# queries the document with id 7 under the lqz index, and as long as the title and price fields GET lqz/_doc/7?_source=title,price# query the document with id 7 under the lqz index To modify all fields GET lqz/_doc/7?_source three documents # modify the document (overwrite modification) PUT lqz/_doc/10 {"title": "xxxx", "price": 333," publish_addr ": {" province ":" Heilongjiang "," city ":" Fuzhou "}} # modify the document, incremental modification Only modify a field (note is post) POST lqz/_update/10 {"doc": {"title": "modify"} four delete document # delete document id 10 DELETE lqz/_doc/10 five batch operations _ mget# batch get data with id 2 under lqz index _ doc type and data GET _ mget 1 under lqz2 index _ doc type GET _ mget {"docs": [{"_ index": "lqz" "_ type": "_ doc", "_ id": 2}, {"_ index": "lqz2", "_ type": "_ doc", "_ id": 1}]} # batch obtain data GET lqz/_mget {"docs": [{"_ id": 2} with id 1 and 2 under the lqz index {"_ id": 1}]} # Ibid. GET lqz/_mget {"ids": [1Magne2]} bulkPUT test/_doc/2/_create {"field1": "value22"} POST _ bulk {"index": {"_ index": "test" for six batch operations "_ id": "1"} {"field1": "value1"} {"delete": {"_ index": "test", "_ id": "2"}} {"create": {"_ index": "test" "_ id": "3"} {"field1": "value3"} {"update": {"_ id": "1", "_ index": "test"} {"doc": {"field2": "value2"} "method for batch operation of Elasticsearch documents" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report