我正在与ElasticSearch插件一起使用Grails。它工作正常,但我需要定义设置和分析器。
我怎么能这么做?
我想使用以下设置和映射:
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"autocomplete" : "engram",
"filter" : ["lowercase"]
}
},
"tokenizer" : {
"engram" : {
"type" : "edgeNgram",
"min_gram" : 3,
"max_gram" : 10
}
}
}
}
},
"mappings" : {
"contacts" : {
"name" : {
"index" : "string",
"index_analyzer" : "autocomplete",
"index" : "analyzed", "search_analyzer" : "standard"
},
"country" : { "type" : "string" }
}
}
}
}发布于 2013-08-13 12:14:28
正如dmahaptro所建议的那样,使用Elasticsearch的Rest可以工作。在“映射”标题下的http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index/中,您可以将以下内容复制并粘贴到shell中:
curl -XPOST localhost:9200/index_name -d '{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"autocomplete" : "engram",
"filter" : ["lowercase"]
}
},
"tokenizer" : {
"engram" : {
"type" : "edgeNgram",
"min_gram" : 3,
"max_gram" : 10
}
}
}
}
},
"mappings" : {
"contacts" : {
"name" : {
"index" : "string",
"index_analyzer" : "autocomplete",
"index" : "analyzed", "search_analyzer" : "standard"
},
"country" : { "type" : "string" }
}
}
}
}'检查索引是否使用正确设置创建的一种方法是使用head plugin:https://github.com/mobz/elasticsearch-head。打开浏览器中的头插件,单击“集群状态”选项卡,查看所有索引及其设置、映射等。
https://stackoverflow.com/questions/18188370
复制相似问题