Search API indexes of CRM contacts do not apply CRM’s grant model by default. Without access filtering, contact search can expose private records to users who should not see them.
CRM Search API adds an opt-in CRM contact access processor. It indexes view grants and user–contact mappings, then filters Search API queries with the same access rules used by Views, list builders, and core Contact Search.
Use it whenever you build contact search with Search API—Database Search, Solr, Facets, or Search API Views—and contact privacy matters.
Features
- Grant indexing — Denormalizes view grants from
crm_contact_accessinto the search index. - Mapped-user indexing — Indexes user IDs mapped to each contact for blanket mapped access.
- Access parity — Filters queries using the same model as Views and Contact Search: bypass permissions, bundle permissions, mapped access, and grant tokens (including
hook_crm_contact_grants()). - Opt-in per index — Indexes do not enforce contact access until you enable the processor.
- Mapping-aware reindex — When user–contact mappings change, affected contacts are marked for reindex automatically.
- Mixed-datasource safe — On indexes that mix entity types, only CRM contacts are filtered.
- Backend agnostic — Works with any Search API backend.
Example use cases:
- A member directory where each person only sees contacts they are allowed to view.
- Staff CRM search over Solr or Database Search with role- and grant-based privacy.
- Faceted contact search that must match CRM’s existing access rules.
Post-Installation
This module has no configuration form of its own. After installing CRM, Search API, and a search backend:
- Enable CRM Search API.
- Create a Search API server and index.
- Add the CRM contact datasource (
entity:crm_contact). - On the index Processors tab, enable CRM contact access.
- Save the index and index (or reindex) items.
- Build Views, Facets, or other Search API UIs against the index as usual.
Assign CRM permissions and grants as needed (administer crm, view any crm contact, bundle-specific view permissions, view mapped crm contact, plus your grant setup). After access-model changes that do not go through mapping hooks, reindex affected contacts so search stays in sync.
Additional Requirements
- CRM (
^1.0.0-beta5) - Search API
- Drupal 11.1 or later
- A Search API backend (for example Database Search or Solr)
Recommended modules/libraries
- Database Search or Search API Solr — search backends for your index.
- Facets — faceted browsing on contact indexes.
- CRM’s
crm_simpsonsrecipe — sample contacts for local exploration (see DDEV setup below).
Similar projects
- CRM Contact Search — CRM’s built-in core Search plugin uses the same access model, but it is not Search API. Use this module when you need Search API indexes, backends, Views, or Facets.
- Search API Content access — Filters node search by
node_access. CRM Search API is the equivalent for CRM contacts and thecrm_contact_accessgrant system.
Supporting this Module
Local development for this project relies on DDEV. If you use DDEV, consider sponsoring DDEV development.
Community Documentation
- README in the project repository
- Issue queue for questions, bugs, and feature requests
Develop with DDEV
If you have not already, install DDEV, then:
git clone git@git.drupal.org:project/crm_search_api.git cd crm_search_api ddev config --project-type=drupal --docroot=web --php-version=8.4 --corepack-enable --project-name=crm-search-api ddev add-on get ddev/ddev-drupal-contrib ddev add-on get s-ayers/ddev-drupal-contrib-mkdocs ddev add-on get s-ayers/ddev-drupal-paratest ddev start ddev poser ddev symlink-project ddev drush site:install -y ddev drush pm:install crm_search_api -y ddev drush config:export -y ddev drush user:login ddev drush recipe modules/contrib/crm/recipes/crm_simpsons
Project information
- Project categories: Site search
- Ecosystem: CRM - Contact Relationship Management
3 sites report using this module
- Created by bluegeek9 on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
