开发者

Sphinx search filter to handle arrays

开发者 https://www.devze.com 2022-12-21 19:23 出处:网络
I have a database of objects which have each been assigned to multiple categories. I am using sphinx search to search the products but w开发者_如何转开发ould also like to filter the results to only ob

I have a database of objects which have each been assigned to multiple categories. I am using sphinx search to search the products but w开发者_如何转开发ould also like to filter the results to only objects that match an array of categories.


You may use SetFilter exclude option to solve this.

For example you have following category IDs:1,2,3,4,5 and you need to search in 1 or 3 category.

$sphinx->SetFilter("category_id", (2,4,5), true);

code above will exclude from search categories 2,4 and 5, so in our case search will perform only in category 1 and 3.

0

精彩评论

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