2016-05-06 33 views
3

在LUCENE-5472中,如果術語太長,Lucene會更改爲出錯,而不僅僅是記錄消息。這個錯誤指出SOLR不接受令牌超過了32766如何處理SOLR中的「文檔包含至少一個巨大的術語」?

Caused by: java.lang.IllegalArgumentException: Document contains at least one immense term in field="text" (whose UTF8 encoding is longer than the max length 32766), all of which were skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense term is: '[10, 10, 70, 111, 117, 110, 100, 32, 116, 104, 105, 115, 32, 111, 110, 32, 116, 104, 101, 32, 119, 101, 98, 32, 104, 111, 112, 101, 32, 116]...', original message: bytes can be at most 32766 in length; got 43225 
    at org.apache.lucene.index.DefaultIndexingChain$PerField.invert(DefaultIndexingChain.java:671) 
    at org.apache.lucene.index.DefaultIndexingChain.processField(DefaultIndexingChain.java:344) 
    at org.apache.lucene.index.DefaultIndexingChain.processDocument(DefaultIndexingChain.java:300) 
    at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:234) 
    at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:450) 
    at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1475) 
    at org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:239) 
    at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:163) 
    ... 54 more 
Caused by: org.apache.lucene.util.BytesRefHash$MaxBytesLengthExceededException: bytes can be at most 32766 in length; got 43225 
    at org.apache.lucene.util.BytesRefHash.add(BytesRefHash.java:284) 

試圖解決這一問題時,我在架構中增加了兩個濾波器(大膽):

<field name="text" type="text_en_splitting" termPositions="true" termOffsets="true" termVectors="true" indexed="true" required="false" stored="true"/> 
<fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true"> 
<fieldType name="text_en_splitting" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true"> 
     <analyzer type="index"> 
     <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
     <!-- in this example, we will only use synonyms at query time 
     <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> 
     --> 
     <!-- Case insensitive stop word removal. 
     --> 
     <filter class="solr.StopFilterFactory" 
       ignoreCase="true" 
       words="lang/stopwords_en.txt" 
      /> 
     <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/> 
     <filter class="solr.LowerCaseFilterFactory"/> 
     <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> 
     <filter class="solr.PorterStemFilterFactory"/> 
**<filter class="solr.TruncateTokenFilterFactory" prefixLength="32700"/> 
<filter class="solr.LengthFilterFactory" min="2" max="32700" />** 
</analyzer> 
</fieldType> 

由於錯誤仍然是相同的(這使我認爲過濾器沒有正確設置,也許?) 重新啓動服務器是關鍵感謝Bashetti先生

問題是哪一個更好:LengthFilterFactoryTruncateTokenFilterFactory?假設一個字節是一個字符(因爲過濾器應該刪除'不尋常'字符?)是正確的嗎?) 謝謝!

+0

爲什麼你LengthFilterFactory因爲它要過濾掉這些標記*不*通過最大包長度爲分鐘。 –

+0

,因爲我想忽略或截斷大於SOLR允許的最大值的元素(或其他) – salvob

+1

更改後是否重新啓動solr服務器? –

回答

1

錯誤說"SOLR doesn't accept token larger than 32766"

的問題是,因爲你已經使用的字符串字段類型前面爲你現場文字和要更改的字段類型後得到目前,因爲你沒有重新啓動Solr的同樣的問題服務器發生變化後。

我不認爲有任何需要添加TruncateTokenFilterFactoryLengthFilterFactory

但是,這是留給你,你有什麼要求,你有。

+0

好..我在添加過濾器之前有同樣的問題,我加了那些試圖修復它.. 加,根據到[doc](https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.LengthFilterFactory),它聲明 「過濾掉那些令牌*不*具有包含長度的最小值到最大值」 這意味着它應該丟棄大於32700的值。對嗎? – salvob

+0

您是否在更改之前將字符串fieldType用於您的文本字段? –

+1

做一個重新啓動solr服務器,並嘗試重新索引數據... –

0

我有同樣的錯誤,同時加載從(http://jsonstudio.com/wp-content/uploads/2014/02/enron.zip)enron_email數據到Solr的-6.0.0使用bin /後工具

見下

摘錄......至少包含一個巨大字段= \「文本\」(其UTF8 編碼比最大長度32766長),所有這些都跳過了 。請糾正分析儀不要產生這些條款。第一個巨大術語的前綴是:'[78,97,110,99,121,32,83, ,104,101,101,100,32,60,110,97,110,99,121,95 ,115,104,101, 101,100,64,66,85,83,73,78] ...',原始消息:字節可以是最長32766長度的 ;可能文檔有一個 索引字符串字段(solr.StrField),它太大「,」code「:400}} SimplePostTool:警告:IOException在讀取響應時: java.io.IOException:服務器返回的HTTP響應代碼:400網址: http://localhost:8983/solr/enron_emails/update/json/docs ...

RCA 架構字段名 「文本」 使用字段類型的字符串被限制在32766。 爲了接受長度大於32766更大的數據/ CLOB的,字段類型必須改變到text_general

A)在獨立模式下

編輯文件$ SOLR_HOME /服務器/ Solr的/ core_name/conf目錄/託管模式,
我改變

<field name="text" type="strings"/><field name="text" type="text_general"/>

B)在Solrcloud模式(如託管架構文件將在嵌入式或自己的動物園管理員)

# check collections field "text" definition 
curl "http://localhost:8983/solr/enron_emails/schema/fields/text?wt=json&indent=true" 

# Modify collections field "text" definition 
curl -X POST -H 'Content-type:application/json' --data-binary '{ 
    "replace-field":{ 
    "name":"text", 
    "type":"text_general", 
    "stored":false } }' "http://localhost:8983/solr/enron_emails/schema?wt=json&indent=true" 

# Verify collections field "text" new definition 
curl "http://localhost:8983/solr/enron_emails/schema/fields/text?wt=json&indent=true" 
相關問題