1

I'm trying to use Thinking Sphinx with my Can Can solution for authorization.

I found this answer helpful Cancan Thinking Sphinx current_ability Questions, but was wondering if there might be a way to accomplish this with facets.

So I have projects, where there is a column called privacy which is a bool. If a project is private then there is an index for collaborator_ids, which is a list of all of the users that can view the project.

I was wondering if there is a way to form a query using facets to return all projects that are either public OR private and the user's id is in the collaborator_ids.


Another approach I'm considering is formulating an extended query in my controller to check for these fields. http://sphinxsearch.com/docs/current.html#extended-syntax

Community
  • 1
  • 1
Cyrus
  • 3,687
  • 5
  • 35
  • 67

1 Answers1

1

I have no idea how you would do it thinking sphinx, but in normal sphinx this should work..

$cl->setSelect("*,privacy+IF(IN($user_id,collaborator_ids),1,0) AS myint");
$cl->setFilter('myint',array(1,2));

Which effectily makes an 'OR' query.

As I say, cant help you write thatin in thinging-sphinx.

barryhunter
  • 20,886
  • 3
  • 30
  • 43