bundle_searches and facets

13 views
Skip to first unread message

rbjarnason

unread,
Oct 8, 2010, 12:41:07 PM10/8/10
to Thinking Sphinx
Hi,

Doesn't look that .facets work with bundle_searches and I understand
that this was created internally for facets. I do however need this
feature to enable some quite complex access control logic which will
be easy to implement if I can run two searches with different
parameters on the same fields.

I'm using the latest plugin install version. Just to be sure, should
facets work with bundles searches? Are there any plans to enable
facets with bundles_searches? If not I will take a stab at making it
work and any pointers to help me with the implementation would be
appreciated.

Best regards,
Robert

rbjarnason

unread,
Oct 8, 2010, 7:09:29 PM10/8/10
to Thinking Sphinx
I guess I could call facets twice with the two different bundle_search
queries and then "merge" the results in a way I would add missing
facet results from the first search from the second search. This
would create almost the correct behavior except that counts would be
wrong in some cases... Then instead of using facet.for I would just
add the facet drill-down parameter to the main search hash. I know
its a bit of a hack but if I could find a way to get the counts rights
for the two facet calls at least it would work.

Will look into this more but if anybody has a better idea to solve
this quickly let me know.

Best regards,
Robert

rbjarnason

unread,
Oct 9, 2010, 1:28:35 PM10/9/10
to Thinking Sphinx
Actually when testing this I realize I have misunderstood the behavior
of bundle_search.

I was hoping to be able to run two queries and get one set of results
back with the combined hits.

I need to be able to do a search with filters like those:
:with=>{search_access_tag=>access_tags_from_first_user}
AND
:with=>{search_access_tag=>access_tags_from_anon_user,
"geoblock_disabled_for_#{@country_code.downcase}"=>true}

So in the first case I get an array of access tags from the logged in
user and in the second case I get an array of access tags from an
anonymous user if the geo_blocking is disabled for that document for a
given country.

Any ideas how I could implement this in a single query? Or if I can
somehow merge the result sets from two queries while still making
pagination and facets work.

Best regards,
Robert

rbjarnason

unread,
Oct 9, 2010, 1:34:03 PM10/9/10
to Thinking Sphinx
Sorry that should be:;
:with=>{search_access_tag=>access_tags_from_first_user}
OR
:with=>{search_access_tag=>access_tags_from_anon_user,
"geoblock_disabled_for_#{@country_code.downcase}"=>true}

rbjarnason

unread,
Oct 10, 2010, 10:08:08 AM10/10/10
to Thinking Sphinx
Ok, managed to sort it out by using the search query field and
indexing those attributes.

Here is the basic solution:
"#{params[:search]} & ((@search_access_tag
#{(@search_access_tags).collect {|t| t.to_s}.join(' | ')}) |
(@geoblock_disabled_for_#{@country_code} 1 & @search_access_tag
#{(@anon_search_access_tags << 0).collect {|t| t.to_s}.join(' | ')}))"

Best regards,
Robert
Reply all
Reply to author
Forward
0 new messages