adamjq commented on code in PR #4698:
URL: https://github.com/apache/solr/pull/4698#discussion_r4106962564


##########
solr/core/src/test/org/apache/solr/schema/ScalarQuantizedDenseVectorFieldTest.java:
##########
@@ -121,18 +129,245 @@ public void 
fieldDefinition_deprecatedDynamicConfidenceInterval_shouldStillLoadS
 
       ScalarQuantizedDenseVectorField vectorType =
           (ScalarQuantizedDenseVectorField) vectorField.getType();
-      assertThat(vectorType.getDimension(), is(4));
-      assertThat(vectorType.getBits(), 
is(ScalarQuantizedDenseVectorField.DEFAULT_BITS));
+      assertThat(vectorType.getConfidenceInterval(), is(0f));
     } finally {
       deleteCore();
     }
   }
 
   @Test
-  public void fieldDefinition_flatAlgorithm_shouldThrowException() throws 
Exception {
-    assertConfigs(
-        "solrconfig-basic.xml",
-        "bad-schema-densevector-flat-scalarQuantized.xml",
-        "knnAlgorithm 'flat' is not supported for 
ScalarQuantizedDenseVectorField");
+  public void fieldDefinition_flatAlgorithm_shouldLoadSchemaField() throws 
Exception {
+    try {
+      initCore("solrconfig_codec.xml", 
"schema-densevector-flat-scalarQuantized.xml");
+      IndexSchema schema = h.getCore().getLatestSchema();
+
+      SchemaField vector = schema.getField("vector_sq_flat");
+      assertNotNull(vector);
+
+      ScalarQuantizedDenseVectorField type = (ScalarQuantizedDenseVectorField) 
vector.getType();
+      assertThat(type.getKnnAlgorithm(), is("flat"));
+      assertThat(type.getDimension(), is(4));
+      assertThat(type.getSimilarityFunction(), 
is(VectorSimilarityFunction.COSINE));
+      assertThat(type.getBits(), 
is(ScalarQuantizedDenseVectorField.DEFAULT_BITS));
+
+      assertTrue(vector.indexed());
+      assertTrue(vector.stored());
+    } finally {
+      deleteCore();
+    }
+  }
+
+  @Test
+  public void 
flatAlgorithm_buildKnnVectorsFormat_shouldReturnScalarQuantizedFormat()
+      throws Exception {
+    try {
+      initCore("solrconfig_codec.xml", 
"schema-densevector-flat-scalarQuantized.xml");
+      IndexSchema schema = h.getCore().getLatestSchema();
+
+      SchemaField vector = schema.getField("vector_sq_flat");
+      ScalarQuantizedDenseVectorField type = (ScalarQuantizedDenseVectorField) 
vector.getType();
+
+      assertThat(
+          type.buildKnnVectorsFormat() instanceof 
Lucene104ScalarQuantizedVectorsFormat, is(true));
+    } finally {
+      deleteCore();
+    }
+  }
+
+  @Test
+  public void flatAlgorithm_vectorSimilarityFunction_shouldReturnResults() 
throws Exception {
+    try {
+      initCore("solrconfig_codec.xml", 
"schema-densevector-flat-scalarQuantized.xml");
+
+      addDoc("0", 1.0f, 2.0f, 3.0f, 4.0f);
+      addDoc("1", 2.0f, 3.0f, 4.0f, 5.0f);
+      addDoc("2", 100.0f, 200.0f, 50.0f, 25.0f);
+
+      assertU(commit());
+
+      assertJQ(
+          req(
+              "q", "{!func}vectorSimilarity(vector_sq_flat,[1.0, 2.0, 3.0, 
4.0])",
+              "fl", "id,score"),
+          "/response/numFound==3",
+          "/response/docs/[0]/id=='0'");

Review Comment:
   Thanks, this is a good idea. I've updated the tests to be more explicit with 
the ordering and number of K values returned. I also added some comments to 
explain why certain results are excluded



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to