使用post.jar进行索引时出现Solr错误

时间:2013-11-19 08:23:43

标签: xml solr indexing schema ioexception

Hiee,

我使用solr索引一些xml文件。 我的xml文件如下所示:

<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>

我的schema.xml包含以下字段:

<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"/>

当我使用POST索引文件时,我收到以下错误:

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

我做错了什么?

2 个答案:

答案 0 :(得分:3)

当您发布到solr时,您需要指定要更新的集合,例如http://localhost:8983/solr/collection1/update

例如: java -Dauto -Durl="http://localhost:8983/solr/collection1/update" -jar post.jar ~/foo/bar/baz.csv

你还需要一个solr.xml(在核心所在的目录上),如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<solr> 
    <cores adminPath="/admin/cores">
        <core name = "collection1" instanceDir="collection1"/>
    </cores>

    <queryResultWindowSize>100</queryResultWindowSize>
</solr>

你也可以在与schema.xml相同的目录中使用solrconfig.xml,如下所示:

<?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>

答案 1 :(得分:2)

Okey我检查了服务器端日志并意识到数据字段类型为date,dint支持我提供的日期格式,因此出错!