You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Dennis Brundage <de...@gdit.com> on 2013/10/02 17:46:40 UTC

Submitting Multiple JSON documents from Solr Admin Documents

Is it possible to submit multiple JSON documents through the Solr Admin
Documents page?

The default json is: {"id":"change.me","title":"change.me"}. If I try to add
a second document such as {"id":"change.me2","title":"change.me"}, and
submit them together, I get parsing errors.  I have tried:

1.
{"id":"change.me","title":"change.me"}{"id":"change2.me","title":"change.me2"}
2.
{{"id":"change.me","title":"change.me"}{"id":"change2.me","title":"change.me2"}}
3.
{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}
4.
{{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}}

The parsing errors for items 2, 3 and 4 are (the parsing error for 1
indicates the need for either "," or "}" after the first json document.

"msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
AFTER='\"id\":\"change.me\",\"title\":\"change.me\"}{\"'",

"msg": "Expected string: char={,position=54 BEFORE='{\"add\":{
\"doc\":{\"id\":\"change.me\",\"title\":\"change.me\"},{'
AFTER='\"id\":\"change.me2\",\"title\":\"change.me\"},'",

"msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
AFTER='\"id\":\"change.me\",\"title\":\"change.me\"},{'",




--
View this message in context: http://lucene.472066.n3.nabble.com/Submitting-Multiple-JSON-documents-from-Solr-Admin-Documents-tp4093155.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Submitting Multiple JSON documents from Solr Admin Documents

Posted by Jack Krupansky <ja...@basetechnology.com>.
Use square brackets (array) around a list of documents:

[{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}]

-- Jack Krupansky

-----Original Message----- 
From: Dennis Brundage
Sent: Wednesday, October 02, 2013 11:46 AM
To: solr-user@lucene.apache.org
Subject: Submitting Multiple JSON documents from Solr Admin Documents

Is it possible to submit multiple JSON documents through the Solr Admin
Documents page?

The default json is: {"id":"change.me","title":"change.me"}. If I try to add
a second document such as {"id":"change.me2","title":"change.me"}, and
submit them together, I get parsing errors.  I have tried:

1.
{"id":"change.me","title":"change.me"}{"id":"change2.me","title":"change.me2"}
2.
{{"id":"change.me","title":"change.me"}{"id":"change2.me","title":"change.me2"}}
3.
{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}
4.
{{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}}

The parsing errors for items 2, 3 and 4 are (the parsing error for 1
indicates the need for either "," or "}" after the first json document.

"msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
AFTER='\"id\":\"change.me\",\"title\":\"change.me\"}{\"'",

"msg": "Expected string: char={,position=54 BEFORE='{\"add\":{
\"doc\":{\"id\":\"change.me\",\"title\":\"change.me\"},{'
AFTER='\"id\":\"change.me2\",\"title\":\"change.me\"},'",

"msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
AFTER='\"id\":\"change.me\",\"title\":\"change.me\"},{'",




--
View this message in context: 
http://lucene.472066.n3.nabble.com/Submitting-Multiple-JSON-documents-from-Solr-Admin-Documents-tp4093155.html
Sent from the Solr - User mailing list archive at Nabble.com. 


Re: Submitting Multiple JSON documents from Solr Admin Documents

Posted by Chris Hostetter <ho...@fucit.org>.
: After putting brackets around the doucments:
: 
: [{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}] 
: 
: I get the following error:


There are two ways of submitting JSON using the /documents screen...

1) select "JSON" from the pulldown...

this accepts only a single JSON document to be added, because it wraps 
it in tags like so...

{"add":{ "doc": YOUR_TEXT_AREA_INPUT,
         "boost": BOOST_FORM_INPUT,
         "overwrite": CHECKBOX_INPUT,
         "commitWithin": COMMIT_WITHIN_FORM_INPUT } }

(likewise, similar wrapper tags are added if you select "XML" from the 
pulldown)

2) select "Solr command (raw XML or JSON)" from the pulldown...

this accepts any arbitrary xml or json you wish to post, and you can do 
multiple documents using the json array notation -- the UI doesn't touch 
what you give it at all.


(NOTE: if you change the "Update Handler" text box at teh top of the page 
to "/debug/dump" -- using the example configs -- you can see solr echo 
back exactly what the UI is sending when you submit the form)


-Hoss

Re: Submitting Multiple JSON documents from Solr Admin Documents

Posted by Dennis Brundage <de...@gdit.com>.
After putting brackets around the doucments:

[{"id":"change.me","title":"change.me"},{"id":"change2.me","title":"change.me2"}] 

I get the following error:

"msg": "Expected: OBJECT_START but got ARRAY_START at [16]",


