Skip to content

[DOCS] Reformat span within query #44834

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions docs/reference/query-dsl/span-within-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,48 @@
<titleabbrev>Span within</titleabbrev>
++++

Returns matches which are enclosed inside another span query. The span within
query maps to Lucene `SpanWithinQuery`. Here is an example:
Returns spans from a `little` <<span-queries,span query>> that are enclosed in
spans matching a `big` span query.


[[span-within-query-ex-request]]
==== Example request

[source,js]
--------------------------------------------------
----
GET /_search
{
"query": {
"span_within" : {
"little" : {
"span_term" : { "field1" : "foo" }
},
"big" : {
"span_near" : {
"clauses" : [
{ "span_term" : { "field1" : "bar" } },
{ "span_term" : { "field1" : "baz" } }
{ "span_term" : { "message" : { "value" : "bar" } } },
{ "span_term" : { "message" : { "value" : "baz" } } }
],
"slop" : 5,
"in_order" : true
}
},
"little" : {
"span_term" : { "message" : { "value" : "foo" } }
}
}
}
}
--------------------------------------------------
----
// CONSOLE

The `big` and `little` clauses can be any span type query. Matching
spans from `little` that are enclosed within `big` are returned.

[[span-within-top-level-params]]
==== Top-level parameters for `span_within`

`big`::
(Required, query object) Contains a <<span-queries,span query>>. To be returned,
spans matching the `little` span query must be enclosed in spans matching this
query.

`little`::
(Required, query object) Contains a <<span-queries,span query>>. To be returned,
spans matching this span query must be enclosed in spans matching the `big`
query.