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

How to analyze the ElasticSearch basic interaction

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

ElasticSearch basic interaction how to analyze, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

RESTful API with JSON over HTTP creates an index

PUT http://127.0.0.1:9200/people

{"setting": {"number_of_shards": 5, "number_of_replicas": 1}, "mappings": {"man": {"properties": {"name": {"type": "text"} "country": {"type": "keyword"}, "age": {"type": "integer"}, "date": {"type": "date" "format": "yyyy-MM-dd HH:mm::ss | | yyyy-MM-dd | | epoch_millis"} create a structure

Structured creation requires the use of mappings structured keywords.

POST http://127.0.0.1:9200/book/cs/_mappings

{"cs": {"properties": {"title": {"type": "text"} insert data

1. Specify document ID insertion

PUT http://127.0.0.1:9200/people/man/1

{"name": "Zhang Renjie", "country": "China", "age": 30, "date": "1987-06-01"}

two。 Automatically generate document ID insertion

POST http://127.0.0.1:9200/people/man

{"name": "Zhang Hui", "country": "China", "age": 28, "date": "1990-11-01"} modify data

1. Direct modification

POST http://127.0.0.1:9200/people/man/1/_update

{"doc": {"name": "Jack", "age": 31}}

two。 Modify by script

Painless built-in scripting language

Ctx._source.age+=10

Ctx context

Source current document

POST http://127.0.0.1:9200/people/man/1/_update

{"script": {"lang": "painless", "inline": "ctx._source.age-=10"} {"script": {"lang": "painless", "inline": "ctx._source.age=params.age", "params": {"age": "100"}} delete operation

1. Delete document

DELETE http://127.0.0.1:9200/people/man/1

two。 Delete index

DELETE http://127.0.0.1:9200/people

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Internet Technology

Wechat

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

12
Report