I can submit multiple documents using post.jar, but was curious if there is
some trick that I am missing to get it working on the Solr Admin Documents
page (http://localhost:8983/solr/#/collection1/documents). I am using the
Solr 4.4 example server.





--
View this message in context: http://lucene.472066.n3.nabble.com/Submitting-Multiple-JSON-documents-from-Solr-Admin-Documents-tp4093155p4093170.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Submitting Multiple JSON documents from Solr Admin Documents

Posted by Stefan Matheis <ma...@gmail.com>.
Hm, actually this post made me think, perhaps it would be a good idea to integrate some kind of client-side validation? So we could report back at least those "basic" JSON-format errors?

-Stefan 


On Wednesday, October 2, 2013 at 6:15 PM, Stefan Matheis wrote:

> Dennis
> 
> Have a look at the wiki .. last code-block in the section: http://wiki.apache.org/solr/UpdateJSON#Example
> 
> -Stefan 
> 
> On Wednesday, October 2, 2013 at 5:46 PM, Dennis Brundage wrote:
> 
> > Is it possible to submit multiple JSON documents through the Solr Admin
> > Documents page?
> > 
> > The default json is: {"id":"change.me (http://change.me)","title":"change.me (http://change.me)"}. If I try to add
> > a second document such as {"id":"change.me2","title":"change.me (http://change.me)"}, and
> > submit them together, I get parsing errors. I have tried:
> > 
> > 1.
> > {"id":"change.me (http://change.me)","title":"change.me (http://change.me)"}{"id":"change2.me (http://change2.me)","title":"change.me2"}
> > 2.
> > {{"id":"change.me (http://change.me)","title":"change.me (http://change.me)"}{"id":"change2.me (http://change2.me)","title":"change.me2"}}
> > 3.
> > {"id":"change.me (http://change.me)","title":"change.me (http://change.me)"},{"id":"change2.me (http://change2.me)","title":"change.me2"}
> > 4.
> > {{"id":"change.me (http://change.me)","title":"change.me (http://change.me)"},{"id":"change2.me (http://change2.me)","title":"change.me2"}}
> > 
> > The parsing errors for items 2, 3 and 4 are (the parsing error for 1
> > indicates the need for either "," or "}" after the first json document.
> > 
> > "msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
> > AFTER='\"id\":\"change.me (http://change.me)\",\"title\":\"change.me (http://change.me)\"}{\"'",
> > 
> > "msg": "Expected string: char={,position=54 BEFORE='{\"add\":{
> > \"doc\":{\"id\":\"change.me (http://change.me)\",\"title\":\"change.me (http://change.me)\"},{'
> > AFTER='\"id\":\"change.me2\",\"title\":\"change.me (http://change.me)\"},'",
> > 
> > "msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
> > AFTER='\"id\":\"change.me (http://change.me)\",\"title\":\"change.me (http://change.me)\"},{'",
> > 
> > 
> > 
> > 
> > --
> > View this message in context: http://lucene.472066.n3.nabble.com/Submitting-Multiple-JSON-documents-from-Solr-Admin-Documents-tp4093155.html
> > Sent from the Solr - User mailing list archive at Nabble.com (http://Nabble.com).
> > 
> > 
> > 
> 
> 


Re: Submitting Multiple JSON documents from Solr Admin Documents

Posted by Stefan Matheis <ma...@gmail.com>.
Dennis

Have a look at the wiki .. last code-block in the section: http://wiki.apache.org/solr/UpdateJSON#Example

-Stefan 


On Wednesday, October 2, 2013 at 5:46 PM, Dennis Brundage wrote:

> Is it possible to submit multiple JSON documents through the Solr Admin
> Documents page?
> 
> The default json is: {"id":"change.me (http://change.me)","title":"change.me (http://change.me)"}. If I try to add
> a second document such as {"id":"change.me2","title":"change.me (http://change.me)"}, and
> submit them together, I get parsing errors. I have tried:
> 
> 1.
> {"id":"change.me (http://change.me)","title":"change.me (http://change.me)"}{"id":"change2.me (http://change2.me)","title":"change.me2"}
> 2.
> {{"id":"change.me (http://change.me)","title":"change.me (http://change.me)"}{"id":"change2.me (http://change2.me)","title":"change.me2"}}
> 3.
> {"id":"change.me (http://change.me)","title":"change.me (http://change.me)"},{"id":"change2.me (http://change2.me)","title":"change.me2"}
> 4.
> {{"id":"change.me (http://change.me)","title":"change.me (http://change.me)"},{"id":"change2.me (http://change2.me)","title":"change.me2"}}
> 
> The parsing errors for items 2, 3 and 4 are (the parsing error for 1
> indicates the need for either "," or "}" after the first json document.
> 
> "msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
> AFTER='\"id\":\"change.me (http://change.me)\",\"title\":\"change.me (http://change.me)\"}{\"'",
> 
> "msg": "Expected string: char={,position=54 BEFORE='{\"add\":{
> \"doc\":{\"id\":\"change.me (http://change.me)\",\"title\":\"change.me (http://change.me)\"},{'
> AFTER='\"id\":\"change.me2\",\"title\":\"change.me (http://change.me)\"},'",
> 
> "msg": "Expected string: char={,position=16 BEFORE='{\"add\":{ \"doc\":{{'
> AFTER='\"id\":\"change.me (http://change.me)\",\"title\":\"change.me (http://change.me)\"},{'",
> 
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Submitting-Multiple-JSON-documents-from-Solr-Admin-Documents-tp4093155.html
> Sent from the Solr - User mailing list archive at Nabble.com (http://Nabble.com).
> 
>