Skip to content

[DOCS] Reformat span term query #44770

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 2 commits 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
75 changes: 54 additions & 21 deletions docs/reference/query-dsl/span-term-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,75 @@
<titleabbrev>Span term</titleabbrev>
++++

Matches spans containing a term. The span term query maps to Lucene
`SpanTermQuery`. Here is an example:
Matches spans that contain an *exact* term in a provided field.

[source,js]
--------------------------------------------------
GET /_search
{
"query": {
"span_term" : { "user" : "kimchy" }
}
}
--------------------------------------------------
// CONSOLE
You can combine the `span_term` query with other <<span-queries,span queries>>,
like `span_first` and `span_near`, to create more complex searches.

A boost can also be associated with the query:
[[span-term-query-ex-request]]
==== Example request

[source,js]
--------------------------------------------------
----
GET /_search
{
"query": {
"span_term" : { "user" : { "value" : "kimchy", "boost" : 2.0 } }
"span_term" : {
"user": {
"value": "Kimchy",
"boost": 2.0
}
}
}
}
--------------------------------------------------
----
// CONSOLE

Or :
[[span-term-top-level-params]]
==== Top-level parameters for `span_term`
`<field>`::
(Required, object) Field you wish to search.

[[span-term-field-params]]
==== Parameters for `<field>`
`value`::
(Required, string) Term you wish to find in the provided `<field>`. To return a
document, the term must exactly match the field value, including whitespace and
capitalization.

`boost`::
+
--
(Optional, float) Floating point number used to decrease or increase the
<<relevance-scores,relevance scores>> of a query. Defaults to `1.0`.

WARNING: When using the `span_term` query with compound <<span-queries,span
queries>>, like <<query-dsl-span-near-query,`span_near`>>, you can only set a
`boost` value for the outermost span query.

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.
--


[[span-term-query-notes]]
==== Notes

[[span-term-query-short-ex]]
===== Short request example
You can simplify the `span_query` query syntax by combining the `<field>` and
`value` parameters. For example:

[source,js]
--------------------------------------------------
----
GET /_search
{
"query": {
"span_term" : { "user" : { "term" : "kimchy", "boost" : 2.0 } }
"span_term" : {
"user" : "kimchy"
}
}
}
--------------------------------------------------
// CONSOLE
----
// CONSOLE