Skip to content

Commit

Permalink
add documents about multi match and match phrase (#3873)
Browse files Browse the repository at this point in the history
* add documents about multi match and match phrase

add documents about multi match query and match phrase query

* Update docs/reference/es_compatible_api.md

Co-authored-by: François Massot <[email protected]>

* Update docs/reference/es_compatible_api.md

Co-authored-by: François Massot <[email protected]>

* Update docs/reference/es_compatible_api.md

Co-authored-by: François Massot <[email protected]>

* Update docs/reference/es_compatible_api.md

Co-authored-by: François Massot <[email protected]>

* Update docs/reference/es_compatible_api.md

Co-authored-by: François Massot <[email protected]>

---------

Co-authored-by: François Massot <[email protected]>
  • Loading branch information
JerryKwan and fmassot authored Sep 26, 2023
1 parent 1219e00 commit b87d82e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 2 deletions.
85 changes: 85 additions & 0 deletions docs/reference/es_compatible_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,24 @@ The following query types are supported.



### `match_phrase`

[Elasticsearch reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.8/query-dsl-match-query-phrase.html)

#### Example

```json
{
"query": {
"match_phrase": {
"title": "search keywords",
"analyzer": "default"
}
}
}
```



### `match_phrase_prefix`

Expand Down Expand Up @@ -398,6 +416,70 @@ Contrary to ES/Opensearch, in Quickwit, at most 50 terms will be considered when
| `operator` | `"AND"` or `"OR"` | Defines whether all terms should be present (`AND`) or if at least one term is sufficient to match (`OR`). | OR |
| `zero_terms_query`| `all` or `none` | Defines if all (`all`) or no documents (`none`) should be returned if the query does not contain any terms after tokenization. | `none` |



### `Multi-match`

[Elasticsearch reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.8/query-dsl-multi-match-query.html)

#### Example
```json
{
"query": {
"multi_match" : {
"query": "search keywords",
"fields": [ "title", "body" ]
}
}
}
```

```json
{
"query": {
"multi_match" : {
"query": "search keywords",
"type": "most_fields",
"fields": [ "title", "body" ]
}
}
}
```

```json
{
"query": {
"multi_match" : {
"query": "search keywords",
"type": "phrase",
"fields": [ "title", "body" ]
}
}
}
```

```json
{
"query": {
"multi_match" : {
"query": "search key",
"type": "phrase_prefix",
"fields": [ "title", "body" ]
}
}
}
```

#### Supported Multi-match Queries
| 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. |




### `term`

[Elasticsearch reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.8/query-dsl-term-query.html)
Expand All @@ -422,6 +504,9 @@ Contrary to ES/Opensearch, in Quickwit, at most 50 terms will be considered when
| `value` | String | Term value. This is the string representation of a token after tokenization. | - |
| `boost` | `Number` | Multiplier boost for score computation | 1.0 |




### `match_all` / `match_none`

[Elasticsearch reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use crate::elastic_query_dsl::ConvertableToQueryAst;
use crate::query_ast::{FullTextMode, FullTextParams, FullTextQuery, QueryAst};
use crate::{MatchAllOrNone, OneFieldMap};

/// `MatchQuery` as defined in
/// <https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html>
/// `MatchPhraseQuery` as defined in
/// <https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html>
#[derive(Deserialize, Clone, Eq, PartialEq, Debug)]
#[serde(
from = "OneFieldMap<MatchPhraseQueryParamsForDeserialization>",
Expand Down

0 comments on commit b87d82e

Please sign in to comment.