Skip to content

Commit 72806aa

Browse files
Update documentation
fix invalid domain type reference and make sure to include required arguemtns
1 parent 1ac2c9f commit 72806aa

5 files changed

+23
-17
lines changed

src/main/antora/modules/ROOT/pages/mongodb/mongo-search-indexes.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Java::
2525
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
2626
----
2727
VectorIndex index = new VectorIndex("vector_index")
28-
.addVector("plotEmbedding"), vector -> vector.dimensions(1536).similarity(COSINE)) <1>
28+
.addVector("plotEmbedding", vector -> vector.dimensions(1536).similarity(COSINE)) <1>
2929
.addFilter("year"); <2>
3030
3131
mongoTemplate.searchIndexOps(Movie.class) <3>

src/main/antora/modules/ROOT/partials/vector-search-method-annotated-include.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Annotated search methods use the `@VectorSearch` annotation to define parameters
66
----
77
interface CommentRepository extends Repository<Comment, String> {
88
9-
@VectorSearch(indexName = "cos-index", filter = "{country: ?0}")
10-
SearchResults<WithVector> searchAnnotatedByCountryAndEmbeddingWithin(String country, Vector embedding,
9+
@VectorSearch(indexName = "cos-index", filter = "{country: ?0}", limit="100", numCandidates="2000")
10+
SearchResults<Comment> searchAnnotatedByCountryAndEmbeddingWithin(String country, Vector embedding,
1111
Score distance);
1212
13-
@VectorSearch(indexName = "my-index", filter = "{country: ?0}", numCandidates = "#{#limit * 20}",
13+
@VectorSearch(indexName = "my-index", filter = "{country: ?0}", limit="?3", numCandidates = "#{#limit * 20}",
1414
searchType = VectorSearchOperation.SearchType.ANN)
15-
List<WithVector> findAnnotatedByCountryAndEmbeddingWithin(String country, Vector embedding, Score distance, int limit);
15+
List<Comment> findAnnotatedByCountryAndEmbeddingWithin(String country, Vector embedding, Score distance, int limit);
1616
}
1717
----
1818
====

src/main/antora/modules/ROOT/partials/vector-search-method-derived-include.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ MongoDB Search methods must use the `@VectorSearch` annotation to define the ind
66
----
77
interface CommentRepository extends Repository<Comment, String> {
88
9-
@VectorSearch(indexName = "my-index")
10-
SearchResults<Comment> searchByEmbeddingNear(Vector vector, Score score);
9+
@VectorSearch(indexName = "my-index", numCandidates="200")
10+
SearchResults<Comment> searchTop10ByEmbeddingNear(Vector vector, Score score);
1111
12-
@VectorSearch(indexName = "my-index")
13-
SearchResults<Comment> searchByEmbeddingWithin(Vector vector, Range<Similarity> range);
12+
@VectorSearch(indexName = "my-index", numCandidates="200")
13+
SearchResults<Comment> searchTop10ByEmbeddingWithin(Vector vector, Range<Similarity> range);
1414
15-
@VectorSearch(indexName = "my-index")
16-
SearchResults<Comment> searchByCountryAndEmbeddingWithin(String country, Vector vector, Range<Similarity> range);
15+
@VectorSearch(indexName = "my-index", numCandidates="200")
16+
SearchResults<Comment> searchTop10ByCountryAndEmbeddingWithin(String country, Vector vector, Range<Similarity> range);
1717
}
1818
----
1919
====

src/main/antora/modules/ROOT/partials/vector-search-repository-include.adoc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@
44
----
55
interface CommentRepository extends Repository<Comment, String> {
66
7-
@VectorSearch(indexName = "my-index")
7+
@VectorSearch(indexName = "my-index", numCandidates="#{#limit.max() * 20}")
88
SearchResults<Comment> searchByCountryAndEmbeddingNear(String country, Vector vector, Score score,
99
Limit limit);
1010
11-
@VectorSearch(indexName = "my-index")
12-
SearchResults<WithVector> searchAnnotatedByCountryAndEmbeddingWithin(String country, Vector embedding,
11+
@VectorSearch(indexName = "my-index", limit="10", numCandidates="200")
12+
SearchResults<Comment> searchByCountryAndEmbeddingWithin(String country, Vector embedding,
1313
Score score);
1414
1515
}
1616
1717
SearchResults<Comment> results = repository.searchByCountryAndEmbeddingNear("en", Vector.of(…), Score.of(0.9), Limit.of(10));
1818
----
1919
====
20+
21+
[TIP]
22+
====
23+
The MongoDB https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/[vector search aggregation] stage defines a set of required arguments and restrictions.
24+
Please make sure to follow the guidelines and make sure to provide required arguments like `limit`.
25+
====

src/main/antora/modules/ROOT/partials/vector-search-scoring-include.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ The scoring function defaults to `ScoringFunction.unspecified()` as there is no
99
interface CommentRepository extends Repository<Comment, String> {
1010
1111
@VectorSearch(…)
12-
SearchResults<Comment> searchByEmbeddingNear(Vector vector, Score similarity);
12+
SearchResults<Comment> searchTop10ByEmbeddingNear(Vector vector, Score similarity);
1313
1414
@VectorSearch(…)
15-
SearchResults<Comment> searchByEmbeddingNear(Vector vector, Similarity similarity);
15+
SearchResults<Comment> searchTop10ByEmbeddingNear(Vector vector, Similarity similarity);
1616
1717
@VectorSearch(…)
18-
SearchResults<Comment> searchByEmbeddingNear(Vector vector, Range<Similarity> range);
18+
SearchResults<Comment> searchTop10ByEmbeddingNear(Vector vector, Range<Similarity> range);
1919
}
2020
2121
repository.searchByEmbeddingNear(Vector.of(…), Score.of(0.9)); <1>

0 commit comments

Comments
 (0)