Search¶
Let one Search API index serve every site, each site finding only its own content.
Needs Sites Search API
Part of Sites Search API.
The Sites processor of Search API stores the sites each item belongs to in the Sites field, and narrows every search by it:
- On a site, a search finds the items of that site. An item on no site is found nowhere, unless a module makes its type available on every site.
- On the hub, a search finds the items that belong to any site.
- With Sites language, a search on a site finds only items in the site's languages, and language-neutral ones.
The index holds one document per item, built from the canonical version: what a site changes in an override is not searchable.
Set up¶
- Install:
composer require drupal/sites_search_api drush en sites_search_api - Edit the index at
/admin/config/search/search-api. The processor is offered for indexes with an entity datasource. - On the Processors tab, enable Sites and save.
- On the Fields tab, click Add fields, add Sites from General, and save.
- On the index's View tab, click Queue all items for reindexing, then Index now.
Nothing is set per site. When an item's sites change without a save of the item, it is queued for reindexing.
A search view with Bypass access checks in its query settings is not filtered by site.