Skip to content

Commit

Permalink
Add missing fields to ES compatible Query API
Browse files Browse the repository at this point in the history
* [_source][1] schema
* [docvalue][2] schema

I've added additional fields as `serde_json::Value` to prevent complex
struct definitions as we won't use them anyway.

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-fields.html#source-filtering
[2]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#docvalue-fields
  • Loading branch information
kuzaxak committed Jun 9, 2024
1 parent c2a2674 commit 62a55a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions quickwit/quickwit-query/src/elastic_query_dsl/range_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub struct RangeQueryParams {
lte: Option<JsonLiteral>,
#[serde(default)]
boost: Option<NotNaNf32>,
#[serde(default)]
format: Option<JsonLiteral>,
}

pub type RangeQuery = OneFieldMap<RangeQueryParams>;
Expand All @@ -53,6 +55,7 @@ impl ConvertableToQueryAst for RangeQuery {
lt,
lte,
boost,
format: _,
} = self.value;
let range_query_ast = crate::query_ast::RangeQuery {
field,
Expand Down
25 changes: 25 additions & 0 deletions quickwit/quickwit-serve/src/elasticsearch_api/model/search_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,28 @@ struct FieldSortParams {
pub date_format: Option<ElasticDateFormat>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct SourceObject {
includes: Option<Vec<String>>,
excludes: Option<Vec<String>>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(untagged)]
pub enum Source {
Bool(bool),
String(String),
List(Vec<String>),
Object(SourceObject),
}

#[derive(Debug, Default, Clone, Deserialize, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct SearchBody {
#[serde(default)]
pub _source: Option<Source>,
#[serde(default)]
pub docvalue_fields: Option<serde_json::Value>,
#[serde(default)]
pub from: Option<u64>,
#[serde(default)]
Expand All @@ -86,6 +105,12 @@ pub struct SearchBody {
pub stored_fields: Option<BTreeSet<String>>,
#[serde(default)]
pub search_after: Vec<serde_json::Value>,
#[serde(default)]
pub script_fields: Option<serde_json::Value>,
#[serde(default)]
pub highlight: Option<serde_json::Value>,
#[serde(default)]
pub version: Option<bool>,
}

struct FieldSortVecVisitor;
Expand Down

0 comments on commit 62a55a2

Please sign in to comment.