You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2011/06/29 21:07:57 UTC
[Solr Wiki] Update of "UpdateJSON" by YonikSeeley
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:
http://wiki.apache.org/solr/UpdateJSON?action=diff&rev1=4&rev2=5
Comment:
use array-of-object style in examples
{{{
URL=http://localhost:8983/solr/update/json
curl $URL -H 'Content-type:application/json' -d '
+ [
+ {
- {
- "add": {
- "doc": {
"id" : "MyTestDocument",
"title" : "This is just a test"
}
+ ]'
- }
- }'
curl "$URL?commit=true"
}}}
Here's a simple example of adding more than one document at once:
{{{
curl http://localhost:8983/solr/update/json -H 'Content-type:application/json' -d '
- {
+ [
- "add": {"doc": {"id" : "TestDoc1", "title" : "test1"} },
+ {"id" : "TestDoc1", "title" : "test1"},
- "add": {"doc": {"id" : "TestDoc2", "title" : "another test"} }
+ {"id" : "TestDoc2", "title" : "another test"}
- }'
+ ]'
}}}
== Update Commands ==
@@ -121, +119 @@
Just as in the other update handlers, parameters such as commit, commitWithin, optimize, and overwrite may be specified in the URL instead of in the body of the message.
+ == Solr 3.1 Example ==
+ Solr 3.2 was the first version to support the array-of-JSONObject syntax, so in Solr 3.1 one needs to use duplicate names (the "add" tag)
+ to add more than one document at once. This is valid JSON. 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"} }
+ }'
+ }}}
+