Skip to content

Commit b32f545

Browse files
committed
Merge branch 'master' of https://github.com/elastic/elasticsearch into 35992_fix
2 parents 375caf4 + 01b8f99 commit b32f545

File tree

69 files changed

+523
-629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+523
-629
lines changed

docs/painless/painless-contexts/painless-score-context.asciidoc

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ score to documents returned from a query.
1111
User-defined parameters passed in as part of the query.
1212

1313
`doc` (`Map`, read-only)::
14-
Contains the fields of the current document where each field is a
15-
`List` of values.
14+
Contains the fields of the current document. For single-valued fields,
15+
the value can be accessed via `doc['fieldname'].value`. For multi-valued
16+
fields, this returns the first value; other values can be accessed
17+
via `doc['fieldname'].get(index)`
1618

1719
`_score` (`double` read-only)::
1820
The similarity score of the current document.
@@ -24,4 +26,33 @@ score to documents returned from a query.
2426

2527
*API*
2628

27-
The standard <<painless-api-reference, Painless API>> is available.
29+
The standard <<painless-api-reference, Painless API>> is available.
30+
31+
*Example*
32+
33+
To run this example, first follow the steps in
34+
<<painless-context-examples, context examples>>.
35+
36+
The following query finds all unsold seats, with lower 'row' values
37+
scored higher.
38+
39+
[source,js]
40+
--------------------------------------------------
41+
GET /seats/_search
42+
{
43+
"query": {
44+
"function_score": {
45+
"query": {
46+
"match": { "sold": "false" }
47+
},
48+
"script_score" : {
49+
"script" : {
50+
"source": "1.0 / doc['row'].value"
51+
}
52+
}
53+
}
54+
}
55+
}
56+
--------------------------------------------------
57+
// CONSOLE
58+
// TEST[setup:seats]

docs/painless/painless-contexts/painless-similarity-context.asciidoc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ documents in a query.
1515
`params` (`Map`, read-only)::
1616
User-defined parameters passed in at query-time.
1717

18+
`weight` (`float`, read-only)::
19+
The weight as calculated by a <<painless-weight-context,weight script>>
20+
1821
`query.boost` (`float`, read-only)::
1922
The boost value if provided by the query. If this is not provided the
2023
value is `1.0f`.
@@ -37,12 +40,23 @@ documents in a query.
3740
The total occurrences of the current term in the index.
3841

3942
`doc.length` (`long`, read-only)::
40-
The number of tokens the current document has in the current field.
43+
The number of tokens the current document has in the current field. This
44+
is decoded from the stored {ref}/norms.html[norms] and may be approximate for
45+
long fields
4146

4247
`doc.freq` (`long`, read-only)::
4348
The number of occurrences of the current term in the current
4449
document for the current field.
4550

51+
Note that the `query`, `field`, and `term` variables are also available to the
52+
<<painless-weight-context,weight context>>. They are more efficiently used
53+
there, as they are constant for all documents.
54+
55+
For queries that contain multiple terms, the script is called once for each
56+
term with that term's calculated weight, and the results are summed. Note that some
57+
terms might have a `doc.freq` value of `0` on a document, for example if a query
58+
uses synonyms.
59+
4660
*Return*
4761

4862
`double`::

docs/painless/painless-contexts/painless-sort-context.asciidoc

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ Use a Painless script to
1010
User-defined parameters passed in as part of the query.
1111

1212
`doc` (`Map`, read-only)::
13-
Contains the fields of the current document where each field is a
14-
`List` of values.
13+
Contains the fields of the current document. For single-valued fields,
14+
the value can be accessed via `doc['fieldname'].value`. For multi-valued
15+
fields, this returns the first value; other values can be accessed
16+
via `doc['fieldname'].get(index)`
1517

1618
`_score` (`double` read-only)::
1719
The similarity score of the current document.
@@ -23,4 +25,37 @@ Use a Painless script to
2325

2426
*API*
2527

26-
The standard <<painless-api-reference, Painless API>> is available.
28+
The standard <<painless-api-reference, Painless API>> is available.
29+
30+
*Example*
31+
32+
To run this example, first follow the steps in
33+
<<painless-context-examples, context examples>>.
34+
35+
To sort results by the length of the `theatre` field, submit the following query:
36+
37+
[source,js]
38+
----
39+
GET /_search
40+
{
41+
"query" : {
42+
"term" : { "sold" : "true" }
43+
},
44+
"sort" : {
45+
"_script" : {
46+
"type" : "number",
47+
"script" : {
48+
"lang": "painless",
49+
"source": "doc['theatre'].value.length() * params.factor",
50+
"params" : {
51+
"factor" : 1.1
52+
}
53+
},
54+
"order" : "asc"
55+
}
56+
}
57+
}
58+
59+
----
60+
// CONSOLE
61+
// TEST[setup:seats]

docs/painless/painless-contexts/painless-weight-context.asciidoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33

