【问题标题】:Solr error while indexing using post.jar使用 post.jar 进行索引时出现 Solr 错误
【发布时间】:2013-12-02 16:58:17
【问题描述】:

嘿嘿,

我正在使用 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

我做错了什么?

【问题讨论】:

    标签: xml solr indexing schema ioexception


    【解决方案1】:

    当您发布到 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>
    

    您也可以将 solrconfig.xml 与 schema.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>
    

    【讨论】:

      【解决方案2】:

      Okey我查看了服务器端的日志,发现数据字段类型是date,dint支持我提供的日期格式,所以报错!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-26
        • 1970-01-01
        • 2018-08-27
        • 2012-11-17
        • 1970-01-01
        • 2021-12-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多