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

Add support for arrays of operations to JSON Update Handler

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.0-BETA
    • None
    • update

    Description

      Currently, UpdateRequestHandler accepts a sequence of operations in JSON format by specifying duplicate keys. While duplicate keys aren't forbidden by the JSON spec, in practice, this makes the update handler difficult to use in conjunction with JSON serialization libraries in clients.

      This has been mitigated somewhat by adding special syntax to add and delete in SOLR-2496 and SOLR-3508 respectively, but there's still no way to specify operations in a particular sequence as you can with XML. Per the JSON spec, the right way to do this is with an array, as objects are considered unordered sets.

      Using an array at the top level would obviate the need for such a key, but that syntax was used in the fix for SOLR-2496 as a shortcut for adds, so...

      The attached patch adds an "operations" key that can exist at the same level as any other operation. The "operations" key's value is an array of objects, each of which uses the same syntax as the root object:

      {
        "operations": [
            {"add": {"id": "1"}},
            {"delete": {"query": "foo"}},
            {"add": {"id": "2"}},
            {"commit": {}},
        ]
      }
      

      Attachments

        1. SOLR-3887.patch
          4 kB
          Jesse Dubay

        Activity

          People

            Unassigned Unassigned
            vreon Jesse Dubay
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: