janhoy commented on code in PR #4910: URL: https://github.com/apache/solr/pull/4910#discussion_r4037554197
########## 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. Review Comment: Added it as a fourth alias and now only linking to jsonlines.org ########## 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. Review Comment: Added a sentence about it and also explicitly set `FLAGS_STRICT` in Noggit, so JSON syntax for each line is enforced. -- 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]
