localgovdrupal / localgov_search

Default sitewide search implementation for LocalGov Drupal.
GNU General Public License v2.0
0 stars 1 forks source link

Allow SitewideSearchBlock plugin to be extended for use with a different view. #35

Closed rupertj closed 2 years ago

rupertj commented 2 years ago

I need the functionality that SitewideSearchBlock provides, but with a different view.

This PR moves the view and display IDs to properties of the block plugin class, so they can be changed when the class is extended.

finnlewis commented 2 years ago

Thanks @rupertj - @ekes and I are interested in how you're using this. Are you creating another block that extends this?

rupertj commented 2 years ago

Yep, exactly that.

We're using Elasticsearch/Opensearch on LBHF, so the main search is a view I've built instead of the stock LGD one. Having disabled the main search view, the SiteWideSearchBlock was present but not submitting to the right place any more, so I wanted to change it to submit to my new view.

I've added a new block plugin, which for the moment copies and pastes all the code, but with this PR merged, it could just extend the existing class and set the view and display IDs to the ones I need.

ekes commented 2 years ago

Makes sense.

Can't see that it would be helpful adding tests for this. What would it be? Having to package a test module that extends it.

The way we're implementing swappable servers is to switch the server on the index, thus maintaining the same view. There are separate open questions about better formatting for the view; and how to advise changing it if you want fields not entities - this PR also probably helps that.

So approve this; but are you still using search api? Would you then have a server config, and any advisable settings for the index? If so could we collect them to make an elastic search module for the distro?

rupertj commented 2 years ago

Yes, we're still using search_api, in conjunction with elasticsearch_connector.

The main reason for the new view is that we've set up the search to index both the D9 and D7 sites while we transition between the two. (The D7 site also uses an expensive third party service, which we're keen to discontinue). Hence the view has some specific setup to make that work (no loading entities, access control off, etc).

So I suspect our setup might be a bit unusual to contrib back at the moment, but it might end up a bit more normal once the D7 => D9 transition's done.