Skip to content

Commit

Permalink
Merge branch 'main' of github.com:samoii/quickwit into aws-s3-sse
Browse files Browse the repository at this point in the history
  • Loading branch information
samoii committed Sep 29, 2024
2 parents d9c4b8b + efac619 commit 6ef96ad
Show file tree
Hide file tree
Showing 21 changed files with 571 additions and 105 deletions.
3 changes: 2 additions & 1 deletion docs/reference/es_compatible_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ If a parameter appears both as a query string parameter and in the JSON payload,
| `size` | `Integer` | Number of hits to return. | 10 |
| `sort` | `String` | Describes how documents should be ranked. See [Sort order](#sort-order) | (Optional) |
| `scroll` | `Duration` | Creates a scroll context for "time to live". See [Scroll](#_scroll--scroll-api). | (Optional) |
| `allow_partial_search_results` | `Boolean` | Returns a partial response if some (but not all) of the split searches were unsuccessful. | `true` |

#### Supported Request Body parameters

Expand Down Expand Up @@ -301,7 +302,7 @@ GET api/v1/_elastic/_cat/indices

Use the [cat indices API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html) to get the following information for each index in a cluster:
* Shard count
* Document count
* Document count
* Deleted document count
* Primary store size
* Total store size
Expand Down
8 changes: 6 additions & 2 deletions monitoring/grafana/dashboards/searchers.json
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@
"text": "All",
"value": "$__all"
},
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"definition": "label_values(quickwit_search_leaf_searches_splits_total,instance)",
"hide": 0,
"includeAll": true,
Expand All @@ -861,16 +865,16 @@
"name": "instance",
"options": [],
"query": {
"qryType": 1,
"query": "label_values(quickwit_search_leaf_searches_splits_total,instance)",
"refId": "PrometheusVariableQueryEditor-VariableQuery"
"refId": "StandardVariableQuery"
},
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"type": "query"
}

]
},
"time": {
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-cli/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ pub async fn local_search_cli(args: LocalSearchArgs) -> anyhow::Result<()> {
format: BodyFormat::Json,
sort_by,
count_all: CountHits::CountAll,
allow_failed_splits: false,
};
let search_request =
search_request_from_api_request(vec![args.index_id], search_request_query_string)?;
Expand Down
32 changes: 24 additions & 8 deletions quickwit/quickwit-proto/protos/quickwit/search.proto
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ message ListFieldsRequest {
// Optional limit query to a list of fields
// Wildcard expressions are supported.
repeated string fields = 2;

// Time filter, expressed in seconds since epoch.
// That filter is to be interpreted as the semi-open interval:
// [start_timestamp, end_timestamp).
optional int64 start_timestamp = 3;
optional int64 end_timestamp = 4;

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

Expand All @@ -149,7 +149,7 @@ message LeafListFieldsRequest {
// Optional limit query to a list of fields
// Wildcard expressions are supported.
repeated string fields = 4;

}

message ListFieldsResponse {
Expand Down Expand Up @@ -299,6 +299,17 @@ message SearchResponse {

// Scroll Id (only set if scroll_secs was set in the request)
optional string scroll_id = 6;

// Returns the list of splits for which search failed.
// For the moment, the cause is unknown.
//
// It is up to the caller to decide whether to interpret
// this as an overall failure or to present the partial results
// to the end user.
repeated SplitSearchError failed_splits = 7;

// Total number of successful splits searched.
uint64 num_successful_splits = 8;
}

message SearchPlanResponse {
Expand Down Expand Up @@ -340,7 +351,7 @@ message LeafSearchRequest {
message LeafRequestRef {
// The ordinal of the doc_mapper in `LeafSearchRequest.doc_mappers`
uint32 doc_mapper_ord = 1;

// The ordinal of the index uri in LeafSearchRequest.index_uris
uint32 index_uri_ord = 2;

Expand Down Expand Up @@ -453,10 +464,16 @@ message LeafSearchResponse {
// The list of splits that failed. LeafSearchResponse can be an aggregation of results, so there may be multiple.
repeated SplitSearchError failed_splits = 3;

// Total number of splits the leaf(s) were in charge of.
// num_attempted_splits = num_successful_splits + num_failed_splits.
// Total number of attempt to search into splits.
// We do have:
// `num_splits_requested == num_successful_splits + num_failed_splits.len()`
// But we do not necessarily have:
// `num_splits_requested = num_attempted_splits because of retries.`
uint64 num_attempted_splits = 4;

// Total number of successful splits searched.
uint64 num_successful_splits = 7;

// Deprecated json serialized intermediate aggregation_result.
reserved 5;

Expand Down Expand Up @@ -550,8 +567,7 @@ message LeafListTermsResponse {
// The list of splits that failed. LeafSearchResponse can be an aggregation of results, so there may be multiple.
repeated SplitSearchError failed_splits = 3;

// Total number of splits the leaf(s) were in charge of.
// num_attempted_splits = num_successful_splits + num_failed_splits.
// Total number of single split search attempted.
uint64 num_attempted_splits = 4;
}

Expand Down
24 changes: 20 additions & 4 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.

69 changes: 48 additions & 21 deletions quickwit/quickwit-search/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use std::fmt;
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;
use std::time::{Duration, Instant};

use bytesize::ByteSize;
use futures::{StreamExt, TryStreamExt};
Expand All @@ -37,6 +37,7 @@ use tower::timeout::Timeout;
use tracing::{info_span, warn, Instrument};

use crate::error::parse_grpc_error;
use crate::metrics::SEARCH_METRICS;
use crate::SearchService;

/// Impl is an enumeration that meant to manage Quickwit's search service client types.
Expand Down Expand Up @@ -110,35 +111,61 @@ impl SearchServiceClient {
&mut self,
request: quickwit_proto::search::SearchRequest,
) -> crate::Result<quickwit_proto::search::SearchResponse> {
match &mut self.client_impl {
SearchServiceClientImpl::Grpc(grpc_client) => {
let tonic_request = Request::new(request);
let tonic_response = grpc_client
.root_search(tonic_request)
.await
.map_err(|tonic_error| parse_grpc_error(&tonic_error))?;
Ok(tonic_response.into_inner())
}
let start = Instant::now();
let response_result = match &mut self.client_impl {
SearchServiceClientImpl::Grpc(grpc_client) => grpc_client
.root_search(request)
.await
.map(|tonic_response| tonic_response.into_inner())
.map_err(|tonic_error| parse_grpc_error(&tonic_error)),
SearchServiceClientImpl::Local(service) => service.root_search(request).await,
}
};
let elapsed = start.elapsed().as_secs_f64();
let label_values = if response_result.is_ok() {
["success"]
} else {
["error"]
};
SEARCH_METRICS
.root_search_requests_total
.with_label_values(label_values)
.inc();
SEARCH_METRICS
.root_search_request_duration_seconds
.with_label_values(label_values)
.observe(elapsed);
response_result
}

/// Perform leaf search.
pub async fn leaf_search(
&mut self,
request: quickwit_proto::search::LeafSearchRequest,
) -> crate::Result<quickwit_proto::search::LeafSearchResponse> {
match &mut self.client_impl {
SearchServiceClientImpl::Grpc(grpc_client) => {
let tonic_request = Request::new(request);
let tonic_response = grpc_client
.leaf_search(tonic_request)
.await
.map_err(|tonic_error| parse_grpc_error(&tonic_error))?;
Ok(tonic_response.into_inner())
}
let start = Instant::now();
let response_result = match &mut self.client_impl {
SearchServiceClientImpl::Grpc(grpc_client) => grpc_client
.leaf_search(request)
.await
.map(|tonic_response| tonic_response.into_inner())
.map_err(|tonic_error| parse_grpc_error(&tonic_error)),
SearchServiceClientImpl::Local(service) => service.leaf_search(request).await,
}
};
let elapsed = start.elapsed().as_secs_f64();
let label_values = if response_result.is_ok() {
["success"]
} else {
["error"]
};
SEARCH_METRICS
.leaf_search_requests_total
.with_label_values(label_values)
.inc();
SEARCH_METRICS
.leaf_search_request_duration_seconds
.with_label_values(label_values)
.observe(elapsed);
response_result
}

/// Perform leaf search.
Expand Down
Loading

0 comments on commit 6ef96ad

Please sign in to comment.