While i coded the CiviCRM Solr module I noticed the search has no results if the Apache Solr Node Access module has been enabled. I tried to get the applied filters inside the hook_apachesolr_modify_query(), but the $query->get_filters() doesn't returns with the nodeaccess filters, as a plus, the $params doesn't contains the $params['fq'] array.

The reason is that, inside the apachesolr_modify_query() the $params['fq'] comes later than the invoke of the hook_apachesolr_modify_query() functions, and the $query->get_fq() processes the subqueries too, the $query->get_filters() and the $query->remove_filter() don't.

Comments

jpmckinney’s picture

Title: Not every filter could be reached via hook_apachesolr_modify_query() » Add get_subqueries()
Version: 6.x-2.x-dev » 7.x-1.x-dev
Category: bug » task
Status: Active » Needs review
StatusFileSize
new1007 bytes
new1003 bytes

I assume adding a get_subqueries() will solve this issue. A good idea to have it, in any case. Attaching 6.x-2.x patch, too.

pwolanin’s picture

So, in terms of 7.x at least, I think this problem is a good motivation to switch to using ?f[]= for filters, since that wold make it much easier to get rid of the bad/hacky subquery stuff.

Another reason also to look at the Solace code.

pwolanin’s picture

Looking through the code - I see the only reason the current subquery thing is useful, really, is for handling field aliases.

A quick fix would also be making the subqueries variable public.

jpmckinney’s picture

I think this fix is just as quick and is in line with how we currently handle instance variables.

jpmckinney’s picture

pwolanin’s picture

Status: Needs review » Needs work

Out of date with current code

jpmckinney’s picture

Status: Needs work » Needs review
StatusFileSize
new408 bytes
pwolanin’s picture

Do we need to add this to the interface?

fwiw - the interface probably needs some love more generally.

jpmckinney’s picture

StatusFileSize
new0 bytes

Added it to interface, and gave comments some love.

pwolanin’s picture

Status: Needs review » Needs work

0 byte patch, please re-post.

jpmckinney’s picture

Status: Needs work » Needs review
StatusFileSize
new14.48 KB
pwolanin’s picture

The last comment needs to be changed:

      The params for the search are taken from
 *   the public $query->params array.

is al ittle wrong now, the params come form method getSolrParams(), or more generally from the params stored in the query object (exactly how they are passed to Solr search(0 is an implementation detail, not part of the interface).

jpmckinney’s picture

StatusFileSize
new15.1 KB

Hadn't read that one carefully. Removed most of the words, as it had too many implementation details. Also changed docs for the solr() method.

jpmckinney’s picture

Status: Needs review » Fixed

Figure safe to commit as it was mostly changing comments.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.