Skip to content

Comments

SOLR-18127 Solr native text to vector model interface#4161

Open
prathyand wants to merge 3 commits intoapache:mainfrom
wwgrainger:solrNativeTextToVectorModel
Open

SOLR-18127 Solr native text to vector model interface#4161
prathyand wants to merge 3 commits intoapache:mainfrom
wwgrainger:solrNativeTextToVectorModel

Conversation

@prathyand
Copy link

https://issues.apache.org/jira/browse/SOLR-18127

Description

This PR adds a Solr‑native TextToVectorModel interface so that users can plug in their own embedding models without needing to implement LangChain4j classes. Right now, SolrTextToVectorModel is tied directly to LangChain4j’s EmbeddingModel, which makes it awkward for anyone who has a custom embedding service — they have to implement the whole LC4j API even if they don’t use it anywhere else.

The goal here is to give Solr a simple internal abstraction for “text → vector” while keeping all existing LangChain4j providers working the same as before.

Solution

The change is broken up into a few pieces:

  1. New TextToVectorModel interface
    A small interface that provides the basic methods Solr needs.

  2. LangChain4jModelAdapter
    An adapter that wraps an LC4j EmbeddingModel and exposes it through the new interface. This keeps everything backwards‑compatible so existing configs keep working without changes.

  3. Updates to the model initialization workflow
    SolrTextToVectorModel's getInstance() now recognizes either:

    • a native TextToVectorModel implementation, or
    • a LangChain4j model wrapped using the adapter.

AI Assist Disclosure

The ModelConfigUtils.convertValue helper method was written with some assistance from the AI tool Windsurf. It’s a small utility that converts parsed JSON model config values into the types expected by constructors.

Tests

  • Added a test to TextToVectorUpdateProcessorTest that loads a custom DummyTextToVectorModel.
  • This verifies the new interface works end‑to‑end and that the updated initialization logic can discover and load custom models correctly.
  • Existing LC4j-based tests continue to work through the adapter.

Checklist

  • I have reviewed the Contributing Guide and tried to follow the conventions as closely as possible.
  • I have created a Jira issue and referenced it in the PR title.
  • I have given Solr maintainers access to my PR branch.
  • I have developed this change against main.
  • I have run ./gradlew check.
  • I have added tests for the new functionality.
  • I have added documentation to the Reference Guide.
  • I have added a changelog entry.

@github-actions github-actions bot added the tests label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant