Skip to content

Commit

Permalink
add list_fields api
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Dec 6, 2023
1 parent 8e775e3 commit 13d3418
Show file tree
Hide file tree
Showing 14 changed files with 1,068 additions and 20 deletions.
55 changes: 55 additions & 0 deletions quickwit/quickwit-proto/protos/quickwit/search.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ service SearchService {
rpc GetKV(GetKVRequest) returns (GetKVResponse);

rpc ReportSplits(ReportSplitsRequest) returns (ReportSplitsResponse);

rpc ListFields(ListFieldsRequest) returns (ListFieldsResponse);

rpc LeafListFields(LeafListFieldsRequest) returns (ListFieldsResponse);
}

/// Scroll Request
Expand Down Expand Up @@ -111,6 +115,57 @@ message ReportSplitsRequest {

message ReportSplitsResponse {}

// -- ListFields -------------------

message ListFieldsRequest{
// Optional limit query to a set of indexes.
repeated string index_id = 1;
// Optional limit query to a set of splits.
repeated string split_id = 2;
// Optional limit query to a list of fields
// Wildcard expressions are supported.
repeated string fields = 3;

// Control if the the request will fail if split_ids contains a split that does not exist.
// optional bool fail_on_missing_index = 3;
}

message LeafListFieldsRequest{
// The index id
string index_id = 1;
// The index uri
string index_uri = 2;
// Index split ids to apply the query on.
// This ids are resolved from the index_uri defined in the search_request.
repeated SplitIdAndFooterOffsets split_offsets = 3;

// Optional limit query to a list of fields
// Wildcard expressions are supported.
repeated string fields = 4;
}

message ListFieldsResponse{
repeated ListFieldsEntryResponse fields = 1;
}

message ListFieldsEntryResponse{
// The field name
string field_name = 1;
// The tantivy field type
int32 field_type = 2;
// The index ids the field exists
repeated string index_ids = 3;
// True means the field is searchable (indexed) in at least some indices.
// False means the field is not searchable in any indices.
bool searchable = 4;
// True means the field is aggregatable (fast) in at least some indices.
// False means the field is not aggregatable in any indices.
bool aggregatable = 5;
// The index ids the field exists, but is not searchable.
repeated string non_searchable_index_ids = 6;
// The index ids the field exists, but is not aggregatable
repeated string non_aggregatable_index_ids = 7;
}

// -- Search -------------------

Expand Down
229 changes: 229 additions & 0 deletions quickwit/quickwit-proto/src/codegen/quickwit/quickwit.search.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions quickwit/quickwit-search/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ quickwit-opentelemetry = { workspace = true }
quickwit-proto = { workspace = true }
quickwit-query = { workspace = true }
quickwit-storage = { workspace = true }
quickwit-indexing = { workspace = true }

[dev-dependencies]
assert-json-diff = { workspace = true }
Expand Down
18 changes: 18 additions & 0 deletions quickwit/quickwit-search/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ impl SearchServiceClient {
}
}

/// Perform leaf search.
pub async fn leaf_list_fields(
&mut self,
request: quickwit_proto::search::LeafListFieldsRequest,
) -> crate::Result<quickwit_proto::search::ListFieldsResponse> {
match &mut self.client_impl {
SearchServiceClientImpl::Grpc(grpc_client) => {
let tonic_request = Request::new(request);
let tonic_response = grpc_client
.leaf_list_fields(tonic_request)
.await
.map_err(|tonic_error| parse_grpc_error(&tonic_error))?;
Ok(tonic_response.into_inner())
}
SearchServiceClientImpl::Local(service) => service.leaf_list_fields(request).await,
}
}

/// Perform leaf stream.
pub async fn leaf_search_stream(
&mut self,
Expand Down
15 changes: 12 additions & 3 deletions quickwit/quickwit-search/src/cluster_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use base64::Engine;
use futures::future::ready;
use futures::{Future, StreamExt};
use quickwit_proto::search::{
FetchDocsRequest, FetchDocsResponse, GetKvRequest, LeafListTermsRequest, LeafListTermsResponse,
LeafSearchRequest, LeafSearchResponse, LeafSearchStreamRequest, LeafSearchStreamResponse,
PutKvRequest,
FetchDocsRequest, FetchDocsResponse, GetKvRequest, LeafListFieldsRequest, LeafListTermsRequest,
LeafListTermsResponse, LeafSearchRequest, LeafSearchResponse, LeafSearchStreamRequest,
LeafSearchStreamResponse, ListFieldsResponse, PutKvRequest,
};
use tantivy::aggregation::intermediate_agg_result::IntermediateAggregationResults;
use tokio::sync::mpsc::error::SendError;
Expand Down Expand Up @@ -112,6 +112,15 @@ impl ClusterClient {
response_res
}

/// Leaf search with retry on another node client.
pub async fn leaf_list_fields(
&self,
request: LeafListFieldsRequest,
mut client: SearchServiceClient,
) -> crate::Result<ListFieldsResponse> {
client.leaf_list_fields(request.clone()).await
}

/// Leaf search stream with retry on another node client.
pub async fn leaf_search_stream(
&self,
Expand Down
Loading

0 comments on commit 13d3418

Please sign in to comment.