
Drupal Search Api
Configure Drupal Search API indexes, field types, boost processors, and reindex workflows for better on-site search.
Install
npx skills add https://github.com/grasmash/drupal-claude-skills --skill drupal-search-apiWhat is this skill?
- Boolean fields as type boolean—not integer—for reliable custom boost processors
- YAML field_settings patterns for featured boost (e.g. boost 8.0) and integer flag count fields
- Custom boolean boost processor patterns and numeric engagement boosting via flag_search_api
- Drush config:set examples for search_api.index.{index_name} field type fixes
- Reindexing workflow guidance for processor and field changes
Adoption & trust: 1 installs on skills.sh; 67 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Entra App Registrationmicrosoft/azure-skills
Azure Aigatewaymicrosoft/azure-skills
Lark Openapi Explorerlarksuite/cli
Supabasesupabase/agent-skills
Firebase Auth Basicsfirebase/agent-skills
Firebase Data Connectfirebase/agent-skills
Journey fit
Common Questions / FAQ
Is Drupal Search Api safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Drupal Search Api
# Drupal Search API Patterns This skill documents Search API configuration patterns, boosting strategies, and custom processor development for Drupal sites. ## Index Configuration ### Field Type Requirements **Boolean Fields for Boosting** - Boolean fields work best with custom boost processors - Integer fields can cause issues with boolean-based boost logic - Always configure boolean fields as `type: boolean` in index settings ```yaml field_settings: field_featured: label: Featured datasource_id: 'entity:node' property_path: field_featured type: boolean # NOT integer boost: 8.0 ``` **Configuration Command** ```bash ddev drush config:set search_api.index.{index_name} \ field_settings.field_featured.type boolean ``` ### Numeric Fields for Engagement Boosting **Flag Count Fields** - Use `type: integer` for count fields - Managed by `flag_search_api` module - Automatically indexed and updated ```yaml field_settings: flag_bookmark_count: label: 'Bookmark count' property_path: flag_bookmark_count type: integer flag_favorite_count: label: 'Favorite count' property_path: flag_favorite_count type: integer ``` ## Boost Processors ### Custom Boolean Boost Processor **When to Use** - Boolean field boosting (featured flags, promoted content) - Needs 100% control over boost logic - Complex conditional boosting **Pattern: FeaturedContentBoost.php** ```php <?php namespace Drupal\custom_search\Plugin\search_api\processor; use Drupal\search_api\Item\ItemInterface; use Drupal\search_api\Processor\ProcessorPluginBase; /** * @SearchApiProcessor( * id = "featured_content_boost", * label = @Translation("Featured content boost"), * description = @Translation("Adds a boost to indexed items marked as featured."), * stages = { * "preprocess_index" = 0, * }, * locked = false, * hidden = false, * ) */ class FeaturedContentBoost extends ProcessorPluginBase { /** * {@inheritdoc} */ public function preprocessIndexItems(array $items) { /** @var \Drupal\search_api\Item\ItemInterface $item */ foreach ($items as $item) { try { $entity = $item->getOriginalObject()->getValue(); // Check if entity has featured field and it's set to TRUE. if ($entity->hasField('field_featured') && !$entity->get('field_featured')->isEmpty() && $entity->get('field_featured')->value == 1) { $old_boost = $item->getBoost(); // Apply 2x boost to featured content. $item->setBoost($old_boost * 2.0); } } catch (\Exception $e) { // Skip items that can't be loaded. continue; } } } } ``` **Key Points** - Use multiplicative boost: `$item->setBoost($old_boost * boost_factor)` - Pattern from `search_api_boolean_field_boost` module - Boost at index time via `preprocess_index` stage - Always get old boost first to preserve other boosts **Recommended Boost Factors** - Featured content: `2.0x` (modest but effective) - Featured content: `1.5x - 3.0x` - Premium content: `1.5x - 2.0x` ### Number Field Boost Processor **When to Use** - Engagement metrics (likes, bookmarks, views) - Numeric quality scores - Time-based decay factors **Configuration Pattern** ```yaml processor_settings: number_field_boost: weights: preprocess_index: 0 boosts: flag_bookmark_count: boost_factor: 0.01 aggregation: max flag_favorite_count: boost_factor: 0.1 aggregation: max ``` **How It Works** - Adds to boost based on field value - Formula: `boost += (field_value * boost_factor)` - Example: 138 bookmarks x 0.01 = +1.38 boost **Configuration Commands** ```b