Perform adds with field updates using JSON #374
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds support for doing field updates using JSON instead of XML. I have a need for this due to the intersection of indexing nested documents and field updates.
Indexing nested documents can now work with labelled fields:
https://solr.apache.org/guide/8_0/indexing-nested-documents.html#xml-examples
https://solr.apache.org/guide/8_0/indexing-nested-documents.html#json-examples
And this is preferred over the anonymous way, using the special key _childDocuments_ which pysolr currently supports.
This currently works when using JSON serialization (the default), but the child documents end up being serialized as a string when using XML serialization (which happens when field updates is set).
Field updates can be done through JSON (the documentation actually doesn't even show the XML syntax anymore):
https://solr.apache.org/guide/8_0/updating-parts-of-documents.html#example-updating-part-of-a-document
I have implemented field updates with JSON serialization. I did not add any tests, but I believe the existing field update tests validate the JSON implementation.
This leaves XML serialization to be used only for index time boosts, which have been removed in version 7:
https://solr.apache.org/docs/7_0_0/changes/Changes.html#v7.0.0.upgrading_from_solr_6.x
I believe this means the XML serialization can be completely dropped, but I wanted to check with you if this is something you would be willing to merge in. If it is, I would be happy to continue working on this.