Check the examples of update/json here:

http://wiki.apache.org/solr/UpdateJSON

In your case, either leave out the "add" level or add a "doc" level below it.

For example:

curl http://localhost:8983/solr/update/json -H 'Content-type:application/json' -d '
{
"add": {"doc": {"id" : "TestDoc1", "title" : "test1"} },
"add": {"doc": {"id" : "TestDoc2", "title" : "another test"} }
}'

-- Jack Krupansky

-----Original Message----- From: Rajesh Jain
Sent: Monday, May 14, 2012 1:27 PM
To: solr-user@lucene.apache.org
Cc: Rajesh Jain
Subject: Update JSON not working for me

Hi,

I am using the 4.x version of Solr, and following the UpdateJSON Solr Wiki

1. When I try to update using :

curl 'http://localhost:8983/solr/update/json?commit=true'
--data-binary @books.json -H 'Content-type:application/json'

I don't see any Category as Books in Velocity based Solr Browser the
http://localhost:8983/solr/collection1/browse/?

I see the following message on the startup window when I run this command
C:\Tools\Solr\apache-solr-4.0-2012-05-04_08-23-31\example\exampledocs>C:\tools\curl\curl
http://localhost:8983/solr/update/json?commit=true --data-binary
@books
.json -H 'Content-type:application/json'
{
 "responseHeader":{
   "status":0,
   "QTime":47}}

2. I wrote my own JSON file where I added an extra "add" directive

My JSON File
[
 {
"add":{
"id" : "MXN",
"cat" : ["currency"],
"name" : "One Peso",
"inStock" : true,
"price_c" : "1,MXN",
"manu" : "384",
"manu_id_s" : "Bank Mexico",
"features":"Coins and notes"
     }
   }
]

I still don't see the addition in the existing Currency Categories.


Please let me know if the UPDATEJSON works in 4.x or is this only for 3.6?

Thanks
Rajesh

Reply via email to