Add an AI reranking processor for Search API (owned by the AI module)
### Problem/Motivation Reranking improves the precision of semantic search by re-ordering an initial result set with a dedicated rerank model (or a general-purpose LLM). AI Core already added a `rerank` operation type in [#3488114](https://www.drupal.org/project/ai/issues/3488114) (now closed), but nothing in the ecosystem consumes it yet. [#3557901 — Add Reranking Support to AI Search](https://git.drupalcode.org/project/ai_search/-/work_items/3557901) proposed adding reranking directly to AI Search. On reflection it makes more sense for the **AI module itself to own this**: reranking is a generic Search API capability, not something specific to AI Search's vector backend. Hosting it in AI Core means any Search API index can opt into reranking, and the plugin lives next to the `rerank` operation type it depends on. ### Proposed resolution Add a **Search API processor plugin** in the AI module that reranks query results via the `rerank` operation type: - A Search API `ProcessorPluginBase` plugin that, at result post-processing time, takes the matched items plus the search keys, calls the configured AI provider's `rerank` operation, and re-orders the results by the returned relevance scores. - Configuration: AI provider + model selection, the number of top results to rerank, and which field(s) supply the document text sent to the model. Because Search API processors are plugins discovered at runtime, the processor simply does not load when Search API is absent. ### Dependencies - **No new runtime dependency on `search_api`.** The plugin is purely plugin-based, so the AI module must *not* hard-depend on Search API. - `drupal/search_api` is added under **`require-dev`** in `composer.json` for test coverage only. ### Remaining tasks - Implement the reranking processor plugin - Configuration form (provider/model, top-N, source field(s)) - Kernel/functional test coverage (with `search_api` as a dev dependency) - Documentation ### User interface changes A new "AI reranking" processor becomes available in a Search API index's processor configuration. ### API changes None — this only adds a new plugin. ### Notes This supersedes the AI-Search-owned approach in [#3557901](https://git.drupalcode.org/project/ai_search/-/work_items/3557901); once this lands, that issue can be closed and redirected here.
issue