janhoy commented on PR #4177:
URL: https://github.com/apache/solr/pull/4177#issuecomment-5641534581
I hit an issue trying to do atomic update (JSON format) using v2 `/update`
api. Does not work, and SOLR-11265 has been open for 9 years. Then I found this
PR which looks promising in making some decent decisions for how the V2 JAX-RS
update APIs should work.
I'm leaning towards making the base `/api/collections/{collection}/update`
endpoint support multiple input formats (much like for v1). The HTTP standard
supports this through `Content-Type` already. That way clients can be explicit
in what they send and solr never need to doubt. We can also make extension
content-types for solr e.g. for the "commands" JSON syntax:
| Content-Type | Behavior |
|---|---|
| `application/json`, `text/csv`, `application/xml` | Straightforward, same
as today's sub-paths |
| `application/javabin` or `application/vnd.solr.javabin` | SolrJ's native
binary format, already used internally, just exposed as a `Content-Type` on the
main endpoint instead of only `/update/bin` |
| `application/x-ndjson` | One JSON doc per line, for streaming bulk loads
without a top-level array |
| `application/vnd.solr.commands+json` | Top-level JSON parsed as the
v1-style command envelope (`add`/`delete`/`commit`), restoring what this PR's
table marks as unsupported in v2 |
| `application/vnd.solr.atomic+json` | Tells Solr that `{"set": ...}`,
`{"add": ...}`, `{"inc": ...}` are atomic-update operators, not literal field
structure — directly fixes SOLR-11265 by making intent explicit instead of
guessing |
Example:
```bash
curl -X POST
'http://localhost:8983/api/collections/mycollection/update?commit=true' \
-H 'Content-Type: application/vnd.solr.atomic+json' \
--data-binary '{"id": "mydoc", "price": {"set": 99}}'
```
Not entirely sure whether atomic-syntax should be supported in normal
`application/json`, I think it is problematic since we also need to support
nested child docs and that gets ambigous. So an explicit
`application/vnd.solr.atomic+json` would let Solr know what to expect. But then
if you want atomic update of a deeply nested JSON -- well, what to do? Time to
namespace the atomic qualifiers to avoid confusion, e.g. `inc` becomes `_inc_`,
`set` becomes `_set_` or similar.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]