[ https://issues.apache.org/jira/browse/SOLR-15213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17438674#comment-17438674 ]
David Smiley commented on SOLR-15213: ------------------------------------- {quote}Why not allow the atomic update operation to insert the child document if it doesn't exist? {quote} Fundamentally, an atomic update is a modification to a document that already exists (by ID). Atomic updates are partial documents in general – lacking fields that didn't change. A doc is either a partial update or it isn't. I could imagine Solr supporting a hybrid where it's both, thus requiring the provided doc to have all required fields in case it won't be replacing an existing doc. But I +prefer+ to avoid adding that as it may be too complex for users to understand, for us to document, and to maintain in the codebase. I'm trying to ascertain here if that is truly needed for the use-case presented here. The tests were a bit low-level and none high-level so it wasn't evident to me. The logic in my previous comment satisfies the scenario presented in the issue description, at least. If you agree with my previous comment, can you re-form the contribution as I suggested? Sorry it took so long for me to provide feedback on this. Feel free to poke/remind us committers in general. > Add support for "merge" atomic update operation for child documents > ------------------------------------------------------------------- > > Key: SOLR-15213 > URL: https://issues.apache.org/jira/browse/SOLR-15213 > Project: Solr > Issue Type: New Feature > Reporter: James Ashbourne > Priority: Major > Attachments: SOLR-15213.patch > > > Solr has "add", "set", "add-distinct" which work but all have their > limitations. Namely, there's currently no way to atomically update a document > where that document may or may not be present already by merging if it is > present and inserting if it isn't. > i.e. in the scenario where we have a document with two nested children: > > {noformat} > {"id": "ocean1", > "_isParent":"true", > "fish": [ > { > "id": "fish1", > "type_s": "fish", > "name_s": "Doe", > "_isParent":"false"}, > { > "id": "fish2", > "type_s": "fish", > "name_s": "Hans", > "_isParent":"false"}] > }{noformat} > > If we later want to update that child doc e.g.: > {noformat} > {"id": "ocean1", > "_isParent":"true", > "fish": [ > { > "id": "fish1", > "type_s": "fish", > "name_s": "James", // new name > "_isParent":"false"}, > ] > }{noformat} > > Existing operations: > - "add" - will add another nested doc with the same id leaving us with two > children with the same id. > - "set" - replaces the whole list of child docs with the single doc, we > could use this but would first have to fetch all the existing children. > - "add-distinct" - will reject the update based on the doc already being > present. > I've got some changes (see patch) that a new option "merge" which checks > based on the id and merges the new document with the old with a fall back to > add if there is no id match. > > -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org