lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Solr Wiki] Update of "UpdateJSON" by YonikSeeley
Date Tue, 07 Dec 2010 16:12:01 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "UpdateJSON" page has been changed by YonikSeeley.
The comment on this change is: start doc for JSON updates.


New page:
= Updating a Solr Index with JSON =

Solr accepts index updates in [[|JSON]] format.

<!> [[Solr3.1]]


== Requirements ==
<!> [[Solr3.1]] is the first version with JSON support for updates.

The JSON request handler needs to be configured in solrconfig.xml
This should already be present in the example solrconfig.xml
  <requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler"/>

== Methods of sending JSON ==
JSON formatted update requests may be sent to Solr via the /solr/update/json URL.
All of the normal methods for [[ContentStream|uploading content]] are supported.

=== Example ===
There is a sample JSON file at {{{example/exampledocs/books.json}}} that may be used to add
documents to the solr example server.

Example of using HTTP-POST to index the JSON:
cd example/exampledocs
curl 'http://localhost:8983/solr/update/json?commit=true' --data-binary @books.json -H 'Content-type:application/json'

Note that we added "commit=true" to the URL so that the documents would be immediately searchable.

You should now be able to query for the newly added documents:
        "author":"Rick Riordan",
        "series_t":"Percy Jackson and the Olympians",
          "The Sea of Monsters"],

It's also easy to specify JSON documents from the command line for testing purposes and scripts
(assumes a UNIX environment):
curl $URL -H 'Content-type:application/json' -d '
 "add": {
  "doc": {
    "id" : "MyTestDocument",
    "title" : "This is just a test"
curl "$URL?commit=true"

View raw message