scrapy-elasticsearch icon indicating copy to clipboard operation
scrapy-elasticsearch copied to clipboard

is it possible update item if this item with id exists?

Open heilwood opened this issue 5 years ago • 2 comments

Is it possible update item if this item with same id already exists in elastic instead of adding new one? I mean: { itemId: 1, color: ['red', 'blue'] } { itemId: 1, color: ['green'] }

result: { itemId: 1, color: ['red', 'blue', 'green'] }

heilwood avatar Jan 07 '20 19:01 heilwood

did you set a uniq field?

jrayu avatar May 27 '20 06:05 jrayu

just roughly read the code, you would find the _id field is a hash of your unique fields. i guess the same unique fields together would lead you to the same id. with the python elasticsearch.index api it updates the entry if the id is specified and exists in the database.

jrayu avatar May 27 '20 07:05 jrayu