44
Use a Painless script to create a
55
{ref}/index-modules-similarity.html[weight] for use in a
6-
<<painless-similarity-context, similarity script>>. Weight is used to prevent
7-
recalculation of constants that remain the same across documents.
6+
<<painless-similarity-context, similarity script>>. The weight makes up the
7+
part of the similarity calculation that is independent of the document being
8+
scored, and so can be built up front and cached.
9+
10+
Queries that contain multiple terms calculate a separate weight for each term.
811

912
*Variables*
1013

docs/reference/docs/termvectors.asciidoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ or by adding the requested fields in the request body (see
2727
example below). Fields can also be specified with wildcards
2828
in similar way to the <<query-dsl-multi-match-query,multi match query>>
2929

30-
[WARNING]
31-
Note that the usage of `/_termvector` is deprecated in 2.0, and replaced by `/_termvectors`.
32-
3330
[float]
3431
=== Return values
3532

docs/reference/migration/migrate_7_0/api.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,10 @@ while now an exception is thrown.
119119

120120
The deprecated graph endpoints (those with `/_graph/_explore`) have been
121121
removed.
122+
123+
124+
[float]
125+
==== Deprecated `_termvector` endpoint removed
126+
127+
The `_termvector` endpoint was deprecated in 2.0 and has now been removed.
128+
The endpoint `_termvectors` (plural) should be used instead.

docs/reference/migration/migrate_7_0/java.asciidoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ was moved to `org.elasticsearch.search.aggregations.PipelineAggregationBuilders`
3232
==== `Retry.withBackoff` methods with `Settings` removed
3333

3434
The variants of `Retry.withBackoff` that included `Settings` have been removed
35-
because `Settings` is no longer needed.
35+
because `Settings` is no longer needed.
36+
37+
[float]
38+
==== Deprecated method `Client#termVector` removed
39+
40+
The client method `termVector`, deprecated in 2.0, has been removed. The method
41+
`termVectors` (plural) should be used instead.

docs/reference/migration/migrate_7_0/search.asciidoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,14 @@ Negative scores in the Function Score Query are deprecated in 6.x, and are
159159
not allowed in this version. If a negative score is produced as a result
160160
of computation (e.g. in `script_score` or `field_value_factor` functions),
161161
an error will be thrown.
162+
163+
[float]
164+
==== The filter context has been removed
165+
166+
The `filter` context has been removed from Elasticsearch's query builders,
167+
the distinction between queries and filters is now decided in Lucene depending
168+
on whether queries need to access score or not. As a result `bool` queries with
169+
`should` clauses that don't need to access the score will no longer set their
170+
`minimum_should_match` to 1. This behavior has been deprecated in the previous
171+
major version.
172+

docs/reference/query-dsl/bool-query.asciidoc

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,14 @@ contribute to the score.
1717
in <<query-filter-context,filter context>>, meaning that scoring is ignored
1818
and clauses are considered for caching.
1919

20-
|`should` |The clause (query) should appear in the matching document. If the
21-
`bool` query is in a <<query-filter-context,query context>> and has a `must` or
22-
`filter` clause then a document will match the `bool` query even if none of the
23-
`should` queries match. In this case these clauses are only used to influence
24-
the score. If the `bool` query is a <<query-filter-context,filter context>>
25-
or has neither `must` or `filter` then at least one of the `should` queries
26-
must match a document for it to match the `bool` query. This behavior may be
27-
explicitly controlled by settings the
28-
<<query-dsl-minimum-should-match,`minimum_should_match`>> parameter.
20+
|`should` |The clause (query) should appear in the matching document.
2921

3022
|`must_not` |The clause (query) must not appear in the matching
3123
documents. Clauses are executed in <<query-filter-context,filter context>> meaning
3224
that scoring is ignored and clauses are considered for caching. Because scoring is
3325
ignored, a score of `0` for all documents is returned.
3426
|=======================================================================
3527

36-
[IMPORTANT]
37-
.Bool query in filter context
38-
========================================================================
39-
If this query is used in a filter context and it has `should`
40-
clauses then at least one `should` clause is required to match.
41-
========================================================================
42-
4328
The `bool` query takes a _more-matches-is-better_ approach, so the score from
4429
each matching `must` or `should` clause will be added together to provide the
4530
final `_score` for each document.

docs/reference/search/request/scroll.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ TIP: Keeping older segments alive means that more file handles are needed.
125125
Ensure that you have configured your nodes to have ample free file handles.
126126
See <<file-descriptors>>.
127127

128+
NOTE: To prevent against issues caused by having too many scrolls open, the
129+
user is not allowed to open scrolls past a certain limit. By default, the
130+
maximum number of open scrolls is 500. This limit can be updated with the
131+
`search.max_open_scroll_context` cluster setting.
132+
128133
You can check how many search contexts are open with the
129134
<<cluster-nodes-stats,nodes stats API>>:
130135

0 commit comments

Comments
 (0)