我已将相关字段映射为多字段.我已经设置了'名称'属性,使用雪球分析仪进行分析,并将'精确'设置为未分析.我可以在这个字段上搜索并过滤.我无法对这个领域进行排序.尝试排序时,弹性返回错误"无法对每个文档具有多个值的字符串类型进行排序,或者每个字段使用多个标记".
我试图创建一个名为'raw'的附加字段,类似于exact,这也不起作用.下面是我的映射以及我如何尝试通过轮胎gem进行排序:
mapping do
indexes :sectors, :type => 'object',
:properties => { :name => { :type => 'multi_field',
:fields => {
:name => { :type => 'string', :analyzer => 'snowball' },
:exact => { :type => 'string', :index => 'not_analyzed' , :include_in_all => false }
}
}
}
end
def to_indexed_json
to_json( :include => {
...
:sectors => { :only => ["name"] },
...
})
end
def self.search(params)
tire.search(:load => true, :page=>params[:page], :per_page => 12) do
if params[:query].present?
query { …Run Code Online (Sandbox Code Playgroud)