Indexing documents using JSON
In the previous section, we saw how we can add
, update
, and delete
documents using XML. In this section, we'll see how we can perform the same operations using JSON data types.
We can send the JSON-formatted update request using Solr's update handler, by setting Content-type: application/json or text/json. There are three basic types of JSON documents that can be sent to Solr. They are:
- A single document
- A list of documents—an array of documents
- A sequence of updated documents—a map type object that contains multiple commands
Adding a single document
We can add a single JSON document to Solr by posting the data to the /update/json/docs
handler path. The following is an example of indexing JSON data in Solr:
$ curl 'http://localhost:8983/solr/musicCatalog/update/json/docs' -H 'Content-Type: application/json' --data-binary ' { "songId":100000006, "songName":"Fester Skank (feat. Diztortion...