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