Intersect thinking sphinx results

泪湿孤枕 提交于 2019-12-12 05:06:16

问题


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

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