Hello all,
I want to add a new feature to the Solr Output connector that is the
Atomic Update functionality of Solr to do partial document updates.
This involves modifying the syntax of the /update request made to Solr
to add modifiers to the fields you wish to update:
Example Updating Part of a Document
If the following document exists in our collection:
|{"id":"mydoc", "price":10, "popularity":42, "categories":["kids"],
"sub_categories":["under_5","under_10"], "promo_ids":["a123x"],
"tags":["free_to_try","buy_now","clearance","on_sale"] }|
copy icon
And we apply the following update command:
|{"id":"mydoc", "price":{"set":99}, "popularity":{"inc":-7},
"categories":{"add":["toys","games"]},
"sub_categories":{"add-distinct":"under_10"},
"promo_ids":{"remove":"a123x"},
"tags":{"remove":["free_to_try","on_sale"]} }|
copy icon
The resulting document in our collection will be:
|{"id":"mydoc", "price":99, "popularity":35,
"categories":["kids","toys","games"],
"sub_categories":["under_5","under_10"], "tags":["buy_now","clearance"] }|
My first idea was to modify the request made to Solr in the current
connector, but the creation of this request seems rather complex... I'm
afraid I'd have to go too deep into the current code to add my
modifications. And I haven't yet found the best place to do it.
Is it possible to do this using the RepositoryDocument in the
addOrReplaceDocumentWithException() method? Using this object, I was
able to specify fields to set, but I don't think I can add values to a
multivalued field...
Do you have any advice?
Regards,
Guylaine