[ 
https://issues.apache.org/jira/browse/SOLR-15213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17454008#comment-17454008
 ] 

Endika Posadas commented on SOLR-15213:
---------------------------------------

 I have reviewed your comments:
 * Changed from Invalid and Forbidden to BAD REQUEST
 * I am converting it to String. I have also changed the code a little bit to 
make it more obvious. I was reviewing how the id is read in AddUpdateCommand 
but it looks like it's the same mechanism, converting it to string:
{code:java}
this.childDocIdStr = field.getFirstValue().toString();{code}

 * The reason for changing the assertions int lists is to make it more 
consistent. I have noticed in the tests that sometimes there are square 
brackets and sometimes there aren't without any apparent reason. However, as 
you said, "add" implies a list, so it makes more sense that it's always an 
array.



Thanks, I have uploaded a new patch.

> 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-1.patch, 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.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to