Contextual filters do not get added to the query.

apachesolr_views_query->build() does not include the filters created by apachesolr_views_handler_argument.

Code such as

if (isset($this->params['filters'])) {
  $params['fq'] = $this->params['filters'];
}

adds them but that will interfere with

if (!empty($conditions_string)) {
    $params['fq'] = $conditions_string;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

theapi’s picture

FileSize
598 bytes

I've attached a patch to use the arguments set by apachesolr_views_handler_argument.

It want have an effect if $conditions_string is set.

sylus’s picture

Patch works great thanks @PeterC, Contextual arguments with Apache Solr + Views FTW!

f16viper’s picture

Patch works fine - it made my day to finally have conditional filters working again - thanks heaps

mindbat’s picture

Patch didn't work for me on version 7.x-1.0-beta1.

Contextual filters seem to be ignored altogether in the Apache Solr-based view.

heacu’s picture

hi,

i just tried this patch with version 7.x-1.0-beta2, and it worked for me.

ed

rjbrown99’s picture

Status: Active » Needs review

Patch here, changing status.

roynilanjan’s picture

Patch works fine ... is there any possibility to use Equivalent of "OR"(of a sql)
basically filter array consists all the arguments it behaves like "AND"(of a sql)

Please let me know

roynilanjan’s picture

there is still need some work with this patch although it works only for contextual filter but with Filter criteria & contextual filter together will not work (although it's default function of view) .. this patch can solve the issue.

Please have a test & let me know

babruix’s picture

Status: Needs review » Reviewed & tested by the community

Yes, last patch works as well, checked against 7.x-1.0-beta2.
Thanks!

DrDam’s picture

Yes, last patch works as well, checked against 7.x-1.0-beta2.
Thanks!

Marc Angles’s picture

#8 appply and works on 7.x-1.0-beta2

acidpotato’s picture

Priority: Normal » Major

#8 works for me as well. Can this be added to 7.x.1.x-Dev?

itamar’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.06 KB

The patch from #8 might cause a notice when params['filters'] is not set. Here's a re-roll with a slight cleanup.

TechNikh’s picture

Status: Needs review » Reviewed & tested by the community

#13 applies and works well.

TechNikh’s picture

If there are more than one view in a single page, use https://drupal.org/node/1766254#comment-7721963

MiroslavBanov’s picture

Issue summary: View changes

Confirm that #13 works fine for me.

MiroslavBanov’s picture

Status: Reviewed & tested by the community » Needs work

On second thought, I don't like how the contextual filters are using a separate add_filter function. They should be using add_where, same as regular filters. This is how database views work, too.

MiroslavBanov’s picture

Status: Needs work » Needs review
FileSize
1.66 KB

Here's a new patch as per #17

  • MiroslavBanov committed 0505c30 on 7.x-1.x
    Issue #1750952 by theapi: Argument handlers not working.
    
MiroslavBanov’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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