-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce aggregation result footprint #5661
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
quickwit/quickwit-serve/src/elasticsearch_api/model/search_response.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2021-Present Datadog, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use elasticsearch_dsl::{ClusterStatistics, HitsMetadata, ShardStatistics, Suggest}; | ||
use quickwit_search::AggregationResults; | ||
use serde::Serialize; | ||
|
||
type Map<K, V> = std::collections::BTreeMap<K, V>; | ||
|
||
/// Search response | ||
/// | ||
/// This is a fork of [`elasticsearch_dsl::SearchResponse`] with the | ||
/// `aggregations` field using [`AggregationResults`] instead of | ||
/// [`serde_json::Value`]. | ||
#[derive(Debug, Default, Serialize, PartialEq)] | ||
pub struct ElasticsearchResponse { | ||
/// The time that it took Elasticsearch to process the query | ||
pub took: u32, | ||
|
||
/// The search has been cancelled and results are partial | ||
pub timed_out: bool, | ||
|
||
/// Indicates if search has been terminated early | ||
#[serde(default)] | ||
pub terminated_early: Option<bool>, | ||
|
||
/// Scroll Id | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
#[serde(rename = "_scroll_id")] | ||
pub scroll_id: Option<String>, | ||
|
||
/// Dynamically fetched fields | ||
#[serde(default)] | ||
pub fields: Map<String, serde_json::Value>, | ||
|
||
/// Point in time Id | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub pit_id: Option<String>, | ||
|
||
/// Number of reduce phases | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub num_reduce_phases: Option<u64>, | ||
|
||
/// Maximum document score. [None] when documents are implicitly sorted | ||
/// by a field other than `_score` | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub max_score: Option<f32>, | ||
|
||
/// Number of clusters touched with their states | ||
#[serde(skip_serializing_if = "Option::is_none", rename = "_clusters")] | ||
pub clusters: Option<ClusterStatistics>, | ||
|
||
/// Number of shards touched with their states | ||
#[serde(rename = "_shards")] | ||
pub shards: ShardStatistics, | ||
|
||
/// Search hits | ||
pub hits: HitsMetadata, | ||
|
||
/// Search aggregations | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub aggregations: Option<AggregationResults>, | ||
|
||
#[serde(skip_serializing_if = "Map::is_empty", default)] | ||
/// Suggest response | ||
pub suggest: Map<String, Vec<Suggest>>, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah we can ask @PSeitz to make it Deserializable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OwnedValue
is a little bit special, because it needs to to take ownership of the originalString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't it be possible to still make it deserializable by keeping a state in the deserializer, and building a (non-original)
String
with the concatenation of all of the Strings?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that should be possible, but it would require to have a special deserialization logic. Currently it's just a thin wrapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've looked into it and it seemed pretty hairy 😄
Given that we use deserialisation only in one place and that is in the client, I ended up giving up to the dumb solution of having this DTO style object.