Skip to content

Commit 629e533

Browse files
committed
Polishing.
1 parent 29f824c commit 629e533

16 files changed

+371
-468
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/Aggregation.java

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ public static UnwindOperation unwind(String field, String arrayIndex) {
381381
}
382382

383383
/**
384-
* Factory method to create a new {@link UnwindOperation} for the field with the given name, including the name of a new
385-
* field to hold the array index of the element as {@code arrayIndex} using {@code preserveNullAndEmptyArrays}. Note
386-
* that extended unwind is supported in MongoDB version 3.2+.
384+
* Factory method to create a new {@link UnwindOperation} for the field with the given name, including the name of a
385+
* new field to hold the array index of the element as {@code arrayIndex} using {@code preserveNullAndEmptyArrays}.
386+
* Note that extended unwind is supported in MongoDB version 3.2+.
387387
*
388388
* @param field must not be {@literal null} or empty.
389389
* @param arrayIndex must not be {@literal null} or empty.
@@ -428,6 +428,20 @@ public static StartWithBuilder graphLookup(String fromCollection) {
428428
return GraphLookupOperation.builder().from(fromCollection);
429429
}
430430

431+
/**
432+
* Creates a new {@link VectorSearchOperation} by starting from the {@code indexName} to use.
433+
*
434+
* @param indexName must not be {@literal null} or empty.
435+
* @return new instance of {@link VectorSearchOperation.PathContributor}.
436+
* @since 4.5
437+
*/
438+
public static VectorSearchOperation.PathContributor vectorSearch(String indexName) {
439+
440+
Assert.hasText(indexName, "Index name must not be null or empty");
441+
442+
return VectorSearchOperation.search(indexName);
443+
}
444+
431445
/**
432446
* Factory method to create a new {@link SortOperation} for the given {@link Sort}.
433447
*
@@ -669,14 +683,14 @@ public static LookupOperation lookup(Field from, Field localField, Field foreign
669683

670684
/**
671685
* Entrypoint for creating {@link LookupOperation $lookup} using a fluent builder API.
686+
*
672687
* <pre class="code">
673-
* Aggregation.lookup().from("restaurants")
674-
* .localField("restaurant_name")
675-
* .foreignField("name")
676-
* .let(newVariable("orders_drink").forField("drink"))
677-
* .pipeline(match(ctx -> new Document("$expr", new Document("$in", List.of("$$orders_drink", "$beverages")))))
678-
* .as("matches")
688+
* Aggregation.lookup().from("restaurants").localField("restaurant_name").foreignField("name")
689+
* .let(newVariable("orders_drink").forField("drink"))
690+
* .pipeline(match(ctx -> new Document("$expr", new Document("$in", List.of("$$orders_drink", "$beverages")))))
691+
* .as("matches")
679692
* </pre>
693+
*
680694
* @return new instance of {@link LookupOperationBuilder}.
681695
* @since 4.1
682696
*/

0 commit comments

Comments
 (0)