Skip to content

Commit 3a76b95

Browse files
committed
Merge branch 'master' into java-time
2 parents 8b32091 + 11fa5c6 commit 3a76b95

File tree

8 files changed

+145
-22
lines changed

8 files changed

+145
-22
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/watcher/WatchStatus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.joda.time.DateTime;
2727

2828
import java.io.IOException;
29+
import java.util.Collections;
2930
import java.util.HashMap;
3031
import java.util.Map;
3132
import java.util.Objects;
@@ -125,7 +126,7 @@ public static WatchStatus parse(XContentParser parser) throws IOException {
125126
DateTime lastChecked = null;
126127
DateTime lastMetCondition = null;
127128
Map<String, ActionStatus> actions = null;
128-
Map<String, String> headers = null;
129+
Map<String, String> headers = Collections.emptyMap();
129130
long version = -1;
130131

131132
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser::getTokenLocation);

distribution/packages/build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ Closure commonPackageConfig(String type, boolean oss) {
167167
configurationFile '/etc/elasticsearch/elasticsearch.yml'
168168
configurationFile '/etc/elasticsearch/jvm.options'
169169
configurationFile '/etc/elasticsearch/log4j2.properties'
170-
configurationFile '/etc/elasticsearch/role_mapping.yml'
171-
configurationFile '/etc/elasticsearch/roles.yml'
172-
configurationFile '/etc/elasticsearch/users'
173-
configurationFile '/etc/elasticsearch/users_roles'
170+
if (oss == false) {
171+
configurationFile '/etc/elasticsearch/role_mapping.yml'
172+
configurationFile '/etc/elasticsearch/roles.yml'
173+
configurationFile '/etc/elasticsearch/users'
174+
configurationFile '/etc/elasticsearch/users_roles'
175+
}
174176
into('/etc/elasticsearch') {
175177
dirMode 0750
176178
fileMode 0660

docs/java-rest/high-level/supported-apis.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ The Java High Level REST Client supports the following Watcher APIs:
422422
* <<{upid}-start-watch-service>>
423423
* <<{upid}-stop-watch-service>>
424424
* <<java-rest-high-x-pack-watcher-put-watch>>
425-
* <<java-rest-high-x-pack-watcher-get-watch>>
425+
* <<{upid}-get-watch>>
426426
* <<java-rest-high-x-pack-watcher-delete-watch>>
427427
* <<java-rest-high-watcher-deactivate-watch>>
428428
* <<{upid}-ack-watch>>

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

Lines changed: 124 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ GET /_search
2828
"query": {
2929
"query_string" : {
3030
"default_field" : "content",
31-
"query" : "(new york city) OR (big apple)"
31+
"query" : "(new york city) OR (big apple)" <1>
3232
}
3333
}
3434
}
3535
--------------------------------------------------
3636
// CONSOLE
3737

38-
... will be split into `new york city` and `big apple` and each part is then
38+
<1> will be split into `new york city` and `big apple` and each part is then
3939
analyzed independently by the analyzer configured for the field.
4040

4141
WARNING: Whitespaces are not considered operators, this means that `new york city`
@@ -48,7 +48,6 @@ When multiple fields are provided it is also possible to modify how the differen
4848
field queries are combined inside each textual part using the `type` parameter.
4949
The possible modes are described <<multi-match-types, here>> and the default is `best_fields`.
5050

51-
5251
The `query_string` top level parameters include:
5352

5453
[cols="<,<",options="header",]
@@ -107,8 +106,8 @@ not analyzed. By setting this value to `true`, a best effort will be
107106
made to analyze those as well.
108107

109108
|`max_determinized_states` |Limit on how many automaton states regexp
110-
queries are allowed to create. This protects against too-difficult
111-
(e.g. exponentially hard) regexps. Defaults to 10000.
109+
queries are allowed to create. This protects against too-difficult
110+
(e.g. exponentially hard) regexps. Defaults to 10000.
112111

113112
|`minimum_should_match` |A value controlling how many "should" clauses
114113
in the resulting boolean query should match. It can be an absolute value
@@ -154,7 +153,7 @@ fields in the mapping could be expensive.
154153
==== Multi Field
155154

156155
The `query_string` query can also run against multiple fields. Fields can be
157-
provided via the `"fields"` parameter (example below).
156+
provided via the `fields` parameter (example below).
158157

159158
The idea of running the `query_string` query against multiple fields is to
160159
expand each query term to an OR clause like this:
@@ -194,7 +193,7 @@ GET /_search
194193
// CONSOLE
195194

196195
Since several queries are generated from the individual search terms,
197-
combining them is automatically done using a `dis_max` query with a tie_breaker.
196+
combining them is automatically done using a `dis_max` query with a `tie_breaker`.
198197
For example (the `name` is boosted by 5 using `^5` notation):
199198

200199
[source,js]
@@ -289,7 +288,7 @@ GET /_search
289288

290289
The `query_string` query supports multi-terms synonym expansion with the <<analysis-synonym-graph-tokenfilter,
291290
synonym_graph>> token filter. When this filter is used, the parser creates a phrase query for each multi-terms synonyms.
292-
For example, the following synonym: `"ny, new york" would produce:`
291+
For example, the following synonym: `ny, new york` would produce:
293292

294293
`(ny OR ("new york"))`
295294

@@ -317,4 +316,121 @@ The example above creates a boolean query:
317316
that matches documents with the term `ny` or the conjunction `new AND york`.
318317
By default the parameter `auto_generate_synonyms_phrase_query` is set to `true`.
319318

319+
[float]
320+
==== Minimum should match
321+
322+
The `query_string` splits the query around each operator to create a boolean
323+
query for the entire input. You can use `minimum_should_match` to control how
324+
many "should" clauses in the resulting query should match.
325+
326+
[source,js]
327+
--------------------------------------------------
328+
GET /_search
329+
{
330+
"query": {
331+
"query_string": {
332+
"fields": [
333+
"title"
334+
],
335+
"query": "this that thus",
336+
"minimum_should_match": 2
337+
}
338+
}
339+
}
340+
--------------------------------------------------
341+
// CONSOLE
342+
343+
The example above creates a boolean query:
344+
345+
`(title:this title:that title:thus)~2`
346+
347+
that matches documents with at least two of the terms `this`, `that` or `thus`
348+
in the single field `title`.
349+
350+
[float]
351+
===== Multi Field
352+
353+
[source,js]
354+
--------------------------------------------------
355+
GET /_search
356+
{
357+
"query": {
358+
"query_string": {
359+
"fields": [
360+
"title",
361+
"content"
362+
],
363+
"query": "this that thus",
364+
"minimum_should_match": 2
365+
}
366+
}
367+
}
368+
--------------------------------------------------
369+
// CONSOLE
370+
371+
The example above creates a boolean query:
372+
373+
`((content:this content:that content:thus) | (title:this title:that title:thus))`
374+
375+
that matches documents with the disjunction max over the fields `title` and
376+
`content`. Here the `minimum_should_match` parameter can't be applied.
377+
378+
[source,js]
379+
--------------------------------------------------
380+
GET /_search
381+
{
382+
"query": {
383+
"query_string": {
384+
"fields": [
385+
"title",
386+
"content"
387+
],
388+
"query": "this OR that OR thus",
389+
"minimum_should_match": 2
390+
}
391+
}
392+
}
393+
--------------------------------------------------
394+
// CONSOLE
395+
396+
Adding explicit operators forces each term to be considered as a separate clause.
397+
398+
The example above creates a boolean query:
399+
400+
`((content:this | title:this) (content:that | title:that) (content:thus | title:thus))~2`
401+
402+
that matches documents with at least two of the three "should" clauses, each of
403+
them made of the disjunction max over the fields for each term.
404+
405+
[float]
406+
===== Cross Field
407+
408+
[source,js]
409+
--------------------------------------------------
410+
GET /_search
411+
{
412+
"query": {
413+
"query_string": {
414+
"fields": [
415+
"title",
416+
"content"
417+
],
418+
"query": "this OR that OR thus",
419+
"type": "cross_fields",
420+
"minimum_should_match": 2
421+
}
422+
}
423+
}
424+
--------------------------------------------------
425+
// CONSOLE
426+
427+
The `cross_fields` value in the `type` field indicates that fields that have the
428+
same analyzer should be grouped together when the input is analyzed.
429+
430+
The example above creates a boolean query:
431+
432+
`(blended(terms:[field2:this, field1:this]) blended(terms:[field2:that, field1:that]) blended(terms:[field2:thus, field1:thus]))~2`
433+
434+
that matches documents with at least two of the three per-term blended queries.
435+
320436
include::query-string-syntax.asciidoc[]

docs/reference/search/request/search-after.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ of the sort specification. Otherwise the sort order for documents that have
3737
the same sort values would be undefined and could lead to missing or duplicate
3838
results. The <<mapping-id-field,`_id` field>> has a unique value per document
3939
but it is not recommended to use it as a tiebreaker directly.
40+
Beware that `search_after` looks for the first document which fully or partially
41+
matches tiebreaker's provided value. Therefore if a document has a tiebreaker value of
42+
`"654323"` and you `search_after` for `"654"` it would still match that document
43+
and return results found after it.
4044
<<doc-values,doc value>> are disabled on this field so sorting on it requires
4145
to load a lot of data in memory. Instead it is advised to duplicate (client side
4246
or with a <<ingest-processors,set ingest processor>>) the content

server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/InternalDateHistogramTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void setUp() throws Exception {
7171
//it's ok if min and max are outside the range of the generated buckets, that will just mean that
7272
//empty buckets won't be added before the first bucket and/or after the last one
7373
long min = baseMillis - intervalMillis * randomNumberOfBuckets();
74-
long max = baseMillis + randomNumberOfBuckets() * intervalMillis + randomNumberOfBuckets();
74+
long max = baseMillis + randomNumberOfBuckets() * intervalMillis;
7575
extendedBounds = new ExtendedBounds(min, max);
7676
}
7777
emptyBucketInfo = new InternalDateHistogram.EmptyBucketInfo(rounding, InternalAggregations.EMPTY, extendedBounds);
@@ -86,7 +86,7 @@ protected InternalDateHistogram createTestInstance(String name,
8686
int nbBuckets = randomNumberOfBuckets();
8787
List<InternalDateHistogram.Bucket> buckets = new ArrayList<>(nbBuckets);
8888
//avoid having different random instance start from exactly the same base
89-
long startingDate = baseMillis - intervalMillis * randomIntBetween(0, 100);
89+
long startingDate = baseMillis - intervalMillis * randomNumberOfBuckets();
9090
for (int i = 0; i < nbBuckets; i++) {
9191
//rarely leave some holes to be filled up with empty buckets in case minDocCount is set to 0
9292
if (frequently()) {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/watch/WatchStatus.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ public void readFrom(StreamInput in) throws IOException {
234234
}
235235
if (in.readBoolean()) {
236236
headers = in.readMap(StreamInput::readString, StreamInput::readString);
237+
} else {
238+
headers = Collections.emptyMap();
237239
}
238240
}
239241

x-pack/plugin/core/src/test/java/org/elasticsearch/protocol/xpack/watcher/GetWatchResponseTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,10 @@ private static WatchStatus randomWatchStatus() {
140140
);
141141
actionMap.put(randomAlphaOfLength(10), actionStatus);
142142
}
143-
Map<String, String> headers = randomBoolean() ? new HashMap<>() : null;
144-
if (headers != null) {
145-
int headerSize = randomIntBetween(1, 5);
146-
for (int i = 0; i < headerSize; i++) {
147-
headers.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(1, 10));
148-
}
143+
Map<String, String> headers = new HashMap<>();
144+
int headerSize = randomIntBetween(0, 5);
145+
for (int i = 0; i < headerSize; i++) {
146+
headers.put(randomAlphaOfLengthBetween(5, 10), randomAlphaOfLengthBetween(1, 10));
149147
}
150148
return new WatchStatus(version, state, executionState, lastChecked, lastMetCondition, actionMap, headers);
151149
}

0 commit comments

Comments
 (0)