Token导航 LogoToken导航

Agent Skill · 研究检索

drupal-search-api(drupal 搜索 API)

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

drupal-search-api 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 42,992。

总安装 1,023周安装 41GitHub Stars 61下载 331核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:drupal-search-api(drupal 搜索 API)
来源仓库:https://github.com/grasmash/drupal-claude-skills
仓库路径:skills/drupal-search-api
安装命令:
npx skills add https://github.com/grasmash/drupal-claude-skills --skill drupal-search-api
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/grasmash/drupal-claude-skills --skill drupal-search-api

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

该技能提供 Search API 的配置模式和优化策略,支持自定义处理器开发。适用于索引配置、字段类型设置和搜索结果排序优化。包含布尔字段提升策略和配置命令参考,确保搜索性能最佳化。安装需从 GitHub 仓库获取,使用前应确认 Search API 模块已启用。

涉及复杂搜索逻辑时,应测试不同字段类型的性能表现,避免整数字段误用。

来源仓库内路径:skills/drupal-search-api

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/grasmash/drupal-claude-skills --skill drupal-s…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

drupal-search-api 怎么安装?

在终端执行 npx skills add https://github.com/grasmash/drupal-claude-skills --skill drupal-search-api。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

drupal-search-api 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

drupal-search-api 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

drupal-search-api 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

drupal-search-api 用的人多吗?

公开数据是累计安装 1,023 次,近一周安装 41 次,下载 331 次,GitHub 61 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

drupal-search-api 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
drupal-search-api

drupal 搜索 API · 本页

1,02361需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

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
field_settings:
  field_featured:
    label: Featured
    datasource_id: 'entity:node'
    property_path: field_featured
    type: boolean  # NOT integer
    boost: 8.0

Configuration Command

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
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

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

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

# 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.1

Recommended 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 null

Best 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} to server: 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:

  1. Verify changes: ddev drush config:get search_api.index.{index_name} field_settings.field_featured
  2. Export to files: ddev drush config:export -y
  3. Review exported changes: git diff config/default/
  4. 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: text

Solution: 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 -y

Fields Using ngram Tokenization:

  • field_display_name - Display names (partial matching for autocomplete)
  • label - Entity labels/titles
  • name - User account names
  • title - 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:

  1. Don't modify search_api.server.{server_name}.yml for local development
  2. Use DDEV's built-in Solr service without changing server config
  3. If server config changes are needed, use config splits for environment-specific settings
  4. Always review git diff config/default/ before committing

Recovery:

# Revert index files if server was set to null
git checkout HEAD -- config/default/search_api.index.*.yml

Reindexing 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}

Partial Reindexing

# Index only remaining items (incremental)
ddev drush search-api:index {index_name}

# Clear and reindex specific items (not available in core)
# Use full reindex instead

Testing Boosts

Search API Drush Commands

# Test search via drush
ddev drush search-api:search {index_name} "search query"

# Check indexed values
ddev drush search-api:status {index_name}

Web Endpoint Testing

# Test via web search endpoint
curl -H "Accept: application/vnd.api+json" \
  "https://example.com/search-api/web-search?query=test"

# Parse results with Python
curl -s "https://example.com/search-api/web-search?query=test" | \
  python3 -c "import sys, json; data = json.load(sys.stdin); \
  [print(f'{i+1}. {item[\"attributes\"][\"title\"]}') \
  for i, item in enumerate(data['data'][:10])]"

Validation Queries

Check Bookmark Counts

SELECT u.uid, u.name, fcf.count AS bookmark_count
FROM users_field_data u
LEFT JOIN flag_counts fcf ON fcf.entity_type = 'user'
  AND fcf.entity_id = u.uid
  AND fcf.flag_id = 'bookmark'
ORDER BY fcf.count DESC
LIMIT 10;

Check Favorite Counts

SELECT n.nid, n.title, fcl.count AS favorite_count
FROM node_field_data n
INNER JOIN flag_counts fcl ON fcl.entity_type = 'node'
  AND fcl.entity_id = n.nid
  AND fcl.flag_id = 'favorite'
WHERE n.type = 'article'
ORDER BY fcl.count DESC
LIMIT 10;

Performance Considerations

Index-Time vs Query-Time Boosting

Index-Time Boosting (Recommended)

  • Better performance (computed once during indexing)
  • Scales with high query volume
  • Requires reindex when boost logic changes
  • Static boosts (can't adjust per-query)

Query-Time Boosting

  • Dynamic (can adjust per-query)
  • No reindex needed for changes
  • Performance impact on every query
  • Complex to implement with Search API

Recommended Pattern: Index-Time Boosting

  • All boosts applied during preprocess_index stage
  • Scales better for high-traffic search
  • Acceptable reindex requirement

Boost Stacking

How Boosts Combine

  1. Base relevance score (from Solr)
  2. Featured content boost: score x 2.0
  3. Bookmark count boost: score + (bookmarks x 0.01)
  4. Favorite count boost: score + (favorites x 0.1)

Example Calculation

Node: "Getting Started with Drupal" (featured, 138 bookmarks)
- Base score: 1.0
- Featured: 1.0 x 2.0 = 2.0
- 138 bookmarks: 2.0 + (138 x 0.01) = 3.38
- Final boost: 3.38

Node: "Advanced Drupal Techniques"
- Base score: 1.0
- 12 favorites: 1.0 + (12 x 0.1) = 2.2
- Final boost: 2.2

Common Issues

Issue: Boost Not Applied

Symptoms

  • Results not ranking as expected
  • No difference after reindex

Checklist

  1. Processor enabled in index config
  2. Field type correct (boolean/integer)
  3. Full reindex completed
  4. No conflicting processors
  5. Cache cleared after config changes

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}

Issue: Boost Too Strong/Weak

Symptoms

  • Irrelevant results ranking too high
  • Important results not ranking high enough

Solution: Adjust Boost Factors

Too strong (dominating relevance):

  • Reduce multiplicative boosts (2.0 -> 1.5)
  • Reduce additive boost factors (0.1 -> 0.05)

Too weak (no visible effect):

  • Increase boost factors gradually
  • Test with extreme values to confirm working, then dial back

Testing Pattern

  1. Start with conservative boost (1.5x or 0.01)
  2. Test with known queries
  3. Increase gradually until effect visible
  4. Reduce to optimal level

Module Dependencies

Required Modules

  • search_api - Core Search API module
  • search_api_solr - Solr backend (if using Solr)

Optional Modules

  • flag_search_api - Index flag counts (bookmark, favorite)
  • search_api_boolean_field_boost - Reference for boost patterns

References

Search API Processor Development

Boosting Strategies

Flag Search API

平台分布

Codex

36.82%
按下载量换算122

Claude

30.67%
按下载量换算102

Cursor

17.32%
按下载量换算57

Gemini CLI

8.78%
按下载量换算29

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills