-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Update query-string-syntax.asciidoc #46863
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
Changes from all commits
9a071fd
0c6b19f
ae2c159
28dffd4
cbaa328
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -271,12 +271,27 @@ of a sub-query: | |
| If you need to use any of the characters which function as operators in your | ||
| query itself (and not as operators), then you should escape them with | ||
| a leading backslash. For instance, to search for `(1+1)=2`, you would | ||
| need to write your query as `\(1\+1\)\=2`. | ||
| need to write your query as `\(1\+1\)\=2`. When using JSON for the request body, two preceding backslashes (`\\`) are required; the backslash is a reserved escaping character in JSON strings. | ||
|
|
||
| [source,console] | ||
| ---- | ||
| GET /twitter/_search | ||
| Content-Type: application/json | ||
|
|
||
| { | ||
| "query" : { | ||
| "query_string" : { | ||
| "query" : "kimchy\\!", | ||
| "fields" : ["user"] | ||
| } | ||
| } | ||
| } | ||
| ---- | ||
| // TEST[setup:twitter] | ||
|
|
||
| The reserved characters are: `+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /` | ||
|
|
||
| Failing to escape these special characters correctly could lead to a syntax | ||
| error which prevents your query from running. | ||
| Failing to escape these special characters correctly could lead to a syntax error which prevents your query from running. | ||
|
|
||
|
Member
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. I think better than having two notes would be to make the former example even clearer. We could first extend the paragraph with the search for "(1+1)=2" by stating this would apply to keyword-field search mostly ("... to search for wdyt?
Contributor
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. I think a simpler example might illustrate the point better. Maybe something more like this: @AndrewNaguib Let me know if you think that addresses the issue. If so, please feel free to add it to your PR. I think it might also be helpful to move this section higher in the file.
Contributor
Author
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. Thanks @jrodewig and @cbuescher for your response. I believe both of you have provided a much neater way on saying the same information; I will add them to the PR. I have a question tho, do you have internal policies for the documentation that I should be aware of, i.e., is it preferred, for instance, to adopt single example across the topic and so on? Moreover, @jrodewig you were suggesting moving the section in a higher position, I'm not sure where is the appropriate place except right after
Contributor
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. Thank you @AndrewNaguib. We don't have any specific policies about adopting the examples across topics. Generally, you should use an example you feel best fits the context. The I don't feel strongly about relocating the section. Your point about this section following others that mention operators is a good one. Let's just leave the section where it is for now. Thanks again for your work on this.
Contributor
Author
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. Thank you for your suggestions; I've added them. |
||
| NOTE: `<` and `>` can't be escaped at all. The only way to prevent them from | ||
| attempting to create a range query is to remove them from the query string | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.