Elasticsearch DSL Query for Update

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Elasticsearch DSL Query for Update



I understand that I am able to update a particular document by http://localhost:9200/[index_name]/[index_type]/[_id], but I have document where the _id has # symbols which Sense couldn't find them.



Understand that the Query DSL will be able to perform a search where I am able to indicate the _id not in the URL.
Resource: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html



Can I check with you, how can I do the same for updating document?




2 Answers
2



If you don't want to put the ID in the URL, the only option you have is to use the update by query API, like this:


POST index/_update_by_query

"query":
"ids":
"values": ["2323#23423"]

,
"script":
"source": "do some update here"






thanks for the response. I am using Elasticsearch version 1.3.3 and I think this version don't have the update_by_query. I used "index/_update_by_query" and it throws error: "InvalidTypeNameException[mapping type name [_update_by_query] can't start with '']", status 400.
– xxestter
Aug 12 at 8:23





In that case, you can use the update by query 2.2.0 plugin that worked for ES 1.3.3
– Val
Aug 12 at 9:14






thank you for the response. The _update_by_query won't be able to create new document if 2323#23423 is not in the index. May I ask you what about the creation of new document?
– xxestter
Aug 13 at 11:54





Your question didn't mention anything about creating the document if it was missing.
– Val
Aug 13 at 12:03





No, I don't have luck on this. I will create a new question regarding the creation of the document. Thanks for your advise.
– xxestter
Aug 14 at 5:26



Use localhost:9200/index/type/ID%23, %23 for #



So if '_id' is 10, url will look like localhost:9200/index/type/10%23





There might be other special characters that the users might enter, so I would like to ask whether is there any workaround rather than having the _id on the url. Thank you for the response.
– xxestter
Aug 12 at 8:25





It would be _update_by_query as suggested by Val
– Biplab
Aug 20 at 8:53






Yes, I marked his response as the accepted answer. Thank you.
– xxestter
Aug 21 at 12:41






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard