Skip to content

Commit

Permalink
Add full-text query documentation (opensearch-project#5428)
Browse files Browse the repository at this point in the history
* Refactor full-text query documentation

Signed-off-by: Fanit Kolchina <[email protected]>

* Add examples and parameter descriptions

Signed-off-by: Fanit Kolchina <[email protected]>

* Add multi-match query

Signed-off-by: Fanit Kolchina <[email protected]>

* Add query string field format

Signed-off-by: Fanit Kolchina <[email protected]>

* Query string examples

Signed-off-by: Fanit Kolchina <[email protected]>

* Add regular expressions and fuzziness

Signed-off-by: Fanit Kolchina <[email protected]>

* Add wildcard and regex warning

Signed-off-by: Fanit Kolchina <[email protected]>

* Added more query string format

Signed-off-by: Fanit Kolchina <[email protected]>

* Added multi-field sections

Signed-off-by: Fanit Kolchina <[email protected]>

* Rewrite minimum should match section

Signed-off-by: Fanit Kolchina <[email protected]>

* Added allow expensive queries section

Signed-off-by: Fanit Kolchina <[email protected]>

* Add simple query string query

Signed-off-by: Fanit Kolchina <[email protected]>

* Small rewrites

Signed-off-by: Fanit Kolchina <[email protected]>

* Add intervals query

Signed-off-by: Fanit Kolchina <[email protected]>

* Include discover in query string syntax

Signed-off-by: Fanit Kolchina <[email protected]>

* Link and index page fix

Signed-off-by: Fanit Kolchina <[email protected]>

* Apply suggestions from code review

Co-authored-by: Melissa Vagi <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>

* Implemented editorial comments

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: Fanit Kolchina <[email protected]>
Signed-off-by: kolchfa-aws <[email protected]>
Co-authored-by: Melissa Vagi <[email protected]>
  • Loading branch information
kolchfa-aws and vagimeli authored Nov 1, 2023
1 parent b5ed6c7 commit 88d06e1
Show file tree
Hide file tree
Showing 25 changed files with 3,527 additions and 526 deletions.
6 changes: 3 additions & 3 deletions _field-types/supported-field-types/flat-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ The flat object field type supports the following queries:
- [Terms set]({{site.url}}{{site.baseurl}}/query-dsl/term/terms-set/)
- [Prefix]({{site.url}}{{site.baseurl}}/query-dsl/term/prefix/)
- [Range]({{site.url}}{{site.baseurl}}/query-dsl/term/range/)
- [Match]({{site.url}}{{site.baseurl}}/query-dsl/full-text/#match)
- [Multi-match]({{site.url}}{{site.baseurl}}/query-dsl/full-text/#multi-match)
- [Match]({{site.url}}{{site.baseurl}}/query-dsl/full-text/match/)
- [Multi-match]({{site.url}}{{site.baseurl}}/query-dsl/full-text/multi-match/)
- [Query string]({{site.url}}{{site.baseurl}}/query-dsl/full-text/query-string/)
- [Simple query string]({{site.url}}{{site.baseurl}}/query-dsl/full-text/#simple-query-string)
- [Simple query string]({{site.url}}{{site.baseurl}}/query-dsl/full-text/simple-query-string/)
- [Exists]({{site.url}}{{site.baseurl}}/query-dsl/term/exists/)

## Limitations
Expand Down
2 changes: 1 addition & 1 deletion _query-dsl/compound/bool.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ redirect_from:
- /query-dsl/query-dsl/compound/bool/
---

# Boolean queries
# Boolean query

A Boolean (`bool`) query can combine several query clauses into one advanced query. The clauses are combined with Boolean logic to find matching documents returned in the results.

Expand Down
2 changes: 1 addition & 1 deletion _query-dsl/compound/boosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ redirect_from:
- /query-dsl/query-dsl/compound/boosting/
---

# Boosting queries
# Boosting query

If you're searching for the word "pitcher", your results may relate to either baseball players or containers for liquids. For a search in the context of baseball, you might want to completely exclude results that contain the words "glass" or "water" by using the `must_not` clause. However, if you want to keep those results but downgrade them in relevance, you can do so with `boosting` queries.

Expand Down
4 changes: 2 additions & 2 deletions _query-dsl/compound/constant-score.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ redirect_from:
- /query-dsl/query-dsl/compound/constant-score/
---

# Constant score queries
# Constant score query

If you need to return documents that contain a certain word regardless of how many times the word appears, you can use a `constant_ score` query. A `constant_score` query wraps a filter query and assigns all documents in the results a relevance score equal to the value of the `boost` parameter. Thus, all returned documents have an equal relevance score, and term frequency/inverse document frequency (TF/IDF) is not considered. Filter queries do not calculate relevance scores. Further, OpenSearch caches frequently used filter queries to improve performance.
If you need to return documents that contain a certain word regardless of how many times the word appears, you can use a `constant_score` query. A `constant_score` query wraps a filter query and assigns all documents in the results a relevance score equal to the value of the `boost` parameter. Thus, all returned documents have an equal relevance score, and term frequency/inverse document frequency (TF/IDF) is not considered. Filter queries do not calculate relevance scores. Further, OpenSearch caches frequently used filter queries to improve performance.

## Example

Expand Down
6 changes: 4 additions & 2 deletions _query-dsl/compound/disjunction-max.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ redirect_from:
- /query-dsl/query-dsl/compound/disjunction-max/
---

# Disjunction max queries
# Disjunction max query

A disjunction max (`dis_max`) query returns any document that matches one or more query clauses. For documents that match multiple query clauses, the relevance score is set to the highest relevance score from all matching query clauses.

Expand All @@ -25,6 +25,7 @@ PUT testindex1/_doc/1
"description": "Top 10 sonnets of England's national poet and the Bard of Avon"
}
```
{% include copy-curl.html %}

```json
PUT testindex1/_doc/2
Expand All @@ -33,8 +34,9 @@ PUT testindex1/_doc/2
"body": "The poems written by various 16-th century poets"
}
```
{% include copy-curl.html %}

Use a `dis_max` query to search for documents that contain the words "Shakespeare works":
Use a `dis_max` query to search for documents that contain the words "Shakespeare poems":

```json
GET testindex1/_search
Expand Down
2 changes: 1 addition & 1 deletion _query-dsl/compound/function-score.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ redirect_from:
- /query-dsl/query-dsl/compound/function-score/
---

# Function score queries
# Function score query

Use a `function_score` query if you need to alter the relevance scores of documents returned in the results. A `function_score` query defines a query and one or more functions that can be applied to all results or subsets of the results to recalculate their relevance scores.

Expand Down
18 changes: 11 additions & 7 deletions _query-dsl/compound/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
layout: default
title: Compound queries
has_children: true
has_toc: false
nav_order: 40
redirect_from:
- /opensearch/query-dsl/compound/index/
- /query-dsl/compound/index/
- /query-dsl/query-dsl/compound/
---

# Compound queries

Compound queries serve as wrappers for multiple leaf or compound clauses either to combine their results or to modify their behavior.

OpenSearch supports the following compound query types:
The following table lists all compound query types.

- **Boolean**: Combines multiple query clauses with Boolean logic. To learn more, see [Boolean queries]({{site.url}}{{site.baseurl}}/opensearch/query-dsl/compound/bool/).
- **Constant score**: Wraps a query or a filter and assigns a constant score to all matching documents. This score is equal to the `boost` value.
- **Disjunction max**: Returns documents that match one or more query clauses. If a document matches multiple query clauses, it is assigned a higher relevance score. The relevance score is calculated using the highest score from any matching clause and, optionally, the scores from the other matching clauses multiplied by the tiebreaker value.
- **Function score**: Recalculates the relevance score of documents that are returned by a query using a function that you define.
- **Boosting**: Changes the relevance score of documents without removing them from the search results. Returns documents that match a `positive` query, but downgrades the relevance of documents in the results that match a `negative` query.
Query type | Description
:--- | :---
[`bool`]({{site.url}}{{site.baseurl}}/query-dsl/compound/bool/) (Boolean)| Combines multiple query clauses with Boolean logic.
[`boosting`]({{site.url}}{{site.baseurl}}/query-dsl/compound/boosting/) | Changes the relevance score of documents without removing them from the search results. Returns documents that match a `positive` query, but downgrades the relevance of documents in the results that match a `negative` query.
[`constant_score`]({{site.url}}{{site.baseurl}}/query-dsl/compound/constant-score/) | Wraps a query or a filter and assigns a constant score to all matching documents. This score is equal to the `boost` value.
[`dis_max`]({{site.url}}{{site.baseurl}}/query-dsl/compound/disjunction-max/) (disjunction max) | Returns documents that match one or more query clauses. If a document matches multiple query clauses, it is assigned a higher relevance score. The relevance score is calculated using the highest score from any matching clause and, optionally, the scores from the other matching clauses multiplied by the tiebreaker value.
[`function_score`]({{site.url}}{{site.baseurl}}/query-dsl/compound/function-score/) | Recalculates the relevance score of documents that are returned by a query using a function that you define.
[`hybrid`]({{site.url}}{{site.baseurl}}/query-dsl/compound/hybrid/) | Combines relevance scores from multiple queries into one score for a given document.
Loading

0 comments on commit 88d06e1

Please sign in to comment.