Skip to content

Commit

Permalink
added documentation + CR comments (#5111)
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Jun 12, 2024
1 parent 379a752 commit de67160
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
12 changes: 8 additions & 4 deletions docs/reference/es_compatible_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,6 @@ The following query types are supported.
| `analyzer` | String | Analyzer meant to cut the query into terms. It is recommended to NOT use this parameter. | The actual field tokenizer. |




### `match_bool_prefix`

[Elasticsearch reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html)
Expand Down Expand Up @@ -560,11 +558,17 @@ Contrary to ES/Opensearch, in Quickwit, at most 50 terms will be considered when
| Type | Description |
| --------------- | ------------------------------------------------------------------------------------------- |
| `most_fields` | (default) Finds documents which match any field and combines the `_score` from each field. |
| `phrase` | Runs a `match_phrase` query on each field and uses the `_score` from the best field . |
| `phrase_prefix` | Runs a `match_phrase_prefix` query on each field and uses the `_score` from the best field. |
| `phrase` | Runs a `match_phrase` query on each field. |
| `phrase_prefix` | Runs a `match_phrase_prefix` query on each field. |
| `bool_prefix` | Runs a `match_bool_prefix` query on each field. |

:::warning

In `phrase`, `phrase_prefix` and `bool_prefix` modes, Quickwit sums the score of the different fields instead of returns their max.

Also, while Quickwit does not support `best_fields` or `cross_fields`, it will not return an error when presented a `best_fields` or `cross_fields` type. For compatibilility reasons, Quickwit will silently accept these parameters and interpret them as a `most_fields` type.

:::

### `term`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct RangeQueryParams {
lte: Option<JsonLiteral>,
#[serde(default)]
boost: Option<NotNaNf32>,
// Currently NO-OP (see #5109)
#[serde(default)]
format: Option<JsonLiteral>,
}
Expand Down
37 changes: 10 additions & 27 deletions quickwit/quickwit-serve/src/elasticsearch_api/model/search_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,9 @@ 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 @@ -105,12 +86,18 @@ pub struct SearchBody {
pub stored_fields: Option<BTreeSet<String>>,
#[serde(default)]
pub search_after: Vec<serde_json::Value>,

// Ignored values, only here for compatibility with opendashboard.
#[serde(default)]
pub _source: serde::de::IgnoredAny,
#[serde(default)]
pub docvalue_fields: serde::de::IgnoredAny,
#[serde(default)]
pub script_fields: Option<serde_json::Value>,
pub script_fields: serde::de::IgnoredAny,
#[serde(default)]
pub highlight: Option<serde_json::Value>,
pub highlight: serde::de::IgnoredAny,
#[serde(default)]
pub version: Option<bool>,
pub version: serde::de::IgnoredAny,
}

struct FieldSortVecVisitor;
Expand Down Expand Up @@ -289,10 +276,6 @@ mod tests {
let search_body = serde_json::from_str::<SearchBody>(json);
let error_msg = search_body.unwrap_err().to_string();
assert!(error_msg.contains("unknown field `term`"));
assert!(error_msg.contains(
"expected one of `_source`, `docvalue_fields`, `from`, `size`, `query`, `sort`, \
`aggs`, `track_total_hits`, `stored_fields`, `search_after`, `script_fields`, \
`highlight`, `version`"
));
assert!(error_msg.contains("expected one of "));
}
}

0 comments on commit de67160

Please sign in to comment.