2011-03-21 66 views
2

我正在尋找使用Elasticsearch來提供我們網站的搜索功能。ElasticSearch和Porterstem分析器

我一直在試驗它,但無法啓用porterstem分析器(以便搜索戰鬥匹配戰鬥和戰鬥)。

下面是我輸入的一個縮減。

curl -XPUT localhost:9200/local/ -d' 
index :      
    analysis : 
     analyzer : 
      stemming : 
       type : custom 
       tokenizer : standard 
       filter : [standard, lowercase, stop, porterStem] 
' 

curl -XPUT localhost:9200/local/_mapping -d'{"properties": { "title" : { "analyzer" : "stemming", "type" : "string" }}}' 

curl -XPUT localhost:9200/local/article/1 -d'{"title": "Fight for your life"}' 
curl -XPUT localhost:9200/local/article/2 -d'{"title": "Fighting for your life"}' 
curl -XPUT localhost:9200/local/article/3 -d'{"title": "My dad fought a dog"}' 
curl -XPUT localhost:9200/local/article/4 -d'{"title": "Bruno fights Tyson tomorrow"}' 

但是,運行搜索「戰鬥」只匹配第一個條目 - 包含確切名詞的條目。

curl -XGET localhost:9200/local/_search?q=fight 

正確的設置似乎已設置,但似乎不起作用。

"indices" : { 
    "local" : { 
     "aliases" : [ ], 
     "settings" : { 
     "index.analysis.analyzer.stemming.type" : "custom", 
     "index.analysis.analyzer.stemming.tokenizer" : "standard", 
     "index.analysis.analyzer.stemming.filter.1" : "lowercase", 
     "index.analysis.analyzer.stemming.filter.0" : "standard", 
     "index.analysis.analyzer.stemming.filter.3" : "porterStem", 
     "index.analysis.analyzer.stemming.filter.2" : "stop", 
     "index.number_of_shards" : "5", 
     "index.number_of_replicas" : "1" 
     }, 

任何人都有這個功能啓動和運行,並能指向我在正確的方向嗎?

回答