It seems a negative query like /search/apachesolr_search/some_key?filters=-tid:20 doesn't work.

SolrQuerySyntax

Comments

vladimir.dolgopolov’s picture

Not sure is that a feature request or a bug report.
Though if negative queries is tested in tests then it's a bug report I think.

pwolanin’s picture

We are passing these fields in as filter queries - in contrast to previously as the q param. I think this will not work for the current query class because we look for field names like so:


    // Gets information about the fields already in solr index.
    $index_fields = $this->solr->getFields();

    $rows = array();
    foreach ((array) $index_fields as $name => $field) {
      do {
        // save the strlen so we can detect if it has changed at the bottom
        // of the do loop
        $a = (int)strlen($filters);
        // Get the values for $name
        $values = Solr_Base_Query::query_extract($filters, $name);

The $name will never have a leading - and hence will never be matched.

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new2.57 KB

we could correctly handle negative filters with something like the change attached.

pwolanin’s picture

Status: Needs review » Needs work
pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 KB
pwolanin’s picture

StatusFileSize
new3.06 KB

plus a start at handling these facets if they exist.

pwolanin’s picture

StatusFileSize
new3.58 KB

reroll for views patch

pwolanin’s picture

StatusFileSize
new8.22 KB

Further cleanup for facet code and date facet code.

pwolanin’s picture

Title: Pure negative queries don't work » Handle negative filters and improve date facet block code
Status: Needs review » Fixed

committed to 6.x

Status: Fixed » Closed (fixed)

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