Skip to main content
added 621 characters in body
Source Link
Pontus Nilsson
  • 3.4k
  • 14
  • 22

I usually use Search API and Search API Solr. And for setting up the site layout I use Panels and Panels everywhere, so my answer will be using those modules. I'm not that familiar with Apache Solr Search but maybe it's doable with that module also. It would be interesting to hear other solutions :)

The fields you want to filter by could be built using Facet API. One thing that's pretty awesome is that the facets are shown depending on the search result. So the facet will only show filters that have results.

The tricky bit is that a facet can only be shown (as far as I know) by a query that has been run. To do this I would create a Search API view that uses you Search API index. Setup a views content pane that shows your search result. Then create a display of the type context in Views.

In your site template (setup using Panels everywhere) Insert the view by adding a pane and look under the "View context" category onwhere you want the leftsearch result to be shown. InsertAdd your views context as a context to the entire viewpanel under Contexts. Then add your facets to the region you want them to show.

Then you probably want some caching on the views context so that it doesn't fire off a query on each page load :)

Another approach as you mention would be building a custom form and redirect the user to the search page /search?q=filter or to the search page and "prefill" the facet on the search page with the filter value (ie /search?facet-argument=X).

The options in the filter list could be fetched with an entity field query so that you fetch all values for the field you want to filter by. Then cache the result of that for X min/hours so that it doesn't load your site.

I usually use Search API and Search API Solr. And for setting up the site layout I use Panels and Panels everywhere, so my answer will be using those modules. I'm not that familiar with Apache Solr Search but maybe it's doable with that module also. It would be interesting to hear other solutions :)

The fields you want to filter by could be built using Facet API. One thing that's pretty awesome is that the facets are shown depending on the search result. So the facet will only show filters that have results.

The tricky bit is that a facet can only be shown (as far as I know) by a query that has been run. To do this I would create a Search API view that uses you Search API index. Setup a views content pane that shows your search result. Then create a display of the type context in Views.

In your site template (setup using Panels everywhere) Insert the view by adding a pane and look under the "View context" category on the left. Insert the entire view. Then add your facets to the region you want them to show.

I usually use Search API and Search API Solr. And for setting up the site layout I use Panels and Panels everywhere, so my answer will be using those modules. I'm not that familiar with Apache Solr Search but maybe it's doable with that module also. It would be interesting to hear other solutions :)

The fields you want to filter by could be built using Facet API. One thing that's pretty awesome is that the facets are shown depending on the search result. So the facet will only show filters that have results.

The tricky bit is that a facet can only be shown (as far as I know) by a query that has been run. To do this I would create a Search API view that uses you Search API index. Setup a views content pane that shows your search result. Then create a display of the type context in Views.

In your site template (setup using Panels everywhere) Insert the view by adding a pane where you want the search result to be shown. Add your views context as a context to the panel under Contexts. Then add your facets to the region you want them to show.

Then you probably want some caching on the views context so that it doesn't fire off a query on each page load :)

Another approach as you mention would be building a custom form and redirect the user to the search page /search?q=filter or to the search page and "prefill" the facet on the search page with the filter value (ie /search?facet-argument=X).

The options in the filter list could be fetched with an entity field query so that you fetch all values for the field you want to filter by. Then cache the result of that for X min/hours so that it doesn't load your site.

Source Link
Pontus Nilsson
  • 3.4k
  • 14
  • 22

I usually use Search API and Search API Solr. And for setting up the site layout I use Panels and Panels everywhere, so my answer will be using those modules. I'm not that familiar with Apache Solr Search but maybe it's doable with that module also. It would be interesting to hear other solutions :)

The fields you want to filter by could be built using Facet API. One thing that's pretty awesome is that the facets are shown depending on the search result. So the facet will only show filters that have results.

The tricky bit is that a facet can only be shown (as far as I know) by a query that has been run. To do this I would create a Search API view that uses you Search API index. Setup a views content pane that shows your search result. Then create a display of the type context in Views.

In your site template (setup using Panels everywhere) Insert the view by adding a pane and look under the "View context" category on the left. Insert the entire view. Then add your facets to the region you want them to show.