Skip to content

Commit

Permalink
SOLR-16807: DenseVectorField breaks '*' copyFields (apache#1651)
Browse files Browse the repository at this point in the history
SOLR-16807: DenseVectorField breaks '*' copyFields
  • Loading branch information
joel-bernstein authored May 23, 2023
1 parent 7a55ce3 commit 5b9cfe1
Show file tree
Hide file tree
Showing 4 changed files with 1,033 additions and 3 deletions.
14 changes: 11 additions & 3 deletions solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public static Document toDocument(
if (copyFields != null) {
used |=
addCopyFields(
schema,
vectorValue,
sfield.getType(),
copyFields,
Expand All @@ -223,6 +224,7 @@ public static Document toDocument(
if (copyFields != null) {
used |=
addCopyFields(
schema,
v,
sfield.getType(),
copyFields,
Expand Down Expand Up @@ -306,6 +308,7 @@ private static boolean addOriginalField(
}

private static boolean addCopyFields(
final IndexSchema schema,
final Object originalFieldValue,
FieldType originalFieldType,
List<CopyField> copyFields,
Expand All @@ -322,9 +325,14 @@ private static boolean addCopyFields(
// Dense Vector Fields can only be copied to same field type
if (originalFieldType instanceof DenseVectorField
&& !(destinationField.getType() instanceof DenseVectorField)) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"The copy field destination must be a DenseVectorField: " + destinationField.getName());
if (schema.getCopySources(destinationField.getName()).contains("*")) {
continue;
} else {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST,
"The copy field destination must be a DenseVectorField: "
+ destinationField.getName());
}
}

// check if the copy field is a multivalued or not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
<field name="string_field" type="string" indexed="true" stored="true" multiValued="false" required="false"/>

<field name="_version_" type="plong" indexed="true" stored="true" multiValued="false" />
<field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
<copyField source="*" dest="_text_"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" words="stopwords.txt" ignoreCase="true"/>
<filter class="solr.SynonymGraphFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

<uniqueKey>id</uniqueKey>
</schema>
Loading

0 comments on commit 5b9cfe1

Please sign in to comment.