Skip to content

Commit

Permalink
Adjust testVectorSearch sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
cindy-peng committed Oct 31, 2024
1 parent 9694abb commit f267339
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions com/google/datastore/snippets/ConceptsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -731,20 +731,6 @@ public void testInequalitySortInvalidNotFirst() {
assertInvalidQuery(query);
}

@Test
public void testVectorSearch() {
setUpQueryTests();
// [START datastore_vector_search]
VectorValue vectorValue = VectorValue.newBuilder(1.78, 2.56, 3.88).build();
FindNearest vectorQuery =
new FindNearest(
"vector_property", vectorValue, FindNearest.DistanceMeasure.COSINE, 1, "distance");

Query<Entity> query = Query.newEntityQueryBuilder().setFindNearest(vectorQuery).build();
// [END datastore_vector_search]
assertValidQuery(query);
}

@Test
public void testLimit() {
setUpQueryTests();
Expand Down Expand Up @@ -1212,4 +1198,18 @@ public void testStaleReads() throws InterruptedException {
// [END datastore_stale_read]
assertValidQueryRealBackend(query);
}

@Test
public void testVectorSearch() {
setUpQueryTests();
// [START datastore_vector_search]
VectorValue vectorValue = VectorValue.newBuilder(1.78, 2.56, 3.88).build();
FindNearest vectorQuery =
new FindNearest(
"vector_property", vectorValue, FindNearest.DistanceMeasure.COSINE, 1, "distance");

Query<Entity> query = Query.newEntityQueryBuilder().setFindNearest(vectorQuery).build();
// [END datastore_vector_search]
assertValidQuery(query);
}
}

0 comments on commit f267339

Please sign in to comment.