Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-15213

Add support for "merge" atomic update operation for child documents

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 9.0
    • None
    • None

    Description

      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: 
       

      {"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"}]
      }

       
      If we later want to update that child doc e.g.:

      {"id": "ocean1", 
      "_isParent":"true", 
      "fish": [ 
          {
           "id": "fish1", 
           "type_s": "fish", 
           "name_s": "James", // new name
           "_isParent":"false"}, 
      ]
      }

       
      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.

       

       

      Attachments

        1. SOLR-15213.patch
          13 kB
          James Ashbourne
        2. SOLR-15213-1.patch
          17 kB
          Endika Posadas
        3. SOLR-15213-2.patch
          17 kB
          Endika Posadas
        4. SOLR-15213-3.patch
          20 kB
          David Smiley

        Issue Links

          Activity

            People

              dsmiley David Smiley
              jamesa-ravn James Ashbourne
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: