Intersect thinking sphinx results

2019-09-02 08:56发布

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条回答
小情绪 Triste *
2楼-- · 2019-09-02 09:57

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?

查看更多
登录 后发表回答