如何设置轮胎弹性搜索的默认分析器?

我最近一直在尝试使用ruby on rails。 我无法将数据编入索引,因此我可以搜索包含复数和非复数关键字的项目。

轮胎将允许我为每个映射属性分配一个分析器:

mapping do indexes title, analyzer: 'snowball' indexes body, analyzer: 'snowball' end 

现在,假设我在“测试”标题中有一个关键字

如果我使用查询中的属性进行搜索: http:// localhost:9200 / myindex / mymapping / _search?q = title:test它将起作用。

但是,如果我在没有指定属性的情况下进行常规搜索,则:
HTTP://本地主机:9200 / myindex / mymapping / _search Q =测试

它找不到该文件。

如何指定我希望默认分析器为“雪球”,因此我不必指定要搜索的属性?

ps我正在使用轮胎gem。 所以请尽可能地回答这个问题。

可以使用索引设置更改默认分析器:

 require 'rubygems' require 'tire' Tire.index 'articles' do delete create :settings => { :index => { :analysis => { :analyzer => { :default => { :type => 'snowball' } } } } }, :mappings => { :article => { :properties => { :title => { :type => 'string', :analyzer => 'snowball'}, :body => { :type => 'string', :analyzer => 'snowball'} } } } store :title => 'Tests', :body => "Plural" store :title => 'Test', :body => "Singular" refresh end 

最简单的方法是在elasticsearch.yml设置文件中设置它:

 index.number_of_shards: 2 index.number_of_replicas: 0 index.analysis.analyzer.default.type: snowball