drupal-search-api
Skill71 starsChanged 7 months agoMITView on GitHub
Search API — index configuration, boost processors, field types, number field boosting, engagement metrics, and reindexing workflows.
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- grasmash/drupal-claude-skillsedited, first seen Oct 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- grasmash/drupal-claude-skills★ 8151% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository35 other files it gives its agents.
- ddev-expertSkill
- docker-localSkill
- drupal-accessSkill
- drupal-cachingSkill
- drupal-composerSkill
- drupal-configSkill
- drupal-contrib-mgmtSkill
- drupal-debuggingSkill
- drupal-drushSkill
- drupal-dttSkill
- drupal-entity-apiSkill
- drupal-eventsSkill
- drupal-fieldsSkill
- drupal-form-ajaxSkill
- drupal-form-alterSkill
- drupal-form-apiSkill
- drupal-form-validationSkill
- drupal-hooksSkill
- drupal-htmxSkill
- drupal-javascriptSkill
- drupal-kernelSkill
- drupal-menusSkill
- drupal-migrationsSkill
- drupal-paragraphsSkill
- drupal-pluginsSkill
- drupal-queriesSkill
- drupal-renderSkill
- drupal-routesSkill
- drupal-securitySkill
- drupal-servicesSkill
- drupal-stateSkill
- drupal-taxonomySkill
- drupal-twigSkill
- drupal-unitSkill
- SKILL.mdSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 12 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Always configure boolean fields as type: boolean in index settings
- Very specific: line 36
Use type: integer for count fields
- Very specific: line 85
Use multiplicative boost: $item->setBoost($old_boost * boost_factor)
- Distinctive: line 88
Always get old boost first to preserve other boosts
- Distinctive: line 143
If multiple processors target the same field, they can conflict:
- Distinctive: line 157
Use custom processor for boolean/complex logic
- Distinctive: line 158
Use number_field_boost for simple numeric boosts
- Distinctive: line 159
Don't configure same field in multiple processors
- Very specific: line 165
When drush config:set fails or produces unexpected results (e.g., side effects on unrelated config), use PHP to directly update active …
- Very specific: line 189
When config:set creates unwanted side effects (e.g., changing server: {server_name} to server: null)
- Very specific: line 190
When removing array keys (unset pattern works better than null)
- Distinctive: line 191
When making multiple related changes atomically
- Distinctive: line 192
When field type changes cause Drupal to fallback to generic types
- Distinctive: line 202
Problem: When Solr server config is modified (e.g., pointing to a different backend), config export may downgrade custom field types to …
- Distinctive: line 214
Solution: After exporting, restore custom field types via PHP:
- Distinctive: line 238
When modifying Search API server config (e.g., for local development), Drupal may update index configs to remove server dependencies:
- Very specific: line 249
Don't modify search_api.server.{server_name}.yml for local development
- Distinctive: line 250
Use DDEV's built-in Solr service without changing server config
- Distinctive: line 251
If server config changes are needed, use config splits for environment-specific settings
- Very specific: line 252
Always review git diff config/sync/ before committing
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Drupal Search API
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: booleanin index settings
field_settings:
field_featured:
label: Featured
datasource_id: 'entity:node'
property_path: field_featured
type: boolean # NOT integer
boost: 8.0Configuration Command
ddev drush config:set search_api.index.{index_name} \
field_settings.field_featured.type booleanNumeric Fields for Engagement Boosting
Flag Count Fields
- Use
type: integerfor count fields - Managed by
flag_search_apimodule - Automatically indexed and updated
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: integerBoost 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 — extends ProcessorPluginBase, stage preprocess_index
// Use #[SearchApiProcessor(...)] attribute (use Drupal\search_api\Attribute\SearchApiProcessor) — see README for full class
final class FeaturedContentBoost extends ProcessorPluginBase {
public function preprocessIndexItems(array $items) {
foreach ($items as $item) {
try {
$entity = $item->getOriginalObject()->getValue();
if ($entity->hasField('field_featured') &&
!$entity->get('field_featured')->isEmpty() &&
$entity->get('field_featured')->value == 1) {
$item->setBoost($item->getBoost() * 2.0);
}
}
catch (\Exception $e) {
continue;
}
}
}
}Key Points
- Use multiplicative boost:
$item->setBoost($old_boost * boost_factor) - Pattern from
search_api_boolean_field_boostmodule - Boost at index time via
preprocess_indexstage - 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
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: maxHow 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
# Set bookmark count boost (0.01 per bookmark)
ddev drush config:set search_api.index.{index_name} \
processor_settings.number_field_boost.boosts.flag_bookmark_count.boost_factor 0.01
# Set favorite count boost (0.1 per favorite)
ddev drush config:set search_api.index.{index_name} \
processor_settings.number_field_boost.boosts.flag_favorite_count.boost_factor 0.1Recommended Boost Factors
- Bookmark count:
0.01 - 0.05(for counts in 10-1000 range) - Favorite count:
0.1 - 0.5(for counts in 1-50 range) - View count:
0.001 - 0.01(for counts in 100-10000 range)
Processor Conflicts
Problem: Multiple Processors on Same Field
If multiple processors target the same field, they can conflict:
- One overrides the other
- Boosts don't combine as expected
- Unpredictable results
Solution: Remove Conflicting Configuration
# Remove field from number_field_boost if using custom processor
ddev drush config:set search_api.index.{index_name} \
processor_settings.number_field_boost.boosts.field_featured nullBest Practice
- Use custom processor for boolean/complex logic
- Use number_field_boost for simple numeric boosts
- Don't configure same field in multiple processors
Configuration Management
Direct Config Updates with PHP
When drush config:set fails or produces unexpected results (e.g., side effects on unrelated config), use PHP to directly update active configuration:
ddev drush php:eval "
\$config = \Drupal::configFactory()->getEditable('search_api.index.{index_name}');
// Set field type
\$config->set('field_settings.field_featured.type', 'boolean');
// Remove from number_field_boost
\$boosts = \$config->get('processor_settings.number_field_boost.boosts');
unset(\$boosts['field_featured']);
\$config->set('processor_settings.number_field_boost.boosts', \$boosts);
// Set boost factors
\$config->set('processor_settings.number_field_boost.boosts.flag_bookmark_count.boost_factor', 0.01);
\$config->set('processor_settings.number_field_boost.boosts.flag_favorite_count.boost_factor', 0.1);
\$config->save();
echo \"Configuration updated\n\";
"When to Use PHP Instead of drush config:set:
- When config:set creates unwanted side effects (e.g., changing
server: {server_name}toserver: null) - When removing array keys (unset pattern works better than
null) - When making multiple related changes atomically
- When field type changes cause Drupal to fallback to generic types
After PHP Config Updates:
- Verify changes:
ddev drush config:get search_api.index.{index_name} field_settings.field_featured - Export to files:
ddev drush config:export -y - Review exported changes:
git diff config/sync/ - Revert any unintended changes (e.g., ngram fields changed to plain text)
Field Type Preservation
Problem: When Solr server config is modified (e.g., pointing to a different backend), config export may downgrade custom field types to generic types:
# BEFORE (correct)
field_display_name:
type: 'solr_text_custom:ngramstring'
# AFTER export (incorrect)
field_display_name:
type: textSolution: After exporting, restore custom field types via PHP:
ddev drush php:eval "
\$config = \Drupal::configFactory()->getEditable('search_api.index.{index_name}');
\$config->set('field_settings.field_display_name.type', 'solr_text_custom:ngramstring');
\$config->set('field_settings.label.type', 'solr_text_custom:ngramstring');
\$config->set('field_settings.name.type', 'solr_text_custom:ngramstring');
\$config->set('field_settings.title.type', 'solr_text_custom:ngramstring');
\$config->save();
"
ddev drush config:export -yFields Using ngram Tokenization:
field_display_name- Display names (partial matching for autocomplete)label- Entity labels/titlesname- User account namestitle- Node titles
Never change these to type: text - it breaks partial name matching (e.g., "mich" won't find "Michael").
Config Export Side Effects
When modifying Search API server config (e.g., for local development), Drupal may update index configs to remove server dependencies:
# Unintended change in search_api.index.{index_name}.yml
dependencies:
config:
- - search_api.server.{server_name} # Removed
server: null # Changed from {server_name}Prevention:
- Don't modify
search_api.server.{server_name}.ymlfor local development - Use DDEV's built-in Solr service without changing server config
- If server config changes are needed, use config splits for environment-specific settings
- Always review
git diff config/sync/before committing
Recovery:
# Revert index files if server was set to null
git checkout HEAD -- config/sync/search_api.index.*.ymlReindexing After Changes
When Reindexing is Required
Always reindex after:
- Changing field type (integer -> boolean)
- Changing boost factors
- Adding/removing processors
- Modifying processor configuration
Reindex Commands
# Full reindex workflow
ddev drush cr
ddev drush search-api:clear {index_name}
ddev drush search-api:index {index_name}
# Check index status
ddev drush search-api:status {index_name}Debug Commands
# Check processor configuration
ddev drush config:get search_api.index.{index_name} processor_settings
# Check field configuration
ddev drush config:get search_api.index.{index_name} field_settings
# Verify index status
ddev drush search-api:status {index_name}Boost not applying checklist: processor enabled → field type correct (boolean/integer) → full reindex completed → no conflicting processors → cache cleared.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

