Skip to content

Commit 7f8cd95

Browse files
committed
Merge branch 'master' into feature/searchable-snapshots
2 parents 050583e + 9a2a59b commit 7f8cd95

File tree

175 files changed

+3435
-1025
lines changed

Some content is hidden

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

175 files changed

+3435
-1025
lines changed

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,22 @@ Some tests related to locale testing also require the flag
166166
IntelliJ or Eclipse like describe above to use
167167
`-Djava.locale.providers=SPI,COMPAT`.
168168

169+
### REST Endpoint Conventions
170+
171+
Elasticsearch typically uses singular nouns rather than plurals in URLs.
172+
For example:
173+
174+
/_ingest/pipline
175+
/_ingest/pipline/{id}
176+
177+
but not:
178+
179+
/_ingest/piplines
180+
/_ingest/piplines/{id}
181+
182+
You may find counterexamples, but new endpoints should use the singular
183+
form.
184+
169185
### Java Language Formatting Guidelines
170186

171187
Java files in the Elasticsearch codebase are formatted with the Eclipse JDT

client/rest-high-level/src/main/java/org/elasticsearch/client/eql/EqlSearchRequest.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,32 @@ public class EqlSearchRequest implements Validatable, ToXContentObject {
3636
private String[] indices;
3737
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false);
3838

39-
private QueryBuilder query = null;
40-
private String timestampField = "@timestamp";
39+
private QueryBuilder filter = null;
40+
private String timestampField = "timestamp";
4141
private String eventTypeField = "event_type";
4242
private String implicitJoinKeyField = "agent.id";
4343
private int fetchSize = 50;
4444
private SearchAfterBuilder searchAfterBuilder;
45-
private String rule;
45+
private String query;
4646

47-
static final String KEY_QUERY = "query";
47+
static final String KEY_FILTER = "filter";
4848
static final String KEY_TIMESTAMP_FIELD = "timestamp_field";
4949
static final String KEY_EVENT_TYPE_FIELD = "event_type_field";
5050
static final String KEY_IMPLICIT_JOIN_KEY_FIELD = "implicit_join_key_field";
5151
static final String KEY_SIZE = "size";
5252
static final String KEY_SEARCH_AFTER = "search_after";
53-
static final String KEY_RULE = "rule";
53+
static final String KEY_QUERY = "query";
5454

55-
public EqlSearchRequest(String indices, String rule) {
55+
public EqlSearchRequest(String indices, String query) {
5656
indices(indices);
57-
rule(rule);
57+
query(query);
5858
}
5959

6060
@Override
6161
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
6262
builder.startObject();
63-
if (query != null) {
64-
builder.field(KEY_QUERY, query);
63+
if (filter != null) {
64+
builder.field(KEY_FILTER, filter);
6565
}
6666
builder.field(KEY_TIMESTAMP_FIELD, timestampField());
6767
builder.field(KEY_EVENT_TYPE_FIELD, eventTypeField());
@@ -74,7 +74,7 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
7474
builder.array(KEY_SEARCH_AFTER, searchAfterBuilder.getSortValues());
7575
}
7676

77-
builder.field(KEY_RULE, rule);
77+
builder.field(KEY_QUERY, query);
7878
builder.endObject();
7979
return builder;
8080
}
@@ -88,12 +88,12 @@ public EqlSearchRequest indices(String... indices) {
8888
return this;
8989
}
9090

