* Refactor term query documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Refactor term-level query documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * fix links Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * More examples Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Chris Moore <107723039+cwillum@users.noreply.github.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Add section about expensive queries Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * More editorial feedback Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Chris Moore <107723039+cwillum@users.noreply.github.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
1.9 KiB
layout, title, parent, grand_parent, nav_order
| layout | title | parent | grand_parent | nav_order |
|---|---|---|---|---|
| default | Prefix | Term-level queries | Query DSL | 40 |
Prefix query
Use the prefix query to search for terms that begin with a specific prefix. For example, the following query searches for documents in which the speaker field contains a term that starts with KING H:
GET shakespeare/_search
{
"query": {
"prefix": {
"speaker": "KING H"
}
}
}
{% include copy-curl.html %}
To provide parameters, you can use a query equivalent to the preceding one with the following extended syntax:
GET shakespeare/_search
{
"query": {
"prefix": {
"speaker": {
"value": "KING H"
}
}
}
}
{% include copy-curl.html %}
Parameters
The query accepts the name of the field (<field>) as a top-level parameter:
GET _search
{
"query": {
"prefix": {
"<field>": {
"value": "sample",
...
}
}
}
}
{% include copy-curl.html %}
The <field> accepts the following parameters. All parameters except value are optional.
| Parameter | Data type | Description |
|---|---|---|
value |
String | The term to search for in the field specified in <field>. |
case_insensitive |
Boolean | If true, allows case-insensitive matching of the value with the indexed field values. Default is false (case sensitivity is determined by the field's mapping). |
rewrite |
String | Determines how OpenSearch rewrites and scores multi-term queries. Valid values are constant_score, scoring_boolean, constant_score_boolean, top_terms_N, top_terms_boost_N, and top_terms_blended_freqs_N. Default is constant_score. |
If search.allow_expensive_queries is set to false, prefix queries are not run. If index_prefixes is enabled, the search.allow_expensive_queries setting is ignored and an optimized query is built and run.
{: .important}