From 0033d29b1319b4d9aee928145a46c7a56d3bff21 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Wed, 8 May 2019 11:33:17 -0400 Subject: [PATCH 01/10] [DOCS] Rewrite prefix query docs --- .../reference/query-dsl/prefix-query.asciidoc | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 54d69583e990c..d3b46ec56dcb6 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -1,33 +1,52 @@ [[query-dsl-prefix-query]] === Prefix Query +Returns documents that contain a specific prefix in a provided field. -Matches documents that have fields containing terms with a specified -prefix (*not analyzed*). The prefix query maps to Lucene `PrefixQuery`. -The following matches documents where the user field contains a term -that starts with `ki`: +[[prefix-query-ex-request]] +==== Example request + +The following search returns documents where the `user` field contains a term +that begins with `ki`. [source,js] --------------------------------------------------- +---- GET /_search -{ "query": { - "prefix" : { "user" : "ki" } - } +{ + "query": { + "prefix": { + "user": { + "value": "ki", + "boost": 1.0, + "rewrite:" "constant_score" + } + } + } } --------------------------------------------------- +---- // CONSOLE -A boost can also be associated with the query: +[[prefix-query-top-level-params]] +==== Top-level parameters for `term` +``:: +Field you wish to search. -[source,js] --------------------------------------------------- -GET /_search -{ "query": { - "prefix" : { "user" : { "value" : "ki", "boost" : 2.0 } } - } -} --------------------------------------------------- -// CONSOLE +[[prefix-query-field-params]] +==== Parameters for `` +`value`:: +Beginning characters of terms you wish to find in the provided ``. + +`boost`:: +Floating point number used to decrease or increase the +<> of a query. Default is `1.0`. +Optional. ++ +You can use the `boost` parameter to adjust relevance scores for searches +containing two or more queries. ++ +Boost values are relative to the default value of `1.0`. A boost value between +`0` and `1.0` decreases the relevance score. A value greater than `1.0` +increases the relevance score. -This multi term query allows you to control how it gets rewritten using the -<> -parameter. +`rewrite` (Expert):: +Method used to rewrite the query to improve performance. For valid values, +see the <>. Optional. \ No newline at end of file From b5fef4b17fb987a3f4b39a01ae48e9883a811f4c Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Wed, 8 May 2019 12:09:43 -0400 Subject: [PATCH 02/10] [DOCS] Fix snippet typo --- docs/reference/query-dsl/prefix-query.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index d3b46ec56dcb6..56a9e039f0073 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -17,7 +17,7 @@ GET /_search "user": { "value": "ki", "boost": 1.0, - "rewrite:" "constant_score" + "rewrite": "constant_score" } } } From 2df6725b45eb90dd2ba983c7e0dab655bce15d80 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Fri, 10 May 2019 09:21:54 -0400 Subject: [PATCH 03/10] [DOCS] Revise 'rewrite' parameter --- docs/reference/query-dsl/prefix-query.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 56a9e039f0073..8b997ef9858aa 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -48,5 +48,5 @@ Boost values are relative to the default value of `1.0`. A boost value between increases the relevance score. `rewrite` (Expert):: -Method used to rewrite the query to improve performance. For valid values, -see the <>. Optional. \ No newline at end of file +Method used to rewrite the query. For valid values and more information, see the +<>. Optional. \ No newline at end of file From 5caf2b0d499cbddf47d4983db5aab4cb56ece60b Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Fri, 28 Jun 2019 09:57:03 -0400 Subject: [PATCH 04/10] Remove generic boost parm documentation --- docs/reference/query-dsl/prefix-query.asciidoc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 8b997ef9858aa..35f3381e4009b 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -16,7 +16,6 @@ GET /_search "prefix": { "user": { "value": "ki", - "boost": 1.0, "rewrite": "constant_score" } } @@ -35,18 +34,6 @@ Field you wish to search. `value`:: Beginning characters of terms you wish to find in the provided ``. -`boost`:: -Floating point number used to decrease or increase the -<> of a query. Default is `1.0`. -Optional. -+ -You can use the `boost` parameter to adjust relevance scores for searches -containing two or more queries. -+ -Boost values are relative to the default value of `1.0`. A boost value between -`0` and `1.0` decreases the relevance score. A value greater than `1.0` -increases the relevance score. - `rewrite` (Expert):: Method used to rewrite the query. For valid values and more information, see the <>. Optional. \ No newline at end of file From b34b22d96623adee3b21b64abff9802c0e9647c5 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Tue, 2 Jul 2019 08:54:28 -0400 Subject: [PATCH 05/10] Update parameter docs to better match Elastic API Reference template --- docs/reference/query-dsl/prefix-query.asciidoc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 35f3381e4009b..145c007dbbc2d 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -26,14 +26,15 @@ GET /_search [[prefix-query-top-level-params]] ==== Top-level parameters for `term` -``:: -Field you wish to search. +`` (Required):: +(string) Field you wish to search. [[prefix-query-field-params]] ==== Parameters for `` -`value`:: -Beginning characters of terms you wish to find in the provided ``. +`value` (Required):: +(string) Beginning characters of terms you wish to find in the provided +``. -`rewrite` (Expert):: -Method used to rewrite the query. For valid values and more information, see the -<>. Optional. \ No newline at end of file +`rewrite` (Optional):: +(string) Method used to rewrite the query. For valid values and more +information, see the <>. \ No newline at end of file From 1e6ca49d5fae12064876e683784c3b1a8a03947d Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Mon, 8 Jul 2019 09:27:19 -0400 Subject: [PATCH 06/10] Updates to address feedback --- .../reference/query-dsl/prefix-query.asciidoc | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 145c007dbbc2d..67f001b297a61 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -15,8 +15,7 @@ GET /_search "query": { "prefix": { "user": { - "value": "ki", - "rewrite": "constant_score" + "value": "ki" } } } @@ -25,7 +24,7 @@ GET /_search // CONSOLE [[prefix-query-top-level-params]] -==== Top-level parameters for `term` +==== Top-level parameters for `prefix` `` (Required):: (string) Field you wish to search. @@ -37,4 +36,23 @@ GET /_search `rewrite` (Optional):: (string) Method used to rewrite the query. For valid values and more -information, see the <>. \ No newline at end of file +information, see the <>. + +[[prefix-query-notes]] +==== Notes + +[[prefix-query-short-ex]] +===== Short request Example +You can shorten `prefix` searches by combining the `` and `value` +parameters. For example: + +[source,js] +---- +GET /_search +{ + "query": { + "prefix" : { "user" : "ki" } + } +} +---- +// CONSOLE \ No newline at end of file From d58de5927517fc02548e9b7ce7db1727b1829978 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Mon, 8 Jul 2019 09:29:41 -0400 Subject: [PATCH 07/10] Fix typo --- docs/reference/query-dsl/prefix-query.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 67f001b297a61..daea5640172e3 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -42,7 +42,7 @@ information, see the <>. ==== Notes [[prefix-query-short-ex]] -===== Short request Example +===== Short request example You can shorten `prefix` searches by combining the `` and `value` parameters. For example: From b20e099fbbd67f196ce896969ccff2844d2b4564 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Wed, 10 Jul 2019 11:44:53 -0400 Subject: [PATCH 08/10] Add section for `index_prefixes`. Revise short request wording. --- docs/reference/query-dsl/prefix-query.asciidoc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index daea5640172e3..5676a37912da2 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -43,8 +43,8 @@ information, see the <>. [[prefix-query-short-ex]] ===== Short request example -You can shorten `prefix` searches by combining the `` and `value` -parameters. For example: +You can simplify the `prefix` query syntax by combining the `` and +`value` parameters. For example: [source,js] ---- @@ -55,4 +55,11 @@ GET /_search } } ---- -// CONSOLE \ No newline at end of file +// CONSOLE + +[[prefix-query-index-prefixes]] +===== Speed up prefix queries +You can speed up prefix queries using the <> +mapping parameter. If enabled, {es} indexes prefixes between 2 and 5 +characters in a separate field. This lets {es} run prefix queries more +efficiently at the cost of a larger index. \ No newline at end of file From 9b793070e054acea4cc17c64ec65090dd6a06224 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Mon, 22 Jul 2019 10:12:14 -0400 Subject: [PATCH 09/10] [DOCS] Update parameter format --- docs/reference/query-dsl/prefix-query.asciidoc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 5676a37912da2..c6ff5af169193 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -25,17 +25,17 @@ GET /_search [[prefix-query-top-level-params]] ==== Top-level parameters for `prefix` -`` (Required):: -(string) Field you wish to search. +``:: +(Required, string) Field you wish to search. [[prefix-query-field-params]] ==== Parameters for `` -`value` (Required):: -(string) Beginning characters of terms you wish to find in the provided -``. +`value`:: +(Required, string) Beginning characters of terms you wish to find in the +provided ``. -`rewrite` (Optional):: -(string) Method used to rewrite the query. For valid values and more +`rewrite`:: +(Optional, string) Method used to rewrite the query. For valid values and more information, see the <>. [[prefix-query-notes]] From 052be94cf3d7412115bf55449e27ac46b5a3f0d1 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Tue, 23 Jul 2019 09:07:43 -0400 Subject: [PATCH 10/10] Correct datatype --- docs/reference/query-dsl/prefix-query.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/query-dsl/prefix-query.asciidoc b/docs/reference/query-dsl/prefix-query.asciidoc index 1d09344cdb19f..25cf0fc5bf8ea 100644 --- a/docs/reference/query-dsl/prefix-query.asciidoc +++ b/docs/reference/query-dsl/prefix-query.asciidoc @@ -30,7 +30,7 @@ GET /_search [[prefix-query-top-level-params]] ==== Top-level parameters for `prefix` ``:: -(Required, string) Field you wish to search. +(Required, object) Field you wish to search. [[prefix-query-field-params]] ==== Parameters for ``