2013-08-18 49 views
3
curl -XPUT "localhost:9200/products" -d '{ 
    "settings": { 
     "index": { 
      "number_of_replicas" : 0, 
      "number_of_shards": 1 
     } 
    }, 
    "mappings": { 
     "products": { 
      "properties": { 
       "location" : { 
        "type" : "geo_point" 
       } 
      } 
     } 
    } 
}' 

我目前有一個bash腳本來創建我的索引。代碼在上面。如何在Elasticsearch中啓用詞幹?

如何添加詞幹?

回答

6

最通用的方法是用snowball分析儀代替default分析儀。這將啓用所有動態映射的字符串字段的詞幹。這是如何啓用英文詞幹程序:

curl -XPUT "localhost:9200/products" -d '{ 
    "settings": { 
     "index": { 
      "number_of_replicas" : 0, 
      "number_of_shards": 1, 
      "analysis" :{ 
       "analyzer": { 
        "default": { 
         "type" : "snowball", 
         "language" : "English" 
        } 
       } 
      } 
     } 
    }, 
    "mappings": { 
     "products": { 
      "properties": { 
       "location" : { 
        "type" : "geo_point" 
       } 
      } 
     } 
    } 
}' 
+2

怎麼了映射?這與它有什麼關係? –