0

I'm building a website with the panopoly distribution in Drupal 7. One of the client requests is a faceted search page combined with a search box to search on specific keywords and the possibility to sort on date and name.

To build this I used the following modules:

  • apachesolr
  • apachesolr_sorts
  • apachesolr_panels

After configuring everything I got this search page working (without clean url's)

http://i.imgur.com/mxDzhi4.png

solution with no clean url's

To enable clean url's I used the following module:

  • facetapi_pretty_paths

Now the search box always uses the first argument in the url, after I enable the pretty paths module the first argument in the url is the active filter (taxonomy field name in combination with the taxonomy term name).

http://i.imgur.com/5x7Xyoa.png

solution with clean url's

What would be the best approach to use the search box in combination with the facets and pretty paths (and the sorting option)?

1

There are two ways to avoid this issue which depend on module what you use.

1) If Search API module is used. (It was taken from https://www.drupal.org/node/2625298)

function hook_search_api_query_alter(SearchApiQueryInterface $query) {
    $original_keys = $query->getOriginalKeys();
    if ($original_keys == 'field_facet_filter')) {
        $query->keys(NULL);
    }
}

2) If Apache Solr Search module is use

function hook_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {
  ‌‌if ($query->getParam('q') == 'field_facet_filter') {
    $query->removeParam('q');
  }
}
0

if you use search_api, the search term is put into a get parameter rather than as a path argument. this fixes the problem.

i would believe though, that people have also found a solution for the apachesolr module suite.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.