Search code examples
solrdrupal-7

Solr search in multiple fields in drupal 7


Now apachesolr search works only in content. It also have to work on other fields for eg: on typing "test", It searches only in content.

My requirement is to search on description,label also (which i have already indexed). content:abcd OR description:sample_upload_document

I tried by using apachesolr_query_prepare($query)

function filedepot_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {

     $query->addParam('qf','content description');
     watchdog('solr result',print_r($query,true));

}

refering to the sitehttp://knackforge.com/blog/selvam/drupal-7-filtering-solr-results.
After performing that, i found description is added to

SolrBaseQuery Object
    (
        [params:protected] => Array
            (
                 [qf] => Array
                    (
                        [0] => content^40
                        [1] => description
                    )

But still when i give the value for description, search results would not yield any value.

Am i correct in a way? why doesnt it return the result?

How to do that? default search,searches the given text only in content.How to make it to search on other fields like description,label?


Solution

  • Check which parser it is using. If it is using standarad query parser, then qf parameter wont work. The qf parameter works in DisMax Parser.