algolia / jekyll-algolia

Add fast and relevant search to your Jekyll site
https://community.algolia.com/jekyll-algolia/
MIT License
214 stars 35 forks source link

Search across multiple Jekyll sites #163

Open jasonriley opened 3 years ago

jasonriley commented 3 years ago

I want to suggest a feature (or see if anyone has a creative workaround):

Support for searching across multiple, distinct Jekyll sites

What is your use case for such a feature?

Why? We have a WWW site that has lots of blog content, and a separate site for software developers that has API reference information, how to articles etc. I'd like searches on either site to show matches on both. Both sites are driven by Jekyll, and this plugin works well for indexing and searching when there is one site per index.

What is your proposed API? Is this a new option? A new behavior?

How? a) use one index for all the sites, but use a website property to scope the update to the index so that when a site is indexed, it only updates those records with that website. In other words it doesn't update or delete object from a different website. b) website could be a facet that allows for searching one site or all sites, and also allows the building of the full URL to the search result on a different site.

Perhaps there is a way to put a hook or callout either on the query of existing object IDs or the determining of which ones to remove.

Haroenv commented 3 years ago

forking the plugin to add configuration of a certain attribute in this list here https://github.com/algolia/jekyll-algolia/blob/develop/lib/jekyll/algolia/indexer.rb#L205 should be a good start. I'd advise you to fork the plugin and having a look at how that works first, but once you've got something working, I'll gladly review it

Krinkle commented 3 years ago

This can be accomplished today using multiple indexes under the same "application", which I believe is actually a feature specifically for this purpose. Where each related group of sites/indexes together are one application that one or more account holders can manage.

For an example of this, see qunit:/docs and qunitjs.com which are published at api.qunitjs.com and qunitjs.com respectively. Each uses jekyll-algolia to index its own "site", which the Amethyst theme's both specifies in autocomplete query, which also has built-in support already for mutiple indexes and showing their results together.