开发者

Sphinx Search: excluding index B results from index A results

开发者 https://www.devze.com 2023-04-12 02:18 出处:网络
Here\'s my issue: I have 2 indexes: A - product titles only B 开发者_运维问答- product titles and product descriptions

Here's my issue:

I have 2 indexes:

A - product titles only B 开发者_运维问答- product titles and product descriptions

By default I search index A to categorize products (e.g. most bikes have "bike" in title). Sometimes there instances where to determine category (which might be a sub-category of something) we need to look at description, mostly to exclude irrelevant results. In order for pagination on search result page to work, I need to get this clean result as one array after running RunQueries().

But it does not work. It basically adds results of both queries, and looks like there's no way to subtract results. Anyone has any ideas?


Tell me if I'm completely missing something but it sounds to me like your trying to include results with product titles that match a certain query and exclude results with a description that matches another query?

If this is the case it seems to me that having 2 indexes is useless, and you can have one index with both product titles and descriptions and then run a full text search query as such:

@title queryA @description -queryB

You can use the same query to search for matches that have a title of queryA AND a description of queryB by simply removing the - symbol.

If this is off base the only other way I could think of doing it is using SphinxQL (I'm not well versed in any of the libraries since support for all the libraries which don't use SphinxQL is being phased out in the future as far as I've read)

Using SphinxQL you could run 2 queries, one which is like

SELECT id FROM indexB WHERE MATCH('@description queryB')

And then run a second query using a the list of ids you got from the first query as such

SELECT id FROM indexA WHERE id NOT IN(id1,id2,id3,...)
0

精彩评论

暂无评论...
验证码 换一张
取 消