Reputation: 1432
I am new to Elastic Search db. With id property i am able to do update and delete but without id property (I mean another property of document which is unique) it is not working. Please let me know, can we do it or not.
Upvotes: 4
Views: 3860
Reputation: 1432
Here is the query to update
POST /indexName/typeName/_update_by_query
{
"query": {
"match": {
"name": "abc"
}
},
"script": {
"inline": "ctx._source.description = 'Updated description'"
}
}
Here is the query delete
POST /indexName/typeName/_delete_by_query
{
"query": {
"match": {
"name": "abc"
}
}
}
Upvotes: 1
Reputation: 2090
You can use _delete_by_query
API.
_delete_by_query
gets a snapshot of the index when it starts and deletes what it finds using internal versioning. That means that you’ll get a version conflict if the document changes between the time when the snapshot was taken and when the delete request is processed. When the versions match the document is deleted.
Code snippet.
POST twitter/_delete_by_query
{
"query": {
"match": {
"message": "some message"
}
}
}
Upvotes: 0
Reputation: 728
I think what you are looking for is
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
POST twitter/_update_by_query?conflicts=proceed
{
"query": {
"term": {
"user": "kimchy"
}
}
}
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
POST twitter/_delete_by_query
{
"query": {
"match": {
"message": "some message"
}
}
}
Upvotes: 5