materio_ai: neighbour search service with Solr kNN (I4)

NeighbourSearch::search() embeds a phrase and runs a Search API query on the
database index, tagged materio_ai_knn. KnnQuerySubscriber turns only this
query into {!knn f=knn1024_vector topK=N}: Search API filter queries
(content_access, language, index) stay as kNN pre-filters (Solr 9.1+), and
keyword queries are untouched. Sent in POST by http_method AUTO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShDspHaZGwHoRZCsPBJzsM
This commit is contained in:
2026-11-17 10:51:32 +01:00
co-authored by Claude Opus 5.5
parent cc19dedf92
commit f1ebea91db
3 changed files with 181 additions and 0 deletions
@@ -34,3 +34,14 @@ services:
arguments: ['@config.factory', '@materio_ai.embedding_storage']
tags:
- { name: event_subscriber }
materio_ai.neighbour_search:
class: Drupal\materio_ai\Search\NeighbourSearch
arguments: ['@entity_type.manager', '@language_manager', '@config.factory', '@materio_ai.embedding_client']
Drupal\materio_ai\Search\NeighbourSearch: '@materio_ai.neighbour_search'
materio_ai.knn_query_subscriber:
class: Drupal\materio_ai\EventSubscriber\KnnQuerySubscriber
arguments: ['@config.factory']
tags:
- { name: event_subscriber }