Is there a method to get ApacheSolr Views to work with http://drupal.org/project/apachesolr_attachments ?

i.e. For nodes with files attached, and Apachesolr Attachments (and Tika) installed, can ApacheSolr Views based searches generate hits based on attached file content?

Thanks as always! :-)

Comments

jax’s picture

Having the same issue. The normal apachesolr search seems to function but the exposed apachsolr search filter doesn't.

jax’s picture

In apachesolr_views_query.inc from the apachesolr_views module there is

   // Add in facets now
  $this->_params['fq'] = $this->rebuild_fq();

which adds fq=entity:node to the search query. If you comment that out it will work but I'm not sure if that's the best approach. Needs some more investigating.

jax’s picture

Even better; in rebuild_fq() comment out the line

    $query_filters[] = "entity:" . $this->sql_base_table;

That line limits the query to node entities. The file contents is stored in a "file" entity. I'm not sure why it adds that restriction by default.

Some references to make it easier to pick this up again.
http://wiki.apache.org/solr/CommonQueryParameters#fq
http://wiki.apache.org/solr/SolrQuerySyntax

kleinmp’s picture

Category: support » feature

I would like attachments to work on views as well. I'm changing this to feature request.

davidcalhoun’s picture

+1 for the feature request. I ran into this same problem and was originally trying to solve it a different way. I'd like to see attachments work on Views too. In the mean time, I commented out the line stated in comment #3 and it seems to be working for me. The only issue I'm facing is getting duplicate results sometimes. It appears one for the file and one for the node the file is attached to.

medieval111’s picture

Thanks! Works for me. Looks like it's because "Apache SOLR Node" is selected as a View type...

I changed:

    $query_filters[] = "entity:" . $this->sql_base_table;

to:

    if ($this->sql_base_table == "node") {
      $query_filters[] = "entity:node OR entity:file";
    }
    else {
      $query_filters[] = "entity:" . $this->sql_base_table;
    }

Alternative:

      $query_filters[] = "entity:" . $this->sql_base_table . " OR entity:file";
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.