dsmiley commented on code in PR #1680:
URL: https://github.com/apache/solr/pull/1680#discussion_r1214296464


##########
solr/core/src/test/org/apache/solr/schema/DenseVectorFieldTest.java:
##########
@@ -456,6 +458,25 @@ public void indexing_correctDocument_shouldBeIndexed() 
throws Exception {
     }
   }
 
+  @Test
+  public void indexing_highDimensionalityVectorDocument_shouldBeIndexed() 
throws Exception {
+    try {
+      initCore("solrconfig-basic.xml", 
"schema-densevector-high-dimensionality.xml");
+
+      List<Float> highDimensionalityVector = new ArrayList<>();
+      for(float i=0; i< 2048f; i++){
+        highDimensionalityVector.add(i);
+      }
+      SolrInputDocument correctDoc = new SolrInputDocument();
+      correctDoc.addField("id", "0");
+      correctDoc.addField("vector", highDimensionalityVector);
+
+      assertU(adoc(correctDoc));

Review Comment:
   And query for it?



##########
solr/core/src/test-files/solr/collection1/conf/schema-densevector-high-dimensionality.xml:
##########
@@ -0,0 +1,52 @@
+<?xml version="1.0" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- Test schema file for DenseVectorField -->
+
+<schema name="schema-densevector" version="1.0">
+  <fieldType name="string" class="solr.StrField" multiValued="true"/>  
+  <fieldType name="knn_vector" class="solr.DenseVectorField" 
vectorDimension="2048" similarityFunction="cosine" />
+  <fieldType name="plong" class="solr.LongPointField" 
useDocValuesAsStored="false"/>
+
+  <fieldType name="knn_vector_byte_encoding" class="solr.DenseVectorField" 
vectorDimension="4" similarityFunction="cosine" vectorEncoding="BYTE"/>

Review Comment:
   Not used?



##########
solr/core/src/java/org/apache/solr/schema/DenseVectorField.java:
##########
@@ -218,22 +238,46 @@ public List<IndexableField> createFields(SchemaField 
field, Object value) {
 
   @Override
   public IndexableField createField(SchemaField field, Object vectorValue) {
+    FieldType denseVectorFieldType = getDenseVectorFieldType();
+
+
     if (vectorValue == null) return null;
     DenseVectorParser vectorBuilder = (DenseVectorParser) vectorValue;
     switch (vectorEncoding) {
       case BYTE:
         return new KnnByteVectorField(
-            field.getName(), vectorBuilder.getByteVector(), 
similarityFunction);
+            field.getName(), vectorBuilder.getByteVector(), 
denseVectorFieldType);
       case FLOAT32:
         return new KnnFloatVectorField(
-            field.getName(), vectorBuilder.getFloatVector(), 
similarityFunction);
+            field.getName(), vectorBuilder.getFloatVector(), 
denseVectorFieldType);
       default:
         throw new SolrException(
             SolrException.ErrorCode.SERVER_ERROR,
             "Unexpected state. Vector Encoding: " + vectorEncoding);
     }
   }
 
+  private FieldType getDenseVectorFieldType() {

Review Comment:
   This turned out to be easier than I thought it would appear :-).
   
   Please add a comment to reflect that this is a **hack** to work around 
Lucene's FloatVectorValues standard dimension check.  Maybe comment it might 
stop working in a future Lucene release.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to