【问题标题】:Solr returned an error #400 (Bad Request) for urlSolr 为 url 返回错误 #400 (Bad Request)
【发布时间】:2017-09-02 17:13:36
【问题描述】:

我正在使用 Solr 6.5.0,我遇到了一个场景,我必须索引文档中可能有多种语言的数据字段。

我正在尝试为每种语言使用单独的字段,我必须将特定语言的数据索引到为该语言定义的相应字段。

我在下面添加了配置和架构更改:

Solr 配置:

  <requestHandler name="/update" class="solr.UpdateRequestHandler">
       <lst name="defaults">
         <str name="update.chain">langid</str>
       </lst>    
    </requestHandler>
    <updateRequestProcessorChain name="langid">
         <processor class="org.apache.solr.update.processor.TikaLanguageIdentifierUpdateProcessorFactory">
           <str name="langid.fl">title</str>
           <str name="langid.langField">lang</str>
           <str name="langid.fallback">en</str>
         </processor>
         <processor class="solr.LogUpdateProcessorFactory" />
         <processor class="solr.RunUpdateProcessorFactory" />
       </updateRequestProcessorChain>

架构:

<field name="code" type="string" indexed="true" stored="true"/>
    <field name="title" type="string" indexed="true" stored="true"/>
    <field name="content_english" type="text_english" indexed="true" stored="true"/>
    <field name="content_french" type="text_french" indexed="true" stored="true"/>
    <field name="content_spanish" type="text_spanish" indexed="true" stored="true"/>

输入xml:

<add>
<doc>
  <field name="code">one</field>
  <field name="title">Adventures</field>
  <field name="content_english">Especially the fuzzy search is very welcome; Solr really is a beautiful engine and it’s incredibly fast: millions of documents are no problem. Of course, if your servers capacities are configured correctly.</field>    
</doc>
<doc>
  <field name="code">two</field>
  <field name="title">Aventures</field>
  <field name="content_french">Surtout la recherche floue est très bienvenue; Solr est vraiment un beau moteur et c'est incroyablement rapide: des millions de documents ne posent aucun problème. Bien sûr, si les capacités de vos serveurs sont configurées correctement.</field>    
</doc>
<doc>
  <field name="code">three</field>
  <field name="title">Aventuras</field>
  <field name="content_spanish">Especialmente la búsqueda difusa es muy bienvenida; Solr realmente es un motor hermoso y es increíblemente rápido: millones de documentos no son ningún problema. Por supuesto, si las capacidades de los servidores están configuradas correctamente.</field>    
</doc>
</add>

每当我更新核心时,我都会收到以下错误:

C:\solr-6.5.0\example\exampledocs>java
-Durl=http://localhost:8983/solr/autodetect/update?update.chain=langid -jar post.jar multilanguage.xml SimplePostTool version 5.0.0 

将文件发布到 [base] url http://localhost:8983/solr/autodetect/update?update.chain=langid 使用 content-type application/xml... 将文件 multilanguage.xml 发布到 [base] SimplePostTool:警告:Solr 返回错误 #400(错误 请求)的网址: http://localhost:8983/solr/autodetect/update?update.chain=langid SimplePostTool:警告:响应:4006org.apache.solr.common.SolrExceptionorg.apache.solr.common.SolrExceptionDocument 缺少必需的 uniqueKey 字段:id400 SimplePostTool:警告: 读取响应时出现 IOException:java.io.IOException: Server 返回的 HTTP 响应代码:400 用于 URL: http://localhost:8983/solr/autodetect/update?update.chain=langid 1 索引的文件。提交 Solr 索引更改为 http://localhost:8983/solr/autodetect/update?update.chain=langid... 花费时间:0:00:00.179

【问题讨论】:

    标签: solr


    【解决方案1】:

    错误:您的文档中缺少 ID 字段。

    id 用于唯一标识每个文档,在如下架构文件中指定。

    <uniqueKey>id</uniqueKey>  
    

    每个文档都必须并且应该具有指定为唯一键的字段。

    包括所有文档的 ID 字段并检查。 例如:

    <doc>
      <field name="id">001</field>
      <field name="code">one</field>
      <field name="title">Adventures</field>
      <field name="content_english">Especially the fuzzy search is very welcome; Solr really is a beautiful engine and it’s incredibly fast: millions of documents are no problem. Of course, if your servers capacities are configured correctly.</field>    
    </doc>
    

    【讨论】:

      【解决方案2】:

      你看过错误了吗?您的文档没有名为“id”的必填字段的值。您要么必须给每个人一个 id:

      <add>
      <doc>
        <field name="code">one</field>
        <field name="id">1</field>
        <field name="title">Adventures</field>
        <field name="content_english">Especially the fuzzy search is very welcome; Solr really is a beautiful engine and it’s incredibly fast: millions of documents are no problem. Of course, if your servers capacities are configured correctly.</field>    
      </doc>
      <doc>
        <field name="code">two</field>
        <field name="id">2</field>
        <field name="title">Aventures</field>
        <field name="content_french">Surtout la recherche floue est très bienvenue; Solr est vraiment un beau moteur et c'est incroyablement rapide: des millions de documents ne posent aucun problème. Bien sûr, si les capacités de vos serveurs sont configurées correctement.</field>    
      </doc>
      <doc>
        <field name="code">three</field>
        <field name="id">3</field>
        <field name="title">Aventuras</field>
        <field name="content_spanish">Especialmente la búsqueda difusa es muy bienvenida; Solr realmente es un motor hermoso y es increíblemente rápido: millones de documentos no son ningún problema. Por supuesto, si las capacidades de los servidores están configuradas correctamente.</field>    
      </doc>
      </add>
      

      或者您可以将 Solr 配置为在不存在时自动分配一个值。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-24
        • 2010-12-13
        • 1970-01-01
        • 1970-01-01
        • 2017-10-28
        相关资源
        最近更新 更多