Adding Multiple JSON Documents

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding Multiple JSON Documents

John Davis
Hi there,

I was looking at the solr documentation for indexing multiple documents via
json and noticed inconsistency in the docs.

Should the POST url be /update/*json/docs *instead of just /update. It does
look like former does work, unless both will work just fine?

https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#adding-multiple-json-documents
Adding Multiple JSON Documents
<https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#adding-multiple-json-documents>

Adding multiple documents at one time via JSON can be done via a JSON Array
of JSON Objects, where each object represents a document:

curl -X POST -H 'Content-Type: application/json'
'http://localhost:8983/solr/my_collection/*update*' --data-binary '[
{    "id": "1",    "title": "Doc 1"  },  {    "id": "2",    "title":
"Doc 2"  }]'
Reply | Threaded
Open this post in threaded view
|

Re: Adding Multiple JSON Documents

Jason Gerlowski
Hi John,

I believe the documentation there is correct.  That is: those are two
different "update" APIs.  /update takes a JSON array of potentially
multiple docs, /update/json/docs takes either a JSON array of multiple
docs, or a single document not wrapped in the JSON array syntax.

Best,

Jason

On Sun, Jun 2, 2019 at 10:50 PM John Davis <[hidden email]> wrote:

>
> Hi there,
>
> I was looking at the solr documentation for indexing multiple documents via
> json and noticed inconsistency in the docs.
>
> Should the POST url be /update/*json/docs *instead of just /update. It does
> look like former does work, unless both will work just fine?
>
> https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#adding-multiple-json-documents
> Adding Multiple JSON Documents
> <https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#adding-multiple-json-documents>
>
> Adding multiple documents at one time via JSON can be done via a JSON Array
> of JSON Objects, where each object represents a document:
>
> curl -X POST -H 'Content-Type: application/json'
> 'http://localhost:8983/solr/my_collection/*update*' --data-binary '[
> {    "id": "1",    "title": "Doc 1"  },  {    "id": "2",    "title":
> "Doc 2"  }]'
Reply | Threaded
Open this post in threaded view
|

Re: Adding Multiple JSON Documents

Alexandre Rafalovitch
In reply to this post by John Davis
Hi John,

This may be useful:
https://www.slideshare.net/arafalov/json-in-solr-from-top-to-bottom
(there is the video of the session at the end too).

Basically, we have two ways to process JSON and sometimes they look
very similar and you have to be very deliberate in indicating which
one is the correct way.

Regards,
   Alex.

On Sun, 2 Jun 2019 at 22:50, John Davis <[hidden email]> wrote:

>
> Hi there,
>
> I was looking at the solr documentation for indexing multiple documents via
> json and noticed inconsistency in the docs.
>
> Should the POST url be /update/*json/docs *instead of just /update. It does
> look like former does work, unless both will work just fine?
>
> https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#adding-multiple-json-documents
> Adding Multiple JSON Documents
> <https://lucene.apache.org/solr/guide/7_3/uploading-data-with-index-handlers.html#adding-multiple-json-documents>
>
> Adding multiple documents at one time via JSON can be done via a JSON Array
> of JSON Objects, where each object represents a document:
>
> curl -X POST -H 'Content-Type: application/json'
> 'http://localhost:8983/solr/my_collection/*update*' --data-binary '[
> {    "id": "1",    "title": "Doc 1"  },  {    "id": "2",    "title":
> "Doc 2"  }]'