Reputation: 29
Hiee,
I am using solr to index some xml files. My xml file looks like:
<add>
<doc>
<field name="id">736</field>
<field name="title">President of China lunches with Brazilian President</field>
<field name="date">November 13, 2004</field>
<field name="content"> Data comes here </field>
<field name="location">Brazil</field>
<field name="coords">43.17614,-90.57341</field>
</doc>
</add>
My schema.xml has the following fields:
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="date" type="date" indexed="true" stored="true"/>
<field name="location" type="text_general" indexed="true" stored="true"/>
<field name="coords" type="location" indexed="true" stored="true"/>
<field name="content" type="text_general" indexed="false" stored="true" multiValued="true"/>
When I use POST to index the file I get the following error:
C:\Apache\solr-4.5.1\example\solr\collection1\data>java -jar post.jar 1.xml
SimplePostTool version 1.5
Posting files to base url http://localhost:8983/solr/update using content-type a
pplication/xml..
POSTing file 1.xml
SimplePostTool: WARNING: Solr returned an error #400 Bad Request
SimplePostTool: WARNING: IOException while reading response: java.io.IOException
: Server returned HTTP response code: 400 for URL: http://localhost:8983/solr/up
date
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/update..
Time spent: 0:00:00.034
What am I doing wrong?
Upvotes: 0
Views: 7868
Reputation: 29
Okey I checked the server side log and realized that the data field type date, dint support the format of date I provided, hence the error!
Upvotes: 2
Reputation: 2491
when you post to solr you need to specify the collection you are updating e.g. http://localhost:8983/solr/collection1/update
.
example:
java -Dauto -Durl="http://localhost:8983/solr/collection1/update" -jar post.jar ~/foo/bar/baz.csv
you also need an solr.xml (on the dir where the cores are) like this:
<?xml version="1.0" encoding="UTF-8"?>
<solr>
<cores adminPath="/admin/cores">
<core name = "collection1" instanceDir="collection1"/>
</cores>
<queryResultWindowSize>100</queryResultWindowSize>
</solr>
you can also have solrconfig.xml in the same directory with schema.xml like this:
<?xml version="1.0" encoding="UTF-8" ?>
<config>
<luceneMatchVersion>LUCENE_43</luceneMatchVersion>
<requestDispatcher handleSelect="false">
<httpCaching never304="true" />
</requestDispatcher>
<requestHandler name="/select" class="solr.SearchHandler" />
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
<requestHandler name="/admin" class="solr.admin.AdminHandlers" />
<requestHandler name="/analysis/field" class="solr.FieldAnalysisRequestHandler" startup="lazy" />
</config>
Upvotes: 3