Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to analyze the ElasticSearch basic interaction

Shulou Source: shulou.com Published: 2022-06-01 04:31:43 10月02日 Update

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.

Tags: Documents structure data indexes scripts help structure basics analysis clarity context context key words content to this articles novices ways more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn Shulou Information Docker Microsoft