问题
Is it possible to intersect two ThinkingSphinx results?
For example, I have the results of two queries with the same object types: result_1 = [A1, A2]
and result_2 = [A2, A3]
. How can I get the intersection result_1 & result_2 (which should be [A2]), as I can with regular ruby arrays?
I'm using Thinking Sphinx version 3.0.6.
Thanks.
回答1:
If you want to combine the raw arrays from two searches, you can do this using the to_a
method:
result_1.to_a & result_2.to_a
The catch here, though, is you lose all pagination information, and the ordering of results may not be ideal. Is there a reason why you can't run a single query that gets the combined results?
来源:https://stackoverflow.com/questions/30305981/intersect-thinking-sphinx-results