@@ -7,13 +7,68 @@ service Documents {
77 rpc Search (SearchRequest ) returns (SearchResponse ) {}
88}
99
10+ // Document search using a combination of keyword and semantic search.
11+ message HybridRetrieval {
12+ // Overfetch multiplier applied to the requested search limit.
13+ // When set, fetches (limit * search_multiplier) results from each retrieval method
14+ // before reranking, then returns the top `limit` results after reranking.
15+ // Valid range is [1, 100]. Defaults to 1 when unset.
16+ optional int32 search_multiplier = 1 ;
17+
18+ // Which reranker to use to limit results to the desired value.
19+ oneof reranker {
20+ // Use a reranker model to perform the reranking.
21+ RerankerModel reranker_model = 2 ;
22+ // Use RRF to perform the reranking.
23+ ReciprocalRankFusion reciprocal_rank_fusion = 3 ;
24+ }
25+ }
26+
27+ // Document search using keyword matching (sparse embeddings).
28+ message KeywordRetrieval {
29+ // Optional, but always used when doing search across multiple collections.
30+ optional RerankerModel reranker = 1 ;
31+ }
32+
33+ // Document search using semantic similarity (dense embeddings).
34+ message SemanticRetrieval {
35+ // Optional, but always used when doing search across multiple collections.
36+ optional RerankerModel reranker = 1 ;
37+ }
38+
39+ // Configuration for reciprocal rank fusion (RRF) reranking.
40+ message ReciprocalRankFusion {
41+ // The RRF constant k used in the reciprocal rank fusion formula. Defaults to 60.
42+ optional int32 k = 1 ;
43+
44+ // Weight for embedding (dense) search results. Should be between 0 and 1. Defaults to 0.5.
45+ float embedding_weight = 3 ;
46+
47+ // Weight for keyword (sparse) search results. Should be between 0 and 1. Defaults to 0.5.
48+ float text_weight = 4 ;
49+
50+ // Deprecated: Use embedding_weight and text_weight instead.
51+ reserved 2 ;
52+ }
53+
54+ // Configuration for model-based reranking.
55+ message RerankerModel {
56+ // The model to use for reranking. Defaults to standard reranker model.
57+ optional string model = 1 ;
58+
59+ // Instructions for the reranking model. Defaults to generic reranking instructions.
60+ optional string instructions = 2 ;
61+ }
62+
1063// RankingMetric is the metric to use for the search.
64+ // Deprecated: Metric now comes from what is set in the collection creation.
1165enum RankingMetric {
1266 RANKING_METRIC_UNKNOWN = 0 ;
1367 RANKING_METRIC_L2_DISTANCE = 1 ;
1468 RANKING_METRIC_COSINE_SIMILARITY = 2 ;
1569}
1670
71+ // Message that contains settings needed to do a document search.
1772message SearchRequest {
1873 // The query to search for which will be embedded using the
1974 // same embedding model as the one used for the source to query.
@@ -22,14 +77,27 @@ message SearchRequest {
2277 DocumentsSource source = 2 ;
2378 // The number of chunks to return.
2479 // Will always return the top matching chunks.
25- // Optional, defaults to 10
80+ // Optional, defaults to 10.
2681 optional int32 limit = 3 ;
27-
28- // The ranking metric to use for the search. Defaults to RANK_METRIC_L2_DISTANCE.
29- optional RankingMetric ranking_metric = 4 ;
30-
3182 // User-defined instructions to be included in the search query. Defaults to generic search instructions.
3283 optional string instructions = 5 ;
84+
85+ // How to perform the document search. Defaults to HybridRetrieval
86+ oneof retrieval_mode {
87+ HybridRetrieval hybrid_retrieval = 11 ;
88+ SemanticRetrieval semantic_retrieval = 12 ;
89+ KeywordRetrieval keyword_retrieval = 13 ;
90+ }
91+
92+ // Deprecated: Metric now comes from what is set during collection creation.
93+ optional RankingMetric ranking_metric = 4 [deprecated = true ];
94+
95+ // Deprecated: Use retrieval_mode instead
96+ reserved 6 ;
97+ reserved 7 ;
98+ reserved 8 ;
99+ reserved 9 ;
100+ reserved 10 ;
33101}
34102
35103// SearchResponse message contains the results of a document search operation.
0 commit comments