I set up an ApacheSolr Node view with an argument "Apache Solr: Taxonomy terms".

It works, I can set a fixed value for example "1234". But I want to search by multiple terms, like "1234,1233,533" with OR.

THis doesn't work, I get a Status "404" syntax error in the watchdog.

What's going on?

CommentFileSizeAuthor
#3 920450-support_multiple.patch2.51 KBjrust

Comments

Anonymous’s picture

"400" Status: Bad Request
HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse 'tid:': Encountered "<EOF>" at line 1, column 4. Was expecting one of: "(" ... "*" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... "[" ... "{" ... <NUMBER> ...

type Status report

message org.apache.lucene.queryParser.ParseException: Cannot parse 'tid:': Encountered "<EOF>" at line 1, column 4. Was expecting one of: "(" ... "*" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... "[" ... "{" ... <NUMBER> ...

description The request sent by the client was syntactically incorrect (org.apache.lucene.queryParser.ParseException: Cannot parse 'tid:': Encountered "<EOF>" at line 1, column 4. Was expecting one of: "(" ... "*" ... <QUOTED> ... <TERM> ... <PREFIXTERM> ... <WILDTERM> ... "[" ... "{" ... <NUMBER> ... ).
Apache Tomcat/6.0.26
Anonymous’s picture

If I see what the output is of $this->params['fq'], I get this:

Array
(
    [0] => NOT type:webform
    [1] => NOT type:blog
    [2] => NOT type:feed_affiliate_csv
    [3] => NOT type:feed_affiliate_xml
    [4] => NOT type:feed_affilinet_csv
    [5] => NOT type:feed_cj_csv
    [6] => NOT type:feed_default_xml
    [7] => NOT type:feed_m4n_csv
    [8] => NOT type:feed_td_csv
    [9] => NOT type:feed_tt_csv
    [10] => NOT type:feed_wg_csv
    [11] => NOT type:icecat_master_feed
    [12] => NOT type:page
    [13] => tid:1577787
    [14] => tid:1577841
    [15] => tid:1672323
    [16] => tid:1781967
    [17] => language:en
    [18] => entity:node
)

The mistake is probably the duplicate tid:'s, you can only have 1?

EDIT:

I changed your function rebuild_fq to this:

  protected function rebuild_fq() {
    $query_filters = array();
    foreach ($this->_facets as $type => $facets) {
      $filter_string = '';
      foreach ($facets as $definition) {
        if ($definition['exclude']) {
          $type_string = "NOT $type";
        }
        else {
          $type_string = $type;
        }
        if ($type_string == 'tid') {
          $tids[] = $definition['value'];
        } else {
          $query_filters[] = "$type_string:" . $definition['value']; 
        }       
      }
    }
    if (is_array($tids)) {
      $query_filters[] = "tid:" . implode(' OR tid:', $tids);  
    }
    $query_filters[] = "entity:" . $this->sql_base_table;
    return $query_filters;
  }

Now the Tid'S are shown like

[13] => tid:1577787 OR tid:15777872 OR tid:1577787

And it works!

jrust’s picture

Title: No support for multiple taxonomy terms separated by , or + » Add support for arguments to be separated by either , or +
Status: Active » Needs review
StatusFileSize
new2.51 KB

Separating terms by commas (AND) is currently the only supported form of passing in multiple terms. The attached patch adds support for separating them by + (OR).

duynguyen’s picture

Status: Needs review » Active
kenorb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Version 6.x is no longer supported due to Drupal 6 End of Life. For Drupal 8.x, use Search API Solr Searchinstead.