Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Refactor the tests of the language-model module to accomodate new upcoming LLM oriented features avoiding code duplication.
type: fixed
authors:
- name: Nicolò Rinaldi
- name: Anna Ruggero
- name: Alessandro benedetti
links:
- name: PR#4419
url: https://github.com/apache/solr/pull/4419
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ amazon-awssdk-s3 = { module = "software.amazon.awssdk:s3", version.ref = "amazon
amazon-awssdk-sdkcore = { module = "software.amazon.awssdk:sdk-core", version.ref = "amazon-awssdk" }
amazon-awssdk-sts = { module = "software.amazon.awssdk:sts", version.ref = "amazon-awssdk" }
androidx-lifecycle-runtimeCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewModelNav3 = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-navigation3", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodelCompose = { module = "org.jetbrains.androidx.lifecycle:lifecycle-viewmodel-compose", version.ref = "androidx-lifecycle" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suspicious, probably a mistake?

Copy link
Copy Markdown
Contributor Author

@nicolo-rinaldi nicolo-rinaldi May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this came out from ./gradlew tidy. My take is that the capital M changes the alphabetical order. The change has not been made by me personally

androidx-material3-adaptive = { module = "org.jetbrains.compose.material3.adaptive:adaptive", version.ref = "androidx-adaptive" }
androidx-material3-adaptive-nav3 = { module = "org.jetbrains.compose.material3.adaptive:adaptive-navigation3", version.ref = "androidx-adaptive" }
androidx-navigation3-ui = { module = "org.jetbrains.androidx.navigation3:navigation3-ui", version.ref = "androidx-navigation3" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import org.apache.solr.common.SolrException;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.languagemodels.LanguageModelException;
import org.apache.solr.languagemodels.store.rest.ManagedTextToVectorModelStore;
import org.apache.solr.languagemodels.store.rest.TextToVectorModelStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* This object wraps a {@link EmbeddingModel} to encode text to vector. It's meant to be used as a
* managed resource with the {@link ManagedTextToVectorModelStore}
* managed resource with the {@link TextToVectorModelStore}
*/
public class SolrTextToVectorModel extends SolrLanguageModel implements Accountable {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.languagemodels.model.SolrTextToVectorModel;
import org.apache.solr.languagemodels.store.rest.ManagedTextToVectorModelStore;
import org.apache.solr.languagemodels.store.rest.TextToVectorModelStore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.rest.ManagedResource;
import org.apache.solr.rest.ManagedResourceObserver;
Expand All @@ -44,7 +44,7 @@
public class TextToVectorQParserPlugin extends QParserPlugin
implements ResourceLoaderAware, ManagedResourceObserver {
public static final String EMBEDDING_MODEL_PARAM = "model";
private ManagedTextToVectorModelStore modelStore = null;
private TextToVectorModelStore modelStore = null;

@Override
public QParser createParser(
Expand All @@ -55,14 +55,14 @@ public QParser createParser(
@Override
public void inform(ResourceLoader loader) throws IOException {
final SolrResourceLoader solrResourceLoader = (SolrResourceLoader) loader;
ManagedTextToVectorModelStore.registerManagedTextToVectorModelStore(solrResourceLoader, this);
TextToVectorModelStore.registerManagedTextToVectorModelStore(solrResourceLoader, this);
}

@Override
public void onManagedResourceInitialized(NamedList<?> args, ManagedResource res)
throws SolrException {
if (res instanceof ManagedTextToVectorModelStore) {
modelStore = (ManagedTextToVectorModelStore) res;
if (res instanceof TextToVectorModelStore) {
modelStore = (TextToVectorModelStore) res;
}
if (modelStore != null) {
modelStore.loadStoredModels();
Expand Down Expand Up @@ -105,7 +105,7 @@ public Query parse() throws SyntaxError {
"The model requested '"
+ embeddingModelName
+ "' can't be found in the store: "
+ ManagedTextToVectorModelStore.REST_END_POINT);
+ TextToVectorModelStore.REST_END_POINT);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/** Managed Resource wrapper for the text-to-vector model store, exposed via REST */
@ThreadSafe
public class ManagedTextToVectorModelStore
public class TextToVectorModelStore
extends ManagedLanguageModelStore<SolrTextToVectorModel> {

/** the model store rest endpoint */
Expand All @@ -38,11 +38,11 @@ public static void registerManagedTextToVectorModelStore(
solrResourceLoader
.getManagedResourceRegistry()
.registerManagedResource(
REST_END_POINT, ManagedTextToVectorModelStore.class, managedResourceObserver);
REST_END_POINT, TextToVectorModelStore.class, managedResourceObserver);
}

public static ManagedTextToVectorModelStore getManagedModelStore(SolrCore core) {
return (ManagedTextToVectorModelStore) core.getRestManager().getManagedResource(REST_END_POINT);
public static TextToVectorModelStore getManagedModelStore(SolrCore core) {
return (TextToVectorModelStore) core.getRestManager().getManagedResource(REST_END_POINT);
}

@Override
Expand All @@ -56,7 +56,7 @@ protected SolrTextToVectorModel fromModelMap(
(Map<String, Object>) textToVectorModel.get(PARAMS_KEY));
}

public ManagedTextToVectorModelStore(
public TextToVectorModelStore(
String resourceId, SolrResourceLoader loader, ManagedResourceStorage.StorageIO storageIO)
throws SolrException {
super(resourceId, loader, storageIO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.languagemodels.model.SolrTextToVectorModel;
import org.apache.solr.languagemodels.store.rest.ManagedTextToVectorModelStore;
import org.apache.solr.languagemodels.store.rest.TextToVectorModelStore;
import org.apache.solr.languagemodels.update.processor.TextToVectorUpdateProcessor;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
Expand All @@ -44,7 +44,7 @@
* <p>The parameters supported are:
*
* <pre class="prettyprint" >
* &lt;processor class=&quot;solr.llm.textvectorisation.update.processor.TextToVectorUpdateProcessorFactory&quot;&gt;
* &lt;processor class=&quot;solr.languagemodels.update.processor.factory.TextToVectorUpdateProcessorFactory&quot;&gt;
* &lt;str name=&quot;inputField&quot;&gt;textualField&lt;/str&gt;
* &lt;str name=&quot;outputField&quot;&gt;vectorField&lt;/str&gt;
* &lt;str name=&quot;model&quot;&gt;textToVectorModel&lt;/str&gt;
Expand All @@ -58,7 +58,7 @@ public class TextToVectorUpdateProcessorFactory extends UpdateRequestProcessorFa
private static final String INPUT_FIELD_PARAM = "inputField";
private static final String OUTPUT_FIELD_PARAM = "outputField";
private static final String MODEL_NAME = "model";
private ManagedTextToVectorModelStore modelStore = null;
private TextToVectorModelStore modelStore = null;

private String inputField;
private String outputField;
Expand All @@ -77,14 +77,14 @@ public void init(final NamedList<?> args) {
@Override
public void inform(SolrCore core) {
final SolrResourceLoader solrResourceLoader = core.getResourceLoader();
ManagedTextToVectorModelStore.registerManagedTextToVectorModelStore(solrResourceLoader, this);
TextToVectorModelStore.registerManagedTextToVectorModelStore(solrResourceLoader, this);
}

@Override
public void onManagedResourceInitialized(NamedList<?> args, ManagedResource res)
throws SolrException {
if (res instanceof ManagedTextToVectorModelStore) {
modelStore = (ManagedTextToVectorModelStore) res;
if (res instanceof TextToVectorModelStore) {
modelStore = (TextToVectorModelStore) res;
}
if (modelStore != null) {
modelStore.loadStoredModels();
Expand All @@ -104,16 +104,16 @@ public UpdateRequestProcessor getInstance(
final SchemaField outputFieldSchema = latestSchema.getField(outputField);
assertIsDenseVectorField(outputFieldSchema);

ManagedTextToVectorModelStore modelStore =
ManagedTextToVectorModelStore.getManagedModelStore(req.getCore());
TextToVectorModelStore modelStore =
TextToVectorModelStore.getManagedModelStore(req.getCore());
SolrTextToVectorModel textToVector = modelStore.getModel(modelName);
if (textToVector == null) {
throw new SolrException(
SolrException.ErrorCode.SERVER_ERROR,
"The model configured in the Update Request Processor '"
+ modelName
+ "' can't be found in the store: "
+ ManagedTextToVectorModelStore.REST_END_POINT);
+ TextToVectorModelStore.REST_END_POINT);
}

return new TextToVectorUpdateProcessor(inputField, outputField, textToVector, req, next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import org.apache.commons.io.file.PathUtils;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.languagemodels.store.rest.ManagedTextToVectorModelStore;
import org.apache.solr.languagemodels.store.rest.TextToVectorModelStore;
import org.apache.solr.util.RestTestBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -87,24 +87,24 @@ protected static void afterTest() throws Exception {
}
}

public static void loadModel(String fileName, String status) throws Exception {
public static void loadTextToVectorModel(String fileName, String status) throws Exception {
final URL url =
TestLanguageModelBase.class.getResource("/textToVectorModelExamples/" + fileName);
final String multipleModels = Files.readString(Path.of(url.toURI()), StandardCharsets.UTF_8);

assertJPut(
ManagedTextToVectorModelStore.REST_END_POINT,
TextToVectorModelStore.REST_END_POINT,
multipleModels,
"/responseHeader/status==" + status);
}

public static void loadModel(String fileName) throws Exception {
public static void loadTextToVectorModel(String fileName) throws Exception {
final URL url =
TestLanguageModelBase.class.getResource("/textToVectorModelExamples/" + fileName);
final String multipleModels = Files.readString(Path.of(url.toURI()), StandardCharsets.UTF_8);

assertJPut(
ManagedTextToVectorModelStore.REST_END_POINT, multipleModels, "/responseHeader/status==0");
TextToVectorModelStore.REST_END_POINT, multipleModels, "/responseHeader/status==0");
}

protected static void prepareIndex() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TextToVectorQParserTest extends TestLanguageModelBase {
@BeforeClass
public static void init() throws Exception {
setupTest("solrconfig-language-models.xml", "schema-language-models.xml", true, false);
loadModel("dummy-model.json");
loadTextToVectorModel("dummy-model.json");
}

@AfterClass
Expand Down

This file was deleted.

Loading
Loading