0

HI i am trying to index the JSON file as per

http://lucene.apache.org/solr/quickstart.html#indexing-json

but i get the following error in the console

X:\solr\solr-5.3.1\bin>java -Dc=bookcore -jar ..\example\exampledoc
s\post.jar ..\example\exampledocs\books.json
SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/bookcore/update using con
tent-type application/xml...
POSTing file books.json to [base]
SimplePostTool: WARNING: Solr returned an error #400 (Bad Request) for url: http
://localhost:8983/solr/bookcore/update
SimplePostTool: WARNING: Response: <?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">400</int><int name="QTime">30</int
></lst><lst name="error"><str name="msg">Unexpected character '[' (code 91) in p
rolog; expected '&lt;'
 at [row,col {unknown-source}]: [1,1]</str><int name="code">400</int></lst>
</response>
SimplePostTool: WARNING: IOException while reading response: java.io.IOException
: Server returned HTTP response code: 400 for URL: http://localhost:8983/solr/bo
okcore/update
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/bookcore/update...
Time spent: 0:00:00.063

why does it say unexpected character? Shouldn't it expect a JSON file? DO i need to make some changes in the solrconfig.xml for this core? by the way, here's how i created the core

solr create -c bookcore

please help.

thanks

3 Answers 3

2

You are using post.jar directly. It is not recommended anymore, and the post tool is slightly smarter. The tutorial linked actually uses that approach.

So you could do

.\post -c bookcore ..\example\exampledocs\books.json

or if you insist on using post.jar, you need to set the type as explained in other answers, but you need to make sure to pass the -D options before -jar command. Therefore:

java -Dc=bookcore -Dtype=application/json -jar ..\example\exampledocs\post.jar ..\example\exampledocs\books.json

If you still get complaints of different kind, try quoting "application/json" just in case Windows is having issues with slashes.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks man :) that did it. i was passing the -Dtype option after the -jar. Also, i can use the post tool as i am on windows. hence i must use the post jar
1

default type for POST tool is XML

-type (default: application/xml)

Try this

X:\solr\solr-5.3.1\bin>java -Dc=bookcore -jar ..\example\exampledoc
s\post.jar ..\example\exampledocs\books.json -Dtype=application/json

Try it this way.

1 Comment

Try -type application/json instead of -Dtype=application/json.
0

so this works

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

also, windows command line does not like single quotes! i would still like to know how to get post using the JAR.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.