Sunspot two fulltext queries on two fields

China☆狼群 提交于 2019-12-11 06:28:39

问题


I need to do something like the following, which is meant to issue two different queries on two fields.

Video.search do
   fulltext weighting_factors, {:fields => :categories_as_string}
   fulltext prefs, {:fields => :similar_as_string}
end 

Currently I force the two fields to include tokens that have separate namespaces and combine the query to apply to both fields. I think this is equivalent since prefs will never match something in categories_as_string but it's a pain to maintain. Is there a way to do the query above instead?

query = prefs + weighting_factors
search = Video.search do
  fulltext query do
    fields :similar_as_string, :categories_as_string
  end
end

来源:https://stackoverflow.com/questions/21124787/sunspot-two-fulltext-queries-on-two-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!