for editor's review comments
Signed-off-by: alicejw <alicejw@amazon.com>
This commit is contained in:
parent
6f4c75d023
commit
6e65cf2494
|
@ -405,8 +405,8 @@ GET _search
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
Option | Valid values | Description
|
| Option | Valid values | Description |
|
||||||
:--- | :--- | :---
|
:--- | :--- | :--- |
|
||||||
`allow_leading_wildcard` | Boolean | Whether `*` and `?` are allowed as the first character of a search term. The default is true.
|
`allow_leading_wildcard` | Boolean | Whether `*` and `?` are allowed as the first character of a search term. The default is true.
|
||||||
`analyze_wildcard` | Boolean | Whether OpenSearch should attempt to analyze wildcard terms. Some analyzers do a poor job at this task, so the default is false.
|
`analyze_wildcard` | Boolean | Whether OpenSearch should attempt to analyze wildcard terms. Some analyzers do a poor job at this task, so the default is false.
|
||||||
`analyzer` | `standard, simple, whitespace, stop, keyword, pattern, <language>, fingerprint` | The analyzer you want to use for the query. Different analyzers have different character filters, tokenizers, and token filters. The `stop` analyzer, for example, removes stop words (e.g. "an," "but," "this") from the query string.
|
`analyzer` | `standard, simple, whitespace, stop, keyword, pattern, <language>, fingerprint` | The analyzer you want to use for the query. Different analyzers have different character filters, tokenizers, and token filters. The `stop` analyzer, for example, removes stop words (e.g. "an," "but," "this") from the query string.
|
||||||
|
|
|
@ -12,22 +12,22 @@ redirect_from:
|
||||||
|
|
||||||
# Query DSL
|
# Query DSL
|
||||||
|
|
||||||
OpenSearch provides a query domain-specific language (DSL) that you can use to search with more options than a simple search via HTTP request parameter alone. The query DSL uses the HTTP request body, so you can more easily customize your queries to get the exact results that you want.
|
OpenSearch provides a query domain-specific language (DSL) that you can use to search with more options than a simple search with an HTTP request parameter alone. The query DSL uses the HTTP request body, so you can more easily customize your queries to get the exact results that you want.
|
||||||
|
|
||||||
The OpenSearch query DSL provides three query options: term-level queries, full-text queries, and boolean queries. You can even perform more complicated searches by using different elements from each variety to find whatever data you need.
|
The OpenSearch query DSL provides three query options: term-level queries, full-text queries, and boolean queries. You can even perform more complicated searches by using different elements from each variety to find whatever data you need.
|
||||||
|
|
||||||
## DSL Query Types
|
## DSL query types
|
||||||
|
|
||||||
OpenSearch supports two types of queries when you search for data: term-level queries and full-text queries.
|
OpenSearch supports two types of queries when you search for data: term-level queries and full-text queries.
|
||||||
|
|
||||||
The following table describes the differences between them:
|
The following table describes the differences between them.
|
||||||
|
|
||||||
| Metrics | Term-level queries | Full-text queries
|
| Metrics | Term-level queries | Full-text queries
|
||||||
:--- | :--- | :---
|
:--- | :--- | :---
|
||||||
*Query results* | Term-level queries answer which documents match a query. | Full-text queries answer how well the documents match a query.
|
*Query results* | Term-level queries answer which documents match a query. | Full-text queries answer how well the documents match a query.
|
||||||
*Analyzer* | The search term isn't analyzed. This means that the term query searches for your search term as it is. | The search term is analyzed by the same analyzer that was used for the specific field of the document at the time it was indexed. This means that your search term goes through the same analysis process that the document's field did.
|
*Analyzer* | The search term isn't analyzed. This means that the term query searches for your search term as it is. | The search term is analyzed by the same analyzer that was used for the specific field of the document at the time it was indexed. This means that your search term goes through the same analysis process as the document's field.
|
||||||
*Relevance* | Term-level queries simply return documents that match without sorting them based on the relevance score. They still calculate the relevance score, but this score is the same for all the documents that are returned. | Full-text queries calculate a relevance score for each match and sort the results by decreasing order of relevance.
|
*Relevance* | Term-level queries simply return documents that match without sorting them based on the relevance score. They still calculate the relevance score, but this score is the same for all the documents that are returned. | Full-text queries calculate a relevance score for each match and sort the results by decreasing order of relevance.
|
||||||
*Use Case* | Use term-level queries when you want to match exact values such as numbers, dates, tags, and so on, and don't need the matches to be sorted by relevance. | Use full-text queries to match text fields and sort by relevance after taking into account factors like casing and stemming variants.
|
*Use Case* | Use term-level queries when you want to match exact values, such as numbers, dates, tags, and so on, and don't need the matches to be sorted by relevance. | Use full-text queries to match text fields and sort by relevance after taking into account factors like casing and stemming variants.
|
||||||
|
|
||||||
OpenSearch uses a probabilistic ranking framework called Okapi BM25 to calculate relevance scores. To learn more about Okapi BM25, see [Wikipedia](https://en.wikipedia.org/wiki/Okapi_BM25).
|
OpenSearch uses a probabilistic ranking framework called Okapi BM25 to calculate relevance scores. To learn more about Okapi BM25, see [Wikipedia](https://en.wikipedia.org/wiki/Okapi_BM25).
|
||||||
{: .note }
|
{: .note }
|
||||||
|
|
|
@ -214,7 +214,7 @@ The search query “HAMLET” is also searched literally. So, to get a match on
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Term-level query operations
|
# Term-level query operations
|
||||||
|
|
||||||
This section provides examples for term-level query operations that you can use for specific search use cases.
|
This section provides examples for term-level query operations that you can use for specific search use cases.
|
||||||
|
|
||||||
|
@ -309,13 +309,13 @@ You get back documents that match any of the terms.
|
||||||
|
|
||||||
## Terms lookup query (TLQ)
|
## Terms lookup query (TLQ)
|
||||||
|
|
||||||
Use a terms lookup query (TLQ) to retrieve multiple field values in a specific document within a specific index. Use the `terms` operation, and specify the index name, document Id and specify the field you want to look up with the `path` parameter.
|
Use a terms lookup query (TLQ) to retrieve multiple field values in a specific document within a specific index. Use the `terms` operation and specify the index name, document ID and field you want to look up with the `path` parameter.
|
||||||
|
|
||||||
Parameter | Behavior
|
Parameter | Behavior
|
||||||
:--- | :---
|
:--- | :---
|
||||||
`index` | The index name that contains the document that you want search.
|
`index` | The index name that contains the document you want search.
|
||||||
`id` | Specifies the exact document to query for terms.
|
`id` | The exact document to query for terms.
|
||||||
`path` | Specifies the field name for the query.
|
`path` | The field name for the query.
|
||||||
|
|
||||||
To get all the lines from a Shakespeare play for a role (or roles) specified in the index `play-assignments` for the document `42`:
|
To get all the lines from a Shakespeare play for a role (or roles) specified in the index `play-assignments` for the document `42`:
|
||||||
|
|
||||||
|
|
|
@ -124,13 +124,13 @@ PUT _plugins/_security/api/roles/abac
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Use term lookup queries (TLQs) with DLS
|
## Use TLQs with DLS
|
||||||
|
|
||||||
You can perform term lookup queries (TLQs) with document-level security (DLS) using either of two modes: adaptive or filter level. The default mode is adaptive, where OpenSearch automatically switches between Lucene-level or filter-level mode depending on whether or not there is a TLQ. DLS queries that do not contain a TLQ are executed in Lucene-level mode, whereas DLS queries with TLQs are executed in filter-level mode.
|
You can perform TLQs with DLS using either of two modes: adaptive or filter level. The default mode is adaptive, where OpenSearch automatically switches between Lucene-level or filter-level mode depending on whether or not there is a TLQ. DLS queries that do not contain a TLQ are executed in Lucene-level mode, whereas DLS queries with TLQs are executed in filter-level mode.
|
||||||
|
|
||||||
By default, the security plugin detects if a DLS query contains a TLQ or not and chooses the appropriate mode automatically at runtime.
|
By default, the security plugin detects if a DLS query contains a TLQ or not and chooses the appropriate mode automatically at runtime.
|
||||||
|
|
||||||
To learn more about OpenSearch queries, see [Term-level queries](https://opensearch.org/docs/latest/opensearch/query-dsl/term/).
|
To learn more about OpenSearch TLQ, see [Terms lookup query (TLQ)](https://opensearch.org/docs/latest/opensearch/query-dsl/term/#terms-lookup-query-tlq).
|
||||||
|
|
||||||
### How to set the DLS evaluation mode in `opensearch.yml`
|
### How to set the DLS evaluation mode in `opensearch.yml`
|
||||||
|
|
||||||
|
@ -145,5 +145,5 @@ plugins.security.dls.mode: filter-level
|
||||||
| Evaluation mode | Parameter | Description | Usage |
|
| Evaluation mode | Parameter | Description | Usage |
|
||||||
:--- | :--- | :--- | :--- |
|
:--- | :--- | :--- | :--- |
|
||||||
Lucene-level DLS | `lucene-level` | This setting makes all DLS queries apply to the Lucene level. | Lucene-level DLS modifies Lucene queries and data structures directly. This is the most efficient mode but does not allow certain advanced constructs in DLS queries, including TLQs.
|
Lucene-level DLS | `lucene-level` | This setting makes all DLS queries apply to the Lucene level. | Lucene-level DLS modifies Lucene queries and data structures directly. This is the most efficient mode but does not allow certain advanced constructs in DLS queries, including TLQs.
|
||||||
Filter-level DLS | `filter-level` | This setting makes all DLS queries apply to the filter level. | In this mode, OpenSearch applies DLS by modifying queries that OpenSearch receives. This allows for TLQs in DLS queries, but you can only use the `get`, `search`, `mget`, and `msearch` operations to retrieve data from the protected index. Additionally, cross-cluster searches are limited with this mode.
|
Filter-level DLS | `filter-level` | This setting makes all DLS queries apply to the filter level. | In this mode, OpenSearch applies DLS by modifying the queries received. This allows for TLQs in DLS queries, but you can only use the `get`, `search`, `mget`, and `msearch` operations to retrieve data from the protected index. Additionally, cross-cluster searches are limited with this mode.
|
||||||
Adaptive | `adaptive-level` | The default setting that allows OpenSearch to automatically choose the mode. | DLS queries without TLQs are executed in Lucene-level mode, while DLS queries that contain a TLQ are executed in filter-level mode.
|
Adaptive | `adaptive-level` | By default, this setting allows OpenSearch to automatically choose the mode. | DLS queries without TLQs are executed in Lucene-level mode, while DLS queries that contain a TLQ are executed in filter-level mode.
|
||||||
|
|
Loading…
Reference in New Issue