Reputation: 83
I'm trying to post some document(json format) into solr using the below commands in command prompt, but always I'm getting 400 Bad Request error. Java_Version:1.8.0; Solr_Version:7.2
CMD:
C:\..\..\solr-7.2.1\example\exampledocs>java -Dtype=text/json -Durl=http://localhost:8983/solr/mycore/update -jar post.jar books.json
Error:
SimplePostTool: WARNING: Solr returned an error #400 (Bad Request) for url: http://localhost:8983/solr/mycore/update
SimplePostTool: WARNING: Response: {
"responseHeader":{
"status":400,
"QTime":1},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"This IndexSchema is not mutable.",
"code":400}}
SimplePostTool: WARNING: IOException while reading response: java.io.IOException: Server returned HTTP response code: 400 for URL: http://localhost:8983/solr/mycore/update
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/mycore/update...
Time spent: 0:00:00.062
I've added the request handler in solrconfig.xml
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
and <schemaFactory class="ClassicIndexSchemaFactory"/>
-> for referring to schema.xml file
Schema.xml: (new fields added for my indexing)
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="_version_" type="plong" indexed="false" stored="false"/>
<field name="_root_" type="string" indexed="true" stored="false" docValues="false" />
<field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
<!-- new fields -starts -->
<field name="cat" type="text_general" indexed="true" stored="true"/>
<field name="name" type="text_general" indexed="true" stored="true"/>
<field name="price" type="pdouble" indexed="true" stored="true"/>
<field name="inStock" type="boolean" indexed="true" stored="true"/>
<field name="author" type="text_general" indexed="true" stored="true"/>
<!-- new fields -ends -->
My Unique key is 'ID'.
Upvotes: 1
Views: 3342
Reputation: 620
use java -Dc=core_name -Dauto=yes -Dtype=application/json -jar post.jar *.json
i dont know why it worked.
Upvotes: 2
Reputation: 52902
If you started with the schemaless configuration, there is going to be an update chain defined for any update request. You'll have to remove that configuration to stop Solr from trying to automagically create fields for you (which won't work when you're using the old style schema.xml
).
This is defined in the solrconfig.xml
file, and should be removed:
<initParams path="/update/**">
<lst name="defaults">
<str name="update.chain">add-unknown-fields-to-the-schema</str>
</lst>
</initParams>
You shouldn't have to remove the chain itself, just the initParams for the update paths.
Upvotes: 1