How can I get facet blocks to show on pages that aren't search pages?

Comments

Allan Walker’s picture

Yeah! I want to know how to do this too, let me know if you've worked it out!

drunken monkey’s picture

When there is no search, there is nothing to filter, so traditional facets don't make any sense. However, if you want to show the facets for another search page, you can do so via the Views display style "Facet block" for a fitting search view.

BeaPower’s picture

I would like it on the sidebar of my homepage, where users can start to facet search by clicking on the options such as content type, author, categories, etc and would lead them to the search pages. Would Solr Search and not search api be better?

drunken monkey’s picture

I would like it on the sidebar of my homepage, where users can start to facet search by clicking on the options such as content type, author, categories, etc and would lead them to the search pages. Would Solr Search and not search api be better?

you can do so via the Views display style "Facet block" for a fitting search view.

sdragnev’s picture

I think he means that his homepage is not a search view but would like to make it possible for people to start searching for something from the homepage using the facets in the sidebar.

Personally I think this is a good idea as well - this will give people an idea of what they can search for without having to specifically go to a search page or enter keywords. It's the user friendliest way to introduce a visitor to the different categories/facets they can browse without presuming knowledge on their part.

Or maybe I'm misunderstanding the issue.

I can see, however, how this can be a problem technically. As you mentioned, if there's no search, there's no filter.

mrfelton’s picture

In need of this too. I have a search view, and have the facets on the side. When you click through to a node though, the facets disappear and the only way to initiate a new search is to go back to the search page and start from there. I could probably set up exposed filters for the view and have them in a block that displays on the full node view, buts less than ideal because the exposed filters don't seem to interact with the faceted search system in the same way as facet blocks.

drunken monkey’s picture

you can do so via the Views display style "Facet block" for a fitting search view.

mrfelton’s picture

@drunken monkey - just figured that out! Thanks.

tecjam’s picture

Version: 7.x-1.0-rc1 » 7.x-1.0-beta9

Can someone show a basic example of doing this please?

I have a view for a certain node type, it displays my facets nicely to filter by taxonomy terms. However, I want to display the facets on a different view that does not use the search index I created, but the standard nodes table.
This way I can provide openlayers proximity filters to that view, but I can not get it to display the facet filter blocks.

Now in my search index view (with working facets), when I click the Facets Block link I receive the following error message:

Notice: Undefined index: name in SearchApiViewsFacetsBlockDisplay->getFieldOptions() (Zeile 130 von /home/www-data/xxxx.tld/sites/all/modules/search_api/contrib/search_api_views/includes/display_facet_block.inc).

And I can not find the facet block on the blocks page.

Or am I doing it wrong and I should click the facets block in the node type view that doesn't show the facets, but where I'd like to?

Please, a simple guide would be so helpful with this!

drunken monkey’s picture

The mentioned bug should be fixed in the latest dev, other than that your approach seems correct. Note just that the facets then will have to redirect to the search view, filtering on the node view directly is not possible.

rooby’s picture

From #2

When there is no search, there is nothing to filter, so traditional facets don't make any sense.

The apachesolr module allows for facet blocks to be used on an empty search and it works great and is very useful functionality.
They do so by running an empty search.

Is that something you would consider doing here?

drunken monkey’s picture

you can do so via the Views display style "Facet block" for a fitting search view.

rooby’s picture

What about non-views search pages?

I guess that would be the domain of another module, like search_api_page.
And seeing as it is possible for search_api_views to do it then search_api obviously has the ability to support such a thing, am I right?

rooby’s picture

I'm finding it to be a nightmare to get a search page that resembles a normal search page using views to display results.

I want a search page (with a corresponding search block) that has a search box with results displayed below.
When a user is on the page having not done any search I want it to show no search results, but I want the facet blocks to display in their normal locations.
Then I want search to display results when a user clicks a facet without having entered any search keywords.
I also want a separate sort block, which sorts using links, not a select box, and it not part of the exposed filter form.

* This exact set up is very very easy to achieve in the apachesolr module.
(The reason I chose to switch to search api was because it has other features and add ons that apachesolr doesn't have yet.)

* This set up is (almost) very easy to achieve using search_api and search_api_page. The only part that is missing is this ability to have facet only search.

* This set up is extremely hard (or even maybe impossible without dev work) to achieve with search_api_views. search_api_views does allow facet only search but I can't get it to do so without displaying results on an empty search. Also, for sorts to work you have to expose sorts and to get nice sorting you then have to code to remove the sorts from the exposed filter block (which is used for the search box) and add my own custom sorting functionality.

I'm happy to make a patch for search_api_page to give an option to use facets on empty search (if that is where it belongs).
If you could provide a quick bit of direction on running an empty search that would save me some digging time and be greatly appreciated. Or if it is not possible at all for some reason let me know also.

Thanks.

rooby’s picture

No matter, I found what I needed very easily.

For others interested in this, the search api module already provides the abilaity to do this in its api.
Actual implementation of this is the responsibility of other add on modules that provide search pages.

For example, search api views provides this functionality for views based search pages and search api pages would be responsible for implementing this for search pages.

For a search api pages solution see #1368152: Add an option to allow search pages to support facet only searching.
I have a patch on the way there.

BarisW’s picture

@drunken monkey: thanks for the help. The Facets Block display are indeed very nice ;)
What I'm trying to achieve is a replacement of the core search block (fulltext search). Would it be possible to add full-text facets as well?

