-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[DOCS] Rewrite prefix
query docs
#41955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0033d29
[DOCS] Rewrite prefix query docs
jrodewig b5fef4b
[DOCS] Fix snippet typo
jrodewig 2df6725
[DOCS] Revise 'rewrite' parameter
jrodewig 5caf2b0
Remove generic boost parm documentation
jrodewig b34b22d
Update parameter docs to better match Elastic API Reference template
jrodewig 1e6ca49
Updates to address feedback
jrodewig d58de59
Fix typo
jrodewig b20e099
Add section for `index_prefixes`. Revise short request wording.
jrodewig 9b79307
[DOCS] Update parameter format
jrodewig 73b4c7a
Merge branch 'master' into prefix-query-rewrite
jrodewig 052be94
Correct <field> datatype
jrodewig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
[[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", | ||
"rewrite": "constant_score" | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
---- | ||
// CONSOLE | ||
|
||
A boost can also be associated with the query: | ||
[[prefix-query-top-level-params]] | ||
==== Top-level parameters for `term` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be "prefix" instead of "term"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Copy/paste error. Fixed with 1e6ca49. |
||
`<field>` (Required):: | ||
(string) Field you wish to search. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
GET /_search | ||
{ "query": { | ||
"prefix" : { "user" : { "value" : "ki", "boost" : 2.0 } } | ||
} | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
[[prefix-query-field-params]] | ||
==== Parameters for `<field>` | ||
`value` (Required):: | ||
(string) Beginning characters of terms you wish to find in the provided | ||
`<field>`. | ||
|
||
This multi term query allows you to control how it gets rewritten using the | ||
<<query-dsl-multi-term-rewrite,rewrite>> | ||
parameter. | ||
`rewrite` (Optional):: | ||
(string) Method used to rewrite the query. For valid values and more | ||
information, see the <<query-dsl-multi-term-rewrite, `rewrite` parameter>>. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this parameter should be included in the "default" example since IMHO its pretty much an advanced parameter and mentioned later (also,
constant_score
should be the default, so not necessary here).Did you consider also documenting the previous "short" form or do we want to discourage ppl. from using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question!
I've been using the longer form requests because it's easier to delineate additional parameters. This is less of an issue with the
prefix
query, but I used the longer form so it's consistent with other queries. However, I'm open to changing this if wanted.I've removed the
rewrite
parameter and added a "short request example" with 1e6ca49 and d58de59.