Skip to content

Commit

Permalink
[7.17] [DOCS] Adds content on nested queries (#146829) (#146831)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `7.17`:
- [[DOCS] Adds content on nested queries
(#146829)](#146829)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"gchaps","email":"33642766+gchaps@users.noreply.github.com"},"sourceCommit":{"committedDate":"2022-12-01T22:11:28Z","message":"[DOCS]
Adds content on nested queries (#146829)\n\n## Summary\r\n\r\nThis PR
adds content on nested
queries.\r\n\r\nPreview:\r\n\r\n[https://kibana_146829.docs-preview.app.elstc.co/guide/en/kibana/master/kuery-query.html](https://kibana_146829.docs-preview.app.elstc.co/guide/en/kibana/master/kuery-query.html)","sha":"f95414f76ff7574a8ef02a9013591994eb2e7bdb","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Docs","v8.0.0","release_note:skip","v8.1.0","v7.17.0","v8.2.0","v8.3.0","v8.4.0","v8.5.0","v8.6.0","v8.7.0"],"number":146829,"url":"https://github.com/elastic/kibana/pull/146829","mergeCommit":{"message":"[DOCS]
Adds content on nested queries (#146829)\n\n## Summary\r\n\r\nThis PR
adds content on nested
queries.\r\n\r\nPreview:\r\n\r\n[https://kibana_146829.docs-preview.app.elstc.co/guide/en/kibana/master/kuery-query.html](https://kibana_146829.docs-preview.app.elstc.co/guide/en/kibana/master/kuery-query.html)","sha":"f95414f76ff7574a8ef02a9013591994eb2e7bdb"}},"sourceBranch":"main","suggestedTargetBranches":["8.0","8.1","7.17","8.2","8.3","8.4","8.5","8.6"],"targetPullRequestStates":[{"branch":"8.0","label":"v8.0.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.1","label":"v8.1.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"7.17","label":"v7.17.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.2","label":"v8.2.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.3","label":"v8.3.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.4","label":"v8.4.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.5","label":"v8.5.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146829","number":146829,"mergeCommit":{"message":"[DOCS]
Adds content on nested queries (#146829)\n\n## Summary\r\n\r\nThis PR
adds content on nested
queries.\r\n\r\nPreview:\r\n\r\n[https://kibana_146829.docs-preview.app.elstc.co/guide/en/kibana/master/kuery-query.html](https://kibana_146829.docs-preview.app.elstc.co/guide/en/kibana/master/kuery-query.html)","sha":"f95414f76ff7574a8ef02a9013591994eb2e7bdb"}}]}]
BACKPORT-->

Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>
  • Loading branch information
kibanamachine and gchaps committed Dec 1, 2022
1 parent 2f12db5 commit 6932e2b
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions docs/concepts/kuery.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,65 @@ documents where any sub-field of `http.response` contains “error”, use the f
-------------------
http.response.*: error
-------------------

[discrete]
=== Querying nested fields

Querying {ref}/nested.html[nested fields] requires a special syntax. Consider the
following document, where `user` is a nested field:

[source,yaml]
-------------------
{
"user" : [
{
"first" : "John",
"last" : "Smith"
},
{
"first" : "Alice",
"last" : "White"
}
]
}
-------------------

To find documents where a single value inside the `user` array contains a first name of
“Alice” and last name of “White”, use the following:

[source,yaml]
-------------------
user:{ first: "Alice" and last: "White" }
-------------------

Because nested fields can be inside other nested fields,
you must specify the full path of the nested field you want to query.
For example, consider the following document where `user` and `names` are both nested fields:

[source,yaml]
-------------------
{
"user": [
{
"names": [
{
"first": "John",
"last": "Smith"
},
{
"first": "Alice",
"last": "White"
}
]
}
]
}
-------------------

To find documents where a single value inside the `user.names` array contains a first name of “Alice” *and*
last name of “White”, use the following:

[source,yaml]
-------------------
user.names:{ first: "Alice" and last: "White" }
-------------------

0 comments on commit 6932e2b

Please sign in to comment.