• Home
  • LLMs
  • Python
  • Docker
  • Kubernetes
  • Java
  • All
  • About
Apache Solr | XML Messages: Update documents
  1. Notes
  2. Example of an XML message to update an existing document
  3. Update a document using the update request handler
  4. Update a document using the update request handler (stream.body)

  1. Notes
    Please visit this Solr wiki pages for more information:
    https://cwiki.apache.org/confluence/display/solr/UpdateXmlMessages

    Here's the structure of the update operation:

    Optional attributes for the "add" element:
    • commitWithin: (milliseconds) time for the document to be committed.

    Optional attributes for the "doc" element:
    • boost: (default: 1.0) a float number for the document boost value.

    Optional attributes for the "field" element:
    • boost: (default: 1.0) a float number for the field boost value.

    • update: "set" | "add" | "inc"

      With:
      • set: sets a value (if null remove the value, or, in the case of a multi-valued field, remove all the values).

      • add: adds a new value to a multi-valued field.

      • inc: increments a value by a specific number.

      Important: If none of the document "field" elements sets the "update" attribute, then the operation will be considered an "add" operation.
      Which means that the document will be added if it's a new document, or updated if it was already added (missing fields will be set to null or to a default value).
  2. Example of an XML message to update an existing document
    Example: (Make sure that the fields "id", "field1", and "field2" are defined in your SchemaXml).
  3. Update a document using the update request handler
    Here's an example of an http request:
  4. Update a document using the update request handler (stream.body)
    Here's an example of an http request that uses the parameter stream.body:

    In order for this request to work, you need to enable Streaming in "solrconfig.xml":

    If you want to update the "solrconfig.xml" file directly in the Configset, make sure to reload all collections that use the updated Configset.
    Please visit this page for more details: http://lucene.apache.org/solr/guide/8_5/requestdispatcher-in-solrconfig.html
© 2025  mtitek