dsmiley commented on code in PR #4910: URL: https://github.com/apache/solr/pull/4910#discussion_r4037592355
########## solr/solr-ref-guide/modules/indexing-guide/pages/indexing-with-update-handlers.adoc: ########## @@ -478,6 +479,44 @@ You can also specify `\_version_` with each "delete": You can specify the version of deletes in the body of the update request as well. +=== Newline Delimited JSON + +Solr also accepts https://ndjson.org/[Newline Delimited JSON] (ND-JSON), also known as JSON Lines or JSONL: one document per line, as a JSON Object, with no enclosing array and no commas between lines. + +Send it to the `/update` handler with `Content-Type: application/x-ndjson`, or to the dedicated `/update/ndjson` path: + +[source,bash] +---- +curl -X POST -H 'Content-Type: application/x-ndjson' 'http://localhost:8983/solr/my_collection/update?commit=true' --data-binary ' +{"id":"1","title":"Doc 1"} +{"id":"2","title":"Doc 2"} +{"id":"3","title":"Doc 3"} +' +---- + +`application/jsonl` and `application/x-jsonlines` are accepted as aliases, and the xref:post-tool.adoc[] sends `.jsonl` and `.ndjson` files automatically. +The format is UTF-8 only: a request declaring any other `charset` is rejected with a `415 Unsupported Media Type`. + +Solr parses and indexes the request as it streams in, so peak memory is bounded by the largest single document rather than by the size of the request, which makes the format a good fit for large bulk loads. +Blank lines are ignored. +A line that is not a single JSON Object -- an enclosing array, a document spread over several lines, two documents on one line, or anything that is not an Object -- fails the request, reporting the line number. +Documents from earlier lines have already been submitted when a later line fails, so a failed load may be partially applied. + +NDJSON carries documents only; the `add`, `delete`, `commit`, `optimize`, and `rollback` commands are not recognized, so use request parameters such as `commit` and `commitWithin` instead. Review Comment: "with optional commit / commitWithin" is confusing to tack on. I suspect you mean as a URL parameter but without having clarified that, reads very confusing because the NDJSON payload would not contain such _commands_. FWIW I think the statement here should be adapted to both mention it does *NOT* carry "commands", _and_ to emphasize that the payload is purely documents to add/update. Separately, note various commit etc. parameters can always be put on the URL no matter what the payload format is. -- 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]