91-
public QueryBuilder query() {
92-
return this.query;
91+
public QueryBuilder filter() {
92+
return this.filter;
9393
}
9494

95-
public EqlSearchRequest query(QueryBuilder query) {
96-
this.query = query;
95+
public EqlSearchRequest filter(QueryBuilder filter) {
96+
this.filter = filter;
9797
return this;
9898
}
9999

@@ -156,13 +156,13 @@ private EqlSearchRequest setSearchAfter(SearchAfterBuilder builder) {
156156
return this;
157157
}
158158

159-
public String rule() {
160-
return this.rule;
159+
public String query() {
160+
return this.query;
161161
}
162162

163-
public EqlSearchRequest rule(String rule) {
164-
Objects.requireNonNull(rule, "rule must not be null");
165-
this.rule = rule;
163+
public EqlSearchRequest query(String query) {
164+
Objects.requireNonNull(query, "query must not be null");
165+
this.query = query;
166166
return this;
167167
}
168168

@@ -175,30 +175,29 @@ public boolean equals(Object o) {
175175
return false;
176176
}
177177
EqlSearchRequest that = (EqlSearchRequest) o;
178-
return
179-
fetchSize == that.fetchSize &&
178+
return fetchSize == that.fetchSize &&
180179
Arrays.equals(indices, that.indices) &&
181180
Objects.equals(indicesOptions, that.indicesOptions) &&
182-
Objects.equals(query, that.query) &&
181+
Objects.equals(filter, that.filter) &&
183182
Objects.equals(timestampField, that.timestampField) &&
184183
Objects.equals(eventTypeField, that.eventTypeField) &&
185184
Objects.equals(implicitJoinKeyField, that.implicitJoinKeyField) &&
186185
Objects.equals(searchAfterBuilder, that.searchAfterBuilder) &&
187-
Objects.equals(rule, that.rule);
186+
Objects.equals(query, that.query);
188187
}
189188

190189
@Override
191190
public int hashCode() {
192191
return Objects.hash(
193192
Arrays.hashCode(indices),
194193
indicesOptions,
195-
query,
194+
filter,
196195
fetchSize,
197196
timestampField,
198197
eventTypeField,
199198
implicitJoinKeyField,
200199
searchAfterBuilder,
201-
rule);
200+
query);
202201
}
203202

204203
public String[] indices() {

client/rest-high-level/src/test/java/org/elasticsearch/client/EqlIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public void testLargeMapping() throws Exception {
7979
sb.append(",");
8080
}
8181
sb.append("\"event_type\": \"process\",");
82+
sb.append("\"timestamp\": \"2020-02-03T12:34:56Z\",");
8283
sb.append("\"serial_event_id\": 1");
8384
sb.append("}");
8485
doc1.setJsonEntity(sb.toString());

client/rest-high-level/src/test/java/org/elasticsearch/client/eql/EqlSearchRequestTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected EqlSearchRequest createClientTestInstance() {
4646
EqlSearchRequest.eventTypeField(randomAlphaOfLength(10));
4747
}
4848
if (randomBoolean()) {
49-
EqlSearchRequest.rule(randomAlphaOfLength(10));
49+
EqlSearchRequest.query(randomAlphaOfLength(10));
5050
}
5151
if (randomBoolean()) {
5252
EqlSearchRequest.timestampField(randomAlphaOfLength(10));
@@ -56,9 +56,9 @@ protected EqlSearchRequest createClientTestInstance() {
5656
}
5757
if (randomBoolean()) {
5858
if (randomBoolean()) {
59-
EqlSearchRequest.query(QueryBuilders.matchAllQuery());
59+
EqlSearchRequest.filter(QueryBuilders.matchAllQuery());
6060
} else {
61-
EqlSearchRequest.query(QueryBuilders.termQuery(randomAlphaOfLength(10), randomInt(100)));
61+
EqlSearchRequest.filter(QueryBuilders.termQuery(randomAlphaOfLength(10), randomInt(100)));
6262
}
6363
}
6464
return EqlSearchRequest;
@@ -75,8 +75,8 @@ protected void assertInstances(org.elasticsearch.xpack.eql.action.EqlSearchReque
7575
assertThat(serverInstance.eventTypeField(), equalTo(clientTestInstance.eventTypeField()));
7676
assertThat(serverInstance.implicitJoinKeyField(), equalTo(clientTestInstance.implicitJoinKeyField()));
7777
assertThat(serverInstance.timestampField(), equalTo(clientTestInstance.timestampField()));
78+
assertThat(serverInstance.filter(), equalTo(clientTestInstance.filter()));
7879
assertThat(serverInstance.query(), equalTo(clientTestInstance.query()));
79-
assertThat(serverInstance.rule(), equalTo(clientTestInstance.rule()));
8080
assertThat(serverInstance.searchAfter(), equalTo(clientTestInstance.searchAfter()));
8181
assertThat(serverInstance.indicesOptions(), equalTo(clientTestInstance.indicesOptions()));
8282
assertThat(serverInstance.indices(), equalTo(clientTestInstance.indices()));

distribution/src/bin/elasticsearch-service.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ rem - fourth, ergonomic JVM options are applied
123123
if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%
124124

125125
@setlocal
126-
for /F "usebackq delims=" %%a in (`"%JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.JvmOptionsParser" "!ES_PATH_CONF!" || echo jvm_options_parser_failed"`) do set ES_JAVA_OPTS=%%a
126+
for /F "usebackq delims=" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.JvmOptionsParser" "!ES_PATH_CONF!" ^|^| echo jvm_options_parser_failed`) do set ES_JAVA_OPTS=%%a
127127
@endlocal & set "MAYBE_JVM_OPTIONS_PARSER_FAILED=%ES_JAVA_OPTS%" & set ES_JAVA_OPTS=%ES_JAVA_OPTS%
128128

129129
if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" (

docs/reference/analysis/index-search-time.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ analyzer produces the following tokens:
6767
[ quick, fox ]
6868
------
6969
70-
To execute the serach, {es} compares these query string tokens to the tokens
70+
To execute the search, {es} compares these query string tokens to the tokens
7171
indexed in the `text` field.
7272
7373
[options="header"]

docs/reference/analysis/tokenfilters/trim-tokenfilter.asciidoc

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,107 @@
44
<titleabbrev>Trim</titleabbrev>
55
++++
66

7-
The `trim` token filter trims the whitespace surrounding a token.
7+
Removes leading and trailing whitespace from each token in a stream.
8+
9+
The `trim` filter uses Lucene's
10+
https://lucene.apache.org/core/{lucene_version_path}/analyzers-common/org/apache/lucene/analysis/miscellaneous/TrimFilter.html[TrimFilter].
11+
12+
[TIP]
13+
====
14+
Many commonly used tokenizers, such as the
15+
<<analysis-standard-tokenizer,`standard`>> or
16+
<<analysis-whitespace-tokenizer,`whitespace`>> tokenizer, remove whitespace by
17+
default. When using these tokenizers, you don't need to add a separate `trim`
18+
filter.
19+
====
20+
21+
[[analysis-trim-tokenfilter-analyze-ex]]
22+
==== Example
23+
24+
To see how the `trim` filter works, you first need to produce a token
25+
containing whitespace.
26+
27+
The following <<indices-analyze,analyze API>> request uses the
28+
<<analysis-keyword-tokenizer,`keyword`>> tokenizer to produce a token for
29+
`" fox "`.
30+
31+
[source,console]
32+
----
33+
GET _analyze
34+
{
35+
"tokenizer" : "keyword",
36+
"text" : " fox "
37+
}
38+
----
39+
40+
The API returns the following response. Note the `" fox "` token contains
41+
the original text's whitespace.
42+
43+
[source,console-result]
44+
----
45+
{
46+
"tokens": [
47+
{
48+
"token": " fox ",
49+
"start_offset": 0,
50+
"end_offset": 5,
51+
"type": "word",
52+
"position": 0
53+
}
54+
]
55+
}
56+
----
57+
58+
To remove the whitespace, add the `trim` filter to the previous analyze API
59+
request.
60+
61+
[source,console]
62+
----
63+
GET _analyze
64+
{
65+
"tokenizer" : "keyword",
66+
"filter" : ["trim"],
67+
"text" : " fox "
68+
}
69+
----
70+
71+
The API returns the following response. The returned `fox` token does not
72+
include any leading or trailing whitespace.
73+
74+
[source,console-result]
75+
----
76+
{
77+
"tokens": [
78+
{
79+
"token": "fox",
80+
"start_offset": 0,
81+
"end_offset": 5,
82+
"type": "word",
83+
"position": 0
84+
}
85+
]
86+
}
87+
----
88+
89+
[[analysis-trim-tokenfilter-analyzer-ex]]
90+
==== Add to an analyzer
91+
92+
The following <<indices-create-index,create index API>> request uses the `trim`
93+
filter to configure a new <<analysis-custom-analyzer,custom analyzer>>.
94+
95+
[source,console]
96+
----
97+
PUT trim_example
98+
{
99+
"settings": {
100+
"analysis": {
101+
"analyzer": {
102+
"keyword_trim": {
103+
"tokenizer": "keyword",
104+
"filter": [ "trim" ]
105+
}
106+
}
107+
}
108+
}
109+
}
110+
----

0 commit comments

Comments
 (0)