问题
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