2012-07-16 69 views
1

目前,我正在評估是否以及如何將遺留的基於lucene的分析器組件移至彈性搜索(0.19.18)。由於遺留代碼基於lucene,因此我將分析器封裝在es-plugin中。分析儀的配置如下所示:ElasticSearch:配置自定義分析器實現

index.analysis.analyzer.myAnalyzer.type : myAnalyzer 
index.analysis.analyzer.default.type: myAnalyzer 
index.analysis.analyzer.default_index.type: myAnalyzer 
index.analysis.analyzer.default_search.type: myAnalyzer 

到目前爲止好。

curl -XGET 'localhost:9200/_analyze' -d 'Some text' 

都將返回一個包含正確標記化的文本對象,但

curl -XGET 'localhost:9200/<name-of-my-index>/_analyze' -d 'Some text' 

將返回一個文本,是不是所有的標記化。顯然,我的分析器不是隻應用小寫字母過濾器。索引中的對象沒有正確分析。

指數映射是這樣的(從頭部插件輸出):

mappings: { 
item: { 
    analyzer: myAnalyzer 
    properties: { 
     id: { 
      type: string 
     } 
     itemnumber: { 
      type: string 
     } 
     articletext: { 
      analyzer: myAnalyzer 
      type: string 
     } 
     sortvalue: { 
      type: string 
     } 
     salesstatus: { 
      format: dateOptionalTime 
      type: date 
     } 
    } 
} 
} 

由於我是新來的ES,我想不通,什麼這種現象的原因究竟是什麼。有人有想法嗎?

+0

當你運行'curl -XGET'localhost:9200/<我的索引名稱>/_ settings''時,你會得到什麼? – imotov 2012-07-16 18:46:00

+0

'{「myIndex」:{「settings」:{「index.version.created」:「190899」,「index.number_of_replicas」:「0」,「index.number_of_shards」:「1」}}}' – GLA 2012-07-17 07:49:45

+0

有可能在某處發佈repro? – imotov 2012-07-18 16:27:03

回答

2

這是我如何在Elasticsearch中設置一個自定義默認分析器。

index: 
    analysis: 
    analyzer: 
     default: 
     filter: [lowercase] 
     tokenizer: whitespace 
     type: custom 

工程就像一個魅力。

+0

我偶然發現了您的答案,試圖在「type」中使用自定義的已定義分析器,例如「法國2」和「自定義」做成了!謝謝。 – maxbeaudoin 2014-11-17 20:10:02

+0

只是爲了強調,關鍵是要使用'默認'作爲自定義分析儀的名稱。 – vim 2015-12-15 06:58:35

相關問題