I tried the Search API Pages modules, but that one only allows the result to be styled in teaser views or view modes. But I want to display my results in a view page.. How can this be achieved?

atlea’s picture

I have been successfully using a "Facets block" in views with "block hidden: yes" to expose facet api blocks "everywhere". This, however, does not seem to work after updating search api and facet api to latest dev (tried 1.x and 2.x branch of facet api).

If I set "block hidden: no", the views facet block (and only the views facet block) shows, so I know the search is executed. But the facet api blocks still only show on the actual search page...

Any advice? :)

Atle

rooby’s picture

@BarisW:
There is a views filter for the full text search.
You can enable that and then enable the display filters in a block setting and you have a full text search block.

The down side is that all exposed filters and sorts will be in that same block, which may or may not be an issue for you.

rooby’s picture

@BarisW:
Also, what is the reason you want the results on a views page as opposed to a search api pages page?

I don't think I've come across anything you can do with the views front end that you can't do with the search_api_pages front end (at least not for my use cases).

BarisW’s picture

@rooby: thanks for your comments. The use case is quite simple: the client wants the search results to be displayed in a table with sortable headings and faceted filters. And tabular results are quite hard to achieve with search api pages, that's why.

rooby’s picture

Ah fair enough, views does make for easy tables.

It is feasible to override the themeing of the search results into a table for search_api_pages though, and there is an issue to overhaul the theme layer of that module to make it a bit better again.
Still, I agree that views is the easier solution - if you can get it to do what you want.

tecjam’s picture

What are the basic settings to show facet blocks created on a search view on views created from nodes?
Is this possible?

The problem I have is that I want to use a proximity filter with facet blocks, but I can only access the proximity filter for node type views, not search type, even though I am indexing the geocoded fields in the correct format (wkt).

So I thought I could create the proximity view and add the facet blocks from the corresponding search view to it for specific paths.

Is this possible in this way or do I have to write some module to mash up both view modules / modify the proximity module to extend or be applicable to the search api / facet api module?

atlea’s picture

See #17 - anyone know how to use Facet api facets on non-search pages using the "Facets block" from views set to hidden? This was working before, but can't get it to show now.

jaxxham’s picture

Hi, I have this working very well with views, one problem though. I can't seem to display checkboxes on my facets this way.

webavant’s picture

I have added a block with the Views display style "Facet block", but how do I change which facet widget it uses? I am using the search_api_range module, but it seems the widget is not available to be used by the "Facet block" Views display.

Seems it's not currently possible. I opened a feature request here.

muayguy’s picture

Every time I try to create a Facets block I get this:

SearchApiException: The "Facets block" display cannot be used with a view for Content. Please only use this display with base tables representing search indexes. in SearchApiViewsFacetsBlockDisplay->getFieldOptions() (line 123 of /Users/muayguy/www/rhys/sites/all/modules/search_api/contrib/search_api_views/includes/display_facet_block.inc).

What's that? I didn't find anything on google and haven't had much help on freenode either....

rooby’s picture

Version: 7.x-1.0-beta9 » 7.x-1.0-rc1

OK so if you use the search API facet block, then you are ok because it does a query so you can get the facets.

However, as #1591424: Views Facet Blocks Displays Don't Have Widget Style Display Option notes, you cannot set the facet api widget then for the views facet blocks.

To get facet api widgets you need to make sure "Hide block" is set to "Yes" and then just use the facet api blocks.

However in that case you cannot use the facetapi facet blocks on non-search_api_views pages because they have no query.

So the issue still remaining is that to use the "Hide Block" & facetapi blocks approach then you can't have the facet blocks on non-search pages.

So that needs to be fixed (see #1252648: Allow for enabling facet blocks on non-search pages as an example of a similar dilemma) or else #1591424: Views Facet Blocks Displays Don't Have Widget Style Display Option needs to be addressed.

Or both.

atlea’s picture

Hi

There is a patch to make Search API facet block set to hidden enable the use of Facet API blocks on any page. Just make sure the Search API facet block has a lower block weight.

#1417456-17: Facets on non-search Search API pages broken by facetapi_block_list_alter removing the block

Atle

rooby’s picture

Thanks for the heads up, I saw that one but haven't tried it out yet.

Nick_vh’s picture

Issue summary: View changes
Status: Active » Fixed

Looks like this was fixed

Status: Fixed » Closed (fixed)

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

Tharick’s picture

Hello,

Am using the Search API facets, I tried our the "Facets Block" display in views. It works well. But my concern is, I have 5 fields to display, but in that view I can select the only one "Facet field". Even I using Facetapi Select to display the terms in select list. So, whenever I display the "Facets Block" contents, it never shows the select list as well as when we click on this its not going to the main search page.

Please any one help on this case.

Thanks in advance.

rooby’s picture

@Tharick:

Please open a new issue for your problem.

Ravi Shankar Karnati’s picture

Hi @drunken monkey , Regarding #7, do we have this configuration options for Drupal 8?