2017-04-07 100 views
1

我正在使用Solr 6.5.0,我遇到了一個場景,我必須爲文檔中可能包含多種語言的數據字段建立索引。Solr返回錯誤#400(錯誤請求)url

我想爲每種語言使用單獨的字段,我必須將特定語言的數據編入索引,以便爲該語言定義的相應字段編制索引。

我增加了以下配置和架構的變化:

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 

Posting files to [base] url http://localhost:8983/solr/autodetect/update?update.chain=langid using content-type application/xml... POSTing file multilanguage.xml to [base] SimplePostTool: WARNING: Solr returned an error #400 (Bad Request) for url: http://localhost:8983/solr/autodetect/update?update.chain=langid SimplePostTool: WARNING: Response: 4006org.apache.solr.common.SolrExceptionorg.apache.solr.common.SolrExceptionDocument is missing mandatory uniqueKey field: id400 SimplePostTool: WARNING: IOException while reading response: java.io.IOException: Server returned HTTP response code: 400 for URL: http://localhost:8983/solr/autodetect/update?update.chain=langid 1 files indexed. COMMITting Solr index changes to http://localhost:8983/solr/autodetect/update?update.chain=langid ... Time spent: 0:00:00.179

回答

0

那麼你看這個錯誤嗎?您的文件沒有名爲'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的自動分配一個值,如果一個不存在。

1

錯誤:您的文檔中缺少ID字段。

id這是用來識別每個文件唯一的是在模式文件中指定如下。

<uniqueKey>id</uniqueKey> 

每個文件都必須且應該有指定爲唯一鍵的字段。

包含所有文檔和檢查的Id字段。 ex:

<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> 
相關問題