首页 文章

Solr为url返回错误#400(错误请求)

提问于
浏览
1

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

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

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

Solr config:

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

schema:

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

Input 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

使用content-type application / xml将文件发布到[base] url http:// localhost:8983 / solr / autodetect / update?update.chain = langid ...将文件multilanguage.xml发布到[base] SimplePostTool:警告: Solr为url返回错误#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:服务器返回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

2 回答

  • 0

    错误:文档中缺少ID字段 .

    用于唯一标识每个文档的 id 在模式文件中指定,如下所示 .

    <uniqueKey>id</uniqueKey>
    

    每个文档必须且应该具有指定为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>
    
  • 1

    那你看错了吗?您的文档没有名为“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配置为在不存在值时自动分配值 .

相关问题