Search code examples
javasphinxthinking-sphinxfaceted-search

sphinx facet search: 'with_all' analogue for php/java


I have a doc set with MVA and i need to filer docs that have all required attrs (let's say, i need all 'news' doc having both 'java' and 'oracle' tags, assume i have tags ids).

at ThinkingSphinx (http://pat.github.com/ts/en/searching.html#filters) i found a usefull notaion:

For matching multiple values in a multi-value attribute, :with doesn’t quite do what you want. Give :with_all a try instead:

Article.search 'pancakes',   :with_all => {:tag_ids => @tags.collect(&:id)}

that, as far as i guess, allows to filter docs having ALL the provided attributes, instead of getting docs, having ANY of provided attr list for SetFilterRange usage.

Can anyone suggest soluion at least in terms of standard PHP interface? hope i'll be able to transform it to java.


Solution

  • Multiple calls to setFilter are ANDed. Where as you note specifing multiple ids to one call are ORed.

    $cl->setFilter('tag_ids',array($tag_id1));
    $cl->setFilter('tag_ids',array($tag_id2));
    $cl->setFilter('tag_ids',array($tag_id3));
    

    Sorry cant help with the java syntax.