因此,我有一个试图运行的简单查询
Tire.search('posts', :size => 15) do
query{ string '*'}
facet('keywords'){ terms :keywords, :global => true }
end.results.facets['keywords']['terms'].each_with_index{|x, i| puts "#{i} - #{x.inspect}" }
但是无论我做什么,它都会不断返回10个结果
虽然这正常工作
Tire.search('posts', :size => 15) do
query{ string '*' }
facet('keywords'){ terms :keywords }
end.results.each_with_index{|x, i| puts "#{x.title} - #{i}" } and false
我究竟做错了什么?
最佳答案
要控制返回的构面中的条目数,
您需要在构面定义中设置大小:
Tire.search('posts') do
query{ string '*' }
facet('keywords'){ terms :keywords, :size => 15 }
end.
results.facets['keywords']['terms'].each_with_index{|x, i| puts "#{i} - #{x.inspect}"}
size
的Tire.search
参数控制您要检索多少个结果。
关于elasticsearch - 无法在控制台中正确设置使用Tyre返回的构面数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13644165/