You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2026/01/16 00:09:39 UTC
(solr) 04/06: refactor implementation details of LateInteractionVectorField -> StrFloatLateInteractionVectorField such that LateInteractionVectorField is now just a marker interface for the query time support
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch jira/SOLR-17975
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 8b027beacab148a083489429f3bc40d59cf533d5
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Thu Jan 15 15:13:17 2026 -0700
refactor implementation details of LateInteractionVectorField -> StrFloatLateInteractionVectorField such that LateInteractionVectorField is now just a marker interface for the query time support
---
.../solr/schema/LateInteractionVectorField.java | 395 ++-------------------
...ava => StrFloatLateInteractionVectorField.java} | 9 +-
.../org/apache/solr/search/ValueSourceParser.java | 2 +-
.../conf/bad-schema-late-vec-field-indexed.xml | 2 +-
.../conf/bad-schema-late-vec-field-multivalued.xml | 2 +-
.../conf/bad-schema-late-vec-field-nodv.xml | 2 +-
.../conf/bad-schema-late-vec-ft-indexed.xml | 2 +-
.../conf/bad-schema-late-vec-ft-nodim.xml | 2 +-
.../conf/bad-schema-late-vec-ft-nodv.xml | 2 +-
.../conf/bad-schema-late-vec-ft-sim.xml | 2 +-
.../solr/collection1/conf/schema-deprecations.xml | 2 +-
.../conf/schema-inplace-required-field.xml | 2 +-
.../solr/collection1/conf/schema-late-vec.xml | 8 +-
.../test-files/solr/collection1/conf/schema15.xml | 2 +-
.../conf/solrconfig-test-properties.xml | 2 +-
.../solr/configsets/cache-control/conf/schema.xml | 2 +-
.../configsets/cache-control/conf/solrconfig.xml | 2 +-
.../collectionA/conf/schema.xml | 2 +-
.../collectionA/conf/solrconfig.xml | 2 +-
.../schema/TestLateInteractionVectorFieldInit.java | 23 +-
.../solr/search/TestLateInteractionVectors.java | 6 +-
21 files changed, 75 insertions(+), 398 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java b/solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java
index ca50cd748c5..f4083481d4f 100644
--- a/solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java
+++ b/solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java
@@ -16,373 +16,48 @@
*/
package org.apache.solr.schema;
-import static java.util.Optional.ofNullable;
-
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import org.apache.lucene.document.LateInteractionField;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.index.IndexableField;
-import org.apache.lucene.index.VectorSimilarityFunction;
-import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.DoubleValuesSource;
-import org.apache.lucene.search.LateInteractionFloatValuesSource;
-import org.apache.lucene.search.LateInteractionFloatValuesSource.ScoreFunction;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.SortField;
-import org.apache.lucene.util.BytesRef;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.response.TextResponseWriter;
import org.apache.solr.search.FunctionQParser;
-import org.apache.solr.search.QParser;
-import org.apache.solr.search.StrParser;
import org.apache.solr.search.SyntaxError;
-import org.apache.solr.uninverting.UninvertingReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/** nocommit: jdocs */
-public class LateInteractionVectorField extends FieldType {
- private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- public static final String VECTOR_DIMENSION = "vectorDimension";
- public static final String SIMILARITY_FUNCTION = "similarityFunction";
- public static final VectorSimilarityFunction DEFAULT_SIMILARITY =
- VectorSimilarityFunction.EUCLIDEAN;
- public static final String SCORE_FUNCTION = "scoreFunction";
- public static final ScoreFunction DEFAULT_SCORE_FUNCTION = ScoreFunction.SUM_MAX_SIM;
-
- private static final int MUST_BE_TRUE = DOC_VALUES;
- private static final int MUST_BE_FALSE = MULTIVALUED | TOKENIZED | INDEXED | UNINVERTIBLE;
-
- private static String MUST_BE_TRUE_MSG =
- " fields require these properties to be true: " + propertiesToString(MUST_BE_TRUE);
- private static String MUST_BE_FALSE_MSG =
- " fields require these properties to be false: " + propertiesToString(MUST_BE_FALSE);
-
- private int dimension;
- private VectorSimilarityFunction similarityFunction;
- private ScoreFunction scoreFunction;
-
- public LateInteractionVectorField() {
- super();
- }
-
- @Override
- public void init(IndexSchema schema, Map<String, String> args) {
-
- this.dimension =
- ofNullable(args.remove(VECTOR_DIMENSION))
- .map(Integer::parseInt)
- .orElseThrow(
- () ->
- new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- VECTOR_DIMENSION + " is a mandatory parameter"));
-
- this.similarityFunction =
- optionalEnumArg(
- SIMILARITY_FUNCTION,
- args.remove(SIMILARITY_FUNCTION),
- VectorSimilarityFunction.class,
- DEFAULT_SIMILARITY);
- this.scoreFunction =
- optionalEnumArg(
- SCORE_FUNCTION,
- args.remove(SCORE_FUNCTION),
- ScoreFunction.class,
- DEFAULT_SCORE_FUNCTION);
-
- // By the time this method is called, FieldType.setArgs has already set "typical" defaults,
- // and parsed the users explicit options.
- // We need to override those defaults, and error if the user asked for nonsense
-
- this.properties |= MUST_BE_TRUE;
- this.properties &= ~MUST_BE_FALSE;
- if (on(trueProperties, MUST_BE_FALSE)) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR, getClass().getSimpleName() + MUST_BE_FALSE_MSG);
- }
- if (on(falseProperties, MUST_BE_TRUE)) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR, getClass().getSimpleName() + MUST_BE_TRUE_MSG);
- }
-
- super.init(schema, args);
- }
-
- public int getDimension() {
- return dimension;
- }
-
- public VectorSimilarityFunction getSimilarityFunction() {
- return similarityFunction;
- }
-
- public ScoreFunction getScoreFunction() {
- return scoreFunction;
- }
-
- // nocommit: jdocs
- public DoubleValuesSource parseLateInteractionValuesSource(
- final String fieldName, final FunctionQParser fp) throws SyntaxError {
- final String vecStr = fp.parseArg();
- if (null == vecStr || fp.hasMoreArguments()) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- "Invalid number of arguments. Please provide both a field name, and a (String) multi-vector.");
- }
- return new LateInteractionFloatValuesSource(
- fieldName,
- stringToMultiFloatVector(dimension, vecStr),
- getSimilarityFunction(),
- getScoreFunction());
- }
-
- @Override
- protected void checkSupportsDocValues() {
- // No-Op: always supported
- }
-
- @Override
- protected boolean enableDocValuesByDefault() {
- return true;
- }
-
- @Override
- public void checkSchemaField(final SchemaField field) throws SolrException {
- super.checkSchemaField(field);
- if (field.multiValued()) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- getClass().getSimpleName() + " fields can not be multiValued: " + field.getName());
- }
- if (field.indexed()) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- getClass().getSimpleName() + " fields can not be indexed: " + field.getName());
- }
-
- if (!field.hasDocValues()) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- getClass().getSimpleName() + " fields must have docValues: " + field.getName());
- }
- }
-
- /** Not supported: We override createFields. so this should never be called */
- @Override
- public IndexableField createField(SchemaField field, Object value) {
- throw new IllegalStateException("This method should never be called in expected operation");
- }
-
- @Override
- public List<IndexableField> createFields(SchemaField field, Object value) {
- try {
- final ArrayList<IndexableField> fields = new ArrayList<>(2);
-
- if (!CharSequence.class.isInstance(value)) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- getClass().getSimpleName() + " fields require string input: " + field.getName());
- }
- final String valueString = value.toString();
-
- final float[][] multiVec = stringToMultiFloatVector(dimension, valueString);
- fields.add(new LateInteractionField(field.getName(), multiVec));
-
- if (field.stored()) {
- fields.add(new StoredField(field.getName(), valueString));
- }
- return fields;
- } catch (SyntaxError | RuntimeException e) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR,
- "Error while creating field '" + field + "' from value '" + value + "'",
- e);
- }
- }
+/**
+ * This is a marrker interface indicating that a {@link FieldType} supports query time usage as
+ * "late interaction" vector field
+ *
+ * @lucene.internal
+ * @lucene.experimental Not currently intended for implementation by custom FieldTypes
+ */
+public interface LateInteractionVectorField {
+
+ // TODO: Refactor StrFloatLateInteractionVectorField if/when more classes implement this
+ // interface.
+ //
+ // The surface area of this interface is intentionally small to focus on the query time aspects
+ //
+ // If/When we want to add more FieldTypes that implement this interface, we should strongly
+ // consider refactoring some of the StrFloatLateInteractionVectorField internals into an
+ // abstract base class for re-use.
+ //
+ // What that abstract base class should look like (and what should be refactored will largely
+ // depend on *why* more implementations are being added:
+ // - new external representations ? (ie: not a single String)
+ // - new internal implementation ? (ie: int/byte vectors)
- // nocommit: 1/2 public methods that refer to float[][] explicitly
- // nocommit: maybe refactor into an abstraction in case lucene supports byte/int/etc later?
/**
- * nocommit: jdocs, note input must not be null, dimension must be positive
+ * Method used for parsing some type specific query input structure into Value source.
*
- * @lucene.experimental
- */
- public static float[][] stringToMultiFloatVector(final int dimension, final String input)
- throws SyntaxError {
-
- assert 0 < dimension;
- final int lastIndex = dimension - 1;
-
- final List<float[]> result = new ArrayList<>(7);
- final StrParser sp = new StrParser(input);
- sp.expect("["); // outer array
-
- while (sp.pos < sp.end) {
- sp.expect("[");
- final float[] entry = new float[dimension];
- for (int i = 0; i < dimension; i++) {
- final int preFloatPos = sp.pos;
- try {
- entry[i] = sp.getFloat();
- } catch (NumberFormatException e) {
- throw new SyntaxError(
- "Expected float at position " + preFloatPos + " in '" + input + "'", e);
- }
- if (i < lastIndex) {
- sp.expect(",");
- }
- }
-
- sp.expect("]");
- result.add(entry);
-
- if (',' != sp.peek()) {
- // no more entries in outer array
- break;
- }
- sp.expect(",");
- }
- sp.expect("]"); // outer array
-
- sp.eatws();
- if (sp.pos < sp.end) {
- throw new SyntaxError("Unexpected text at position " + sp.pos + " in '" + input + "'");
- }
- return result.toArray(new float[result.size()][]);
- }
-
- // nocommit: 1/2 public methods that refer to float[][] explicitly
- // nocommit: maybe refactor into an abstraction in case lucene supports byte/int/etc later?
- /**
- * nocommit: jdocs, note input must not be null(s), dimensions must be positive
+ * <p>At the time this method is called, the {@link FunctionQParser} will have already been used
+ * to parse the <code>fieldName</code> which will have been resolved to a {@link FieldType} which
+ * must implement this interface
*
- * @lucene.experimental
- */
- public static String multiFloatVectorToString(final float[][] input) {
- assert null != input && 0 < input.length;
- final StringBuilder out =
- new StringBuilder(input.length * 89 /* prime, smallish, ~4 verbose floats */);
- out.append("[");
- for (int i = 0; i < input.length; i++) {
- final float[] currentVec = input[i];
- assert 0 < currentVec.length;
- out.append("[");
- for (int x = 0; x < currentVec.length; x++) {
- out.append(currentVec[x]);
- out.append(",");
- }
- out.replace(out.length() - 1, out.length(), "]");
- out.append(",");
- }
- out.replace(out.length() - 1, out.length(), "]");
- return out.toString();
- }
-
- @Override
- public String toExternal(IndexableField f) {
- String val = f.stringValue();
- if (val == null) {
- val = multiFloatVectorToString(LateInteractionField.decode(f.binaryValue()));
- }
- return val;
- }
-
- @Override
- public UninvertingReader.Type getUninversionType(SchemaField sf) {
- return null;
- }
-
- @Override
- public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException {
- writer.writeStr(name, toExternal(f), false);
- }
-
- @Override
- public Object toObject(SchemaField sf, BytesRef term) {
- return multiFloatVectorToString(LateInteractionField.decode(term));
- }
-
- /** Not supported */
- @Override
- public Query getPrefixQuery(QParser parser, SchemaField sf, String termStr) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- getClass().getSimpleName() + " not supported for prefix queries.");
- }
-
- /** Not supported */
- @Override
- public ValueSource getValueSource(SchemaField field, QParser parser) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- getClass().getSimpleName()
- + " not supported for function queries, use lateVector() function.");
- }
-
- /** Not supported */
- @Override
- public Query getFieldQuery(QParser parser, SchemaField field, String externalVal) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- getClass().getSimpleName()
- + " not supported for field queries, use lateVector() function.");
- }
-
- /** Not Supported */
- @Override
- public Query getRangeQuery(
- QParser parser,
- SchemaField field,
- String part1,
- String part2,
- boolean minInclusive,
- boolean maxInclusive) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- getClass().getSimpleName() + " not supported for range queries.");
- }
-
- /** Not Supported */
- @Override
- public Query getSetQuery(QParser parser, SchemaField field, Collection<String> externalVals) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- getClass().getSimpleName() + " not supported for set queries.");
- }
-
- /** Not Supported */
- @Override
- public SortField getSortField(SchemaField field, boolean top) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- getClass().getSimpleName() + " not supported for sorting.");
- }
-
- /**
- * @param key Config option name, used in exception messages
- * @param value Value specified in configuration, may be <code>null</code>
- * @param clazz Enum class specifying the return type
- * @param defaultValue default to use if value is <code>null</code>
+ * <p>This method should be responsible for whatever type specific argument parsing is neccessary,
+ * and confirm that no invalid (or unexpected "extra") arguments exist in the <code>
+ * FunctionQParser</code>
+ *
+ * <p>(If field types implementing this method need the {@link SchemaField} corrisponding to the
+ * <code>fieldName</code>, they should maintain a reference to the {@link IndexSchema} used to
+ * initialize the <code>FieldType</code> instance.
*/
- private static final <E extends Enum<E>> E optionalEnumArg(
- final String key, final String value, final Class<E> clazz, final E defaultValue)
- throws SolrException {
- try {
- return ofNullable(value)
- .map(v -> Enum.valueOf(clazz, v.toUpperCase(Locale.ROOT)))
- .orElse(defaultValue);
- } catch (IllegalArgumentException e) {
- throw new SolrException(
- SolrException.ErrorCode.SERVER_ERROR, key + " not recognized: " + value);
- }
- }
+ public DoubleValuesSource parseLateInteractionValuesSource(
+ final String fieldName, final FunctionQParser fp) throws SyntaxError;
}
diff --git a/solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java b/solr/core/src/java/org/apache/solr/schema/StrFloatLateInteractionVectorField.java
similarity index 96%
copy from solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java
copy to solr/core/src/java/org/apache/solr/schema/StrFloatLateInteractionVectorField.java
index ca50cd748c5..29da2b6f413 100644
--- a/solr/core/src/java/org/apache/solr/schema/LateInteractionVectorField.java
+++ b/solr/core/src/java/org/apache/solr/schema/StrFloatLateInteractionVectorField.java
@@ -47,7 +47,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** nocommit: jdocs */
-public class LateInteractionVectorField extends FieldType {
+public class StrFloatLateInteractionVectorField extends FieldType
+ implements LateInteractionVectorField {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
public static final String VECTOR_DIMENSION = "vectorDimension";
@@ -69,7 +70,7 @@ public class LateInteractionVectorField extends FieldType {
private VectorSimilarityFunction similarityFunction;
private ScoreFunction scoreFunction;
- public LateInteractionVectorField() {
+ public StrFloatLateInteractionVectorField() {
super();
}
@@ -209,8 +210,6 @@ public class LateInteractionVectorField extends FieldType {
}
}
- // nocommit: 1/2 public methods that refer to float[][] explicitly
- // nocommit: maybe refactor into an abstraction in case lucene supports byte/int/etc later?
/**
* nocommit: jdocs, note input must not be null, dimension must be positive
*
@@ -260,8 +259,6 @@ public class LateInteractionVectorField extends FieldType {
return result.toArray(new float[result.size()][]);
}
- // nocommit: 1/2 public methods that refer to float[][] explicitly
- // nocommit: maybe refactor into an abstraction in case lucene supports byte/int/etc later?
/**
* nocommit: jdocs, note input must not be null(s), dimensions must be positive
*
diff --git a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
index 012aca0fa32..1c2cf28e435 100644
--- a/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
+++ b/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
@@ -1382,7 +1382,7 @@ public abstract class ValueSourceParser implements NamedListInitializedPlugin {
}
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
- "Field name is not defined in schema as a LateInteractionVectorField: "
+ "Field name is not defined in schema as a StrFloatLateInteractionVectorField: "
+ fieldName);
}
});
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-indexed.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-indexed.xml
index 0f9c306cfac..656d8a75b56 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-indexed.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-indexed.xml
@@ -20,7 +20,7 @@
<field name="bad_field" type="late" indexed="true" />
- <fieldType name="late" class="solr.LateInteractionVectorField" vectorDimension="4" />
+ <fieldType name="late" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
<uniqueKey>id</uniqueKey>
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-multivalued.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-multivalued.xml
index 086e3a5d1ee..a5803e61391 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-multivalued.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-multivalued.xml
@@ -20,7 +20,7 @@
<field name="bad_field" type="late" multiValued="true" />
- <fieldType name="late" class="solr.LateInteractionVectorField" vectorDimension="4" />
+ <fieldType name="late" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
<uniqueKey>id</uniqueKey>
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-nodv.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-nodv.xml
index 81ca39a9985..68a0a744628 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-nodv.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-field-nodv.xml
@@ -20,7 +20,7 @@
<field name="bad_field" type="late" docValues="false" />
- <fieldType name="late" class="solr.LateInteractionVectorField" vectorDimension="4" />
+ <fieldType name="late" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="false"/>
<uniqueKey>id</uniqueKey>
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-indexed.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-indexed.xml
index 2676f92dc3d..7cb4545ad68 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-indexed.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-indexed.xml
@@ -18,7 +18,7 @@
<schema name="bad-schema" version="1.7">
- <fieldType name="bad_ft" class="solr.LateInteractionVectorField" vectorDimension="4" indexed="true" multiValued="true" />
+ <fieldType name="bad_ft" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" indexed="true" multiValued="true" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodim.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodim.xml
index 1e1521ba517..9734e3ac7d0 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodim.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodim.xml
@@ -18,7 +18,7 @@
<schema name="bad-schema" version="1.7">
- <fieldType name="bad_ft" class="solr.LateInteractionVectorField" />
+ <fieldType name="bad_ft" class="solr.StrFloatLateInteractionVectorField" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodv.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodv.xml
index 9895b72a31b..91d2e257b7e 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodv.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-nodv.xml
@@ -18,7 +18,7 @@
<schema name="bad-schema" version="1.7">
- <fieldType name="bad_ft" class="solr.LateInteractionVectorField" vectorDimension="4" docValues="false" />
+ <fieldType name="bad_ft" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" docValues="false" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-sim.xml b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-sim.xml
index 6d9bcccbe3b..41c7be6b0cc 100644
--- a/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-sim.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/bad-schema-late-vec-ft-sim.xml
@@ -18,7 +18,7 @@
<schema name="bad-schema" version="1.7">
- <fieldType name="bad_ft" class="solr.LateInteractionVectorField" vectorDimension="4" similarityFunction="bogus" />
+ <fieldType name="bad_ft" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" similarityFunction="bogus" />
<fieldType name="string" class="solr.StrField" multiValued="true"/>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-deprecations.xml b/solr/core/src/test-files/solr/collection1/conf/schema-deprecations.xml
index e50bfa8575c..a44cb99f67f 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-deprecations.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-deprecations.xml
@@ -27,4 +27,4 @@
<field name="_version_" type="long" indexed="false" stored="false"/>
</fields>
-</schema>
\ No newline at end of file
+</schema>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-inplace-required-field.xml b/solr/core/src/test-files/solr/collection1/conf/schema-inplace-required-field.xml
index 2892e5eb39f..5fd1c11e257 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-inplace-required-field.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-inplace-required-field.xml
@@ -32,4 +32,4 @@
<field name="signatureField" type="string" indexed="true" stored="false"/>
<dynamicField name="*_sS" type="string" indexed="true" stored="true"/>
-</schema>
\ No newline at end of file
+</schema>
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-late-vec.xml b/solr/core/src/test-files/solr/collection1/conf/schema-late-vec.xml
index 810cb038225..e68e54decb4 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema-late-vec.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-late-vec.xml
@@ -18,11 +18,11 @@
<schema name="late-vec-schema" version="1.7">
- <fieldType name="late_vec_3_defaults" class="solr.LateInteractionVectorField" vectorDimension="3" />
- <fieldType name="late_vec_4_defaults" class="solr.LateInteractionVectorField" vectorDimension="4" />
+ <fieldType name="late_vec_3_defaults" class="solr.StrFloatLateInteractionVectorField" vectorDimension="3" />
+ <fieldType name="late_vec_4_defaults" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" />
- <fieldType name="late_vec_4_cosine" class="solr.LateInteractionVectorField" vectorDimension="4" similarityFunction="cosine" />
- <fieldType name="late_vec_4_nostored" class="solr.LateInteractionVectorField" vectorDimension="4" stored="false" />
+ <fieldType name="late_vec_4_cosine" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" similarityFunction="cosine" />
+ <fieldType name="late_vec_4_nostored" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" stored="false" />
<field name="lv_3_def" type="late_vec_3_defaults" />
<field name="lv_4_def" type="late_vec_4_defaults" />
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema15.xml b/solr/core/src/test-files/solr/collection1/conf/schema15.xml
index 4e06a94d5ac..87fdad981d6 100644
--- a/solr/core/src/test-files/solr/collection1/conf/schema15.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/schema15.xml
@@ -632,7 +632,7 @@
</fieldType>
<!-- Late Interaction Vectors -->
- <fieldType name="late_vector_4" class="solr.LateInteractionVectorField" vectorDimension="4" />
+ <fieldType name="late_vector_4" class="solr.StrFloatLateInteractionVectorField" vectorDimension="4" />
<field name="late_vec_4" type="late_vector_4" />
<uniqueKey>id</uniqueKey>
diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-test-properties.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-test-properties.xml
index 2a095e0b02a..7fea20f90b3 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-test-properties.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-test-properties.xml
@@ -34,4 +34,4 @@
attr2="${non.existent.sys.prop:default-from-config}">prefix-${solr.test.sys.prop2}-suffix</propTest>
<requestHandler name="/select" class="solr.SearchHandler" />
-</config>
\ No newline at end of file
+</config>
diff --git a/solr/core/src/test-files/solr/configsets/cache-control/conf/schema.xml b/solr/core/src/test-files/solr/configsets/cache-control/conf/schema.xml
index 9d85ec4f7f0..954baf7cfee 100644
--- a/solr/core/src/test-files/solr/configsets/cache-control/conf/schema.xml
+++ b/solr/core/src/test-files/solr/configsets/cache-control/conf/schema.xml
@@ -24,4 +24,4 @@
<field name="id" type="string" indexed="true" stored="true"/>
<dynamicField name="*_s" type="string" indexed="true" stored="true" />
<uniqueKey>id</uniqueKey>
-</schema>
\ No newline at end of file
+</schema>
diff --git a/solr/core/src/test-files/solr/configsets/cache-control/conf/solrconfig.xml b/solr/core/src/test-files/solr/configsets/cache-control/conf/solrconfig.xml
index bd27a88952a..6fb9ca42086 100644
--- a/solr/core/src/test-files/solr/configsets/cache-control/conf/solrconfig.xml
+++ b/solr/core/src/test-files/solr/configsets/cache-control/conf/solrconfig.xml
@@ -51,4 +51,4 @@
<indexConfig>
<mergeScheduler class="${solr.mscheduler:org.apache.lucene.index.ConcurrentMergeScheduler}"/>
: </indexConfig>
-</config>
\ No newline at end of file
+</config>
diff --git a/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/schema.xml b/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/schema.xml
index 0d788eb038a..37692c15943 100644
--- a/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/schema.xml
+++ b/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/schema.xml
@@ -102,4 +102,4 @@
<uniqueKey>id</uniqueKey>
-</schema>
\ No newline at end of file
+</schema>
diff --git a/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/solrconfig.xml b/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/solrconfig.xml
index 52da2f113a5..f190e0d9a7c 100644
--- a/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/solrconfig.xml
+++ b/solr/core/src/test-files/solr/configsets/different-stopwords/collectionA/conf/solrconfig.xml
@@ -55,4 +55,4 @@
</lst>
</requestHandler>
-</config>
\ No newline at end of file
+</config>
diff --git a/solr/core/src/test/org/apache/solr/schema/TestLateInteractionVectorFieldInit.java b/solr/core/src/test/org/apache/solr/schema/TestLateInteractionVectorFieldInit.java
index 4f154ef5b79..e15448bb324 100644
--- a/solr/core/src/test/org/apache/solr/schema/TestLateInteractionVectorFieldInit.java
+++ b/solr/core/src/test/org/apache/solr/schema/TestLateInteractionVectorFieldInit.java
@@ -20,18 +20,21 @@ import java.util.Arrays;
import org.apache.lucene.index.VectorSimilarityFunction;
import org.apache.solr.core.AbstractBadConfigTestBase;
-/** Basic tests of {@link LateInteractionVectorField} FieldType & SchemaField initialization */
+/**
+ * Basic tests of {@link StrFloatLateInteractionVectorField} FieldType & SchemaField
+ * initialization
+ */
public class TestLateInteractionVectorFieldInit extends AbstractBadConfigTestBase {
public void test_bad_ft_opts() throws Exception {
assertConfigs(
"solrconfig-basic.xml",
"bad-schema-late-vec-ft-nodim.xml",
- LateInteractionVectorField.VECTOR_DIMENSION);
+ StrFloatLateInteractionVectorField.VECTOR_DIMENSION);
assertConfigs(
"solrconfig-basic.xml",
"bad-schema-late-vec-ft-sim.xml",
- LateInteractionVectorField.SIMILARITY_FUNCTION);
+ StrFloatLateInteractionVectorField.SIMILARITY_FUNCTION);
assertConfigs(
"solrconfig-basic.xml",
"bad-schema-late-vec-ft-nodv.xml",
@@ -68,17 +71,19 @@ public class TestLateInteractionVectorFieldInit extends AbstractBadConfigTestBas
for (SchemaField sf : Arrays.asList(def3, def4, cosine4, nostored3, nostored4)) {
assertNotNull(sf.getName(), sf);
assertNotNull(sf.getName(), sf.getType());
- assertNotNull(sf.getName(), sf.getType() instanceof LateInteractionVectorField);
+ assertNotNull(sf.getName(), sf.getType() instanceof StrFloatLateInteractionVectorField);
assertTrue(sf.getName(), sf.hasDocValues());
assertFalse(sf.getName(), sf.multiValued());
assertFalse(sf.getName(), sf.indexed());
}
for (SchemaField sf : Arrays.asList(def3, nostored3)) {
- assertEquals(sf.getName(), 3, ((LateInteractionVectorField) sf.getType()).getDimension());
+ assertEquals(
+ sf.getName(), 3, ((StrFloatLateInteractionVectorField) sf.getType()).getDimension());
}
for (SchemaField sf : Arrays.asList(def4, cosine4, nostored4)) {
- assertEquals(sf.getName(), 4, ((LateInteractionVectorField) sf.getType()).getDimension());
+ assertEquals(
+ sf.getName(), 4, ((StrFloatLateInteractionVectorField) sf.getType()).getDimension());
}
for (SchemaField sf : Arrays.asList(def3, def4, cosine4)) {
assertTrue(sf.getName(), sf.stored());
@@ -89,14 +94,14 @@ public class TestLateInteractionVectorFieldInit extends AbstractBadConfigTestBas
for (SchemaField sf : Arrays.asList(def3, def4, nostored3, nostored4)) {
assertEquals(
sf.getName(),
- LateInteractionVectorField.DEFAULT_SIMILARITY,
- ((LateInteractionVectorField) sf.getType()).getSimilarityFunction());
+ StrFloatLateInteractionVectorField.DEFAULT_SIMILARITY,
+ ((StrFloatLateInteractionVectorField) sf.getType()).getSimilarityFunction());
}
assertEquals(
cosine4.getName(),
VectorSimilarityFunction.COSINE,
- ((LateInteractionVectorField) cosine4.getType()).getSimilarityFunction());
+ ((StrFloatLateInteractionVectorField) cosine4.getType()).getSimilarityFunction());
} finally {
deleteCore();
diff --git a/solr/core/src/test/org/apache/solr/search/TestLateInteractionVectors.java b/solr/core/src/test/org/apache/solr/search/TestLateInteractionVectors.java
index 493999c8b83..e0f83936b19 100644
--- a/solr/core/src/test/org/apache/solr/search/TestLateInteractionVectors.java
+++ b/solr/core/src/test/org/apache/solr/search/TestLateInteractionVectors.java
@@ -17,8 +17,8 @@
package org.apache.solr.search;
import static org.apache.lucene.search.LateInteractionFloatValuesSource.ScoreFunction.SUM_MAX_SIM;
-import static org.apache.solr.schema.LateInteractionVectorField.multiFloatVectorToString;
-import static org.apache.solr.schema.LateInteractionVectorField.stringToMultiFloatVector;
+import static org.apache.solr.schema.StrFloatLateInteractionVectorField.multiFloatVectorToString;
+import static org.apache.solr.schema.StrFloatLateInteractionVectorField.stringToMultiFloatVector;
import static org.hamcrest.Matchers.startsWith;
import java.util.Arrays;
@@ -62,7 +62,7 @@ public class TestLateInteractionVectors extends SolrTestCaseJ4 {
EnumSet.allOf(ScoreFunction.class));
}
- public void testStringEncodingAndDecoding() throws Exception {
+ public void testStringFloatEncodingAndDecoding() throws Exception {
final int DIMENSIONS = 4;
// some basic whitespace and int/float equivilences...