我想从另一个模块添加特定模型的设置和映射。那可能吗?如果是,请帮助我如何做到这一点。我试过这个:
文章型号:
class Article < ActiveRecord::Base
include SearchArticle
end
新模块:
module SearchArticle
include Tire::Model::Search
settings :analyzer => {
:custom_analyzer => {
'tokenizer' => 'uax_url_email'
}
} do
mapping do
indexes :name, :boost => 10
indexes :email, :analyzer => 'custom_analyzer', :boost => 10
end
end
end
但是没有创建索引。我收到以下错误。
[2012-10-16 11:42:38,023][WARN ][cluster.metadata ] [Inza] [search_article] failed to create
org.elasticsearch.index.mapper.MapperParsingException: mapping [search_article]
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:262)
at org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:208)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.elasticsearch.index.mapper.MapperParsingException: Analyzer [custom_analyzer] not found for field [email]
at org.elasticsearch.index.mapper.core.TypeParsers.parseField(TypeParsers.java:76)
at org.elasticsearch.index.mapper.core.StringFieldMapper$TypeParser.parse(StringFieldMapper.java:124)
at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:261)
at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parse(ObjectMapper.java:217)
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:161)
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:364)
at org.elasticsearch.index.mapper.MapperService.add(MapperService.java:186)
at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService$1.execute(MetaDataCreateIndexService.java:259)
... 4 more