2015-11-17 22 views
2

索引我的數據時出現此錯誤。經過一番研究,我發現爲什麼發生這種情況,並且增加了max_token_length所以我這樣做,但我仍然得到的TokenStream expanded to 912 finite strings. Only <= 256 finite strings are supportedIllegalArgumentException - 僅支持<= 256個有限字符串

這裏同樣的錯誤是我的分析儀設置:

"settings": { 
    "index": { 
     "analysis": { 
      "analyzer": { 
       "shingle_analyzer": { 
        "tokenizer": "standard", 
        "max_token_length": 920, 
        "filter": ["lowercase", "shingle_filter", "asciifolding"], 
        "char_filter": ["html_strip"], 
        "type": "custom" 
       }, 
       "html_analyzer": { 
        "tokenizer": "standard", 
        "max_token_length": 920, 
        "filter": ["lowercase", "asciifolding"], 
        "char_filter": ["html_strip"], 
        "type": "custom" 
       } 
      }, 
      "tokenizer": { 
       "standard": { 
        "type": "standard" 
       } 
      }, 
      "filter": { 
       "shingle_filter": { 
        "min_shingle_size": 2, 
        "max_shingle_size": 5, 
        "type": "shingle" 
       } 
      } 
     } 
    } 
} 

這裏的我想要一個例子來插入:

POST /my_index/my_type/{id} 
{ 
    "myField":{ 
     "input":"Abcdefghij kl Mnopqrstwx yz Abcdef g Hijklmno pq Rstwxy Zabc (DEF)", 
     "weight":2, 
     "payload":{ 
      "iD":"2786129" 
     } 
    } 
} 

下面是my_type屬性映射

"Suggestion": { 
    "properties": { 
     "id": { 
      "index": "not_analyzed", 
      "type": "integer" 
     }, 
     "myField": { 
      "type": "completion", 
      "analyzer": "shingle_analyzer", 
      "search_analyzer": "shingle_analyzer", 
      "max_input_length": 150, 
      "payloads": true 
     } 
    } 
} 

我錯過了什麼?

我將不勝感激任何幫助或線索來解決這個問題,謝謝!

編輯: 更正analyzer封閉失蹤

+0

請注意,您缺少並在您的索引設置中包含''分析器':{...}'部件來包裹您的自定義分析器。查看[自定義分析器的結構](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-custom-analyzer.html),'analyzer','tokenizer'和'filter'進入「分析」結構。 – Val

+0

噢,我很抱歉,我寫了一個錯誤,實際上我把它們都放在'analyzer'設置中 –

回答

0

好了,前幾天我一個解決方案來到身邊。我只是從分析儀中的設置中刪除max_token_length屬性,並將max_input_length從我的領域的映射中減少,這似乎解決了我的問題,但我實在不確定爲什麼會發生這種情況,爲什麼這會解決它。如果有人有想法,請隨時分享您的知識:)

+0

這個木瓦分析器對建議結果有什麼影響嗎?據我瞭解由於完成建議對整個短語起作用,木瓦分析器不應該影響返回的結果。另外你爲什麼設置了'max_input_length'? – keety

+0

當處理重音符時,它會有所不同,當我調用沒有重音的數據查詢時,只有完成類型的字段不起作用,但是當我添加shingle_analyzer時,它確實表明重音是否存在。我只是把'max_input_length'降到了25,這個辦法解決了這個問題。 –

+0

我懷疑口音修復是由於asciifolding過濾器而不是'shingle-filter'。如果您從分析儀中移除'shingle-filter',則不應該有256問題 – keety