简体   繁体   中英

How to specify version type in elasticsearch

I'm trying to index a document as shown below.

curl -s -XPUT -H"content-type:application/json" -d@data.json localhost:9200/contacts/_doc/1?version=7&version_type=external

Unfortunately this results in version conflict. Elasticsearch documentation says that I should pass version_type as external when I use an external version. But I'm not sure how to do this as its not supporting this as a query parameter.

How do I specify version_type as external?

EDIT: current version of the document is 5. But according to es documentation , when version_type external is used, any higher version should work. Which means 7 should be able to overwrite 5. But as I'm getting version conflict I assume that es is not taking the version_type parameter that I'm specifying.

SOLVED: I had to put the URL given to curl in quotes. Bash took the & in in URL, took rest of it as new command and set version_type as an environment variable.

Your curl command looks correct. The conflict can come because of the different versions of the document.

I would guess that the current version of the document is not 7 and hence it throws the version conflict.

Can you post the current version of this same document? Is it 7 ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM