Skip to content

Commit 2e71e39

Browse files
Merge branch 'main' into esql_geogrid_intersects
2 parents b914956 + dcdbbe0 commit 2e71e39

File tree

19 files changed

+593
-38
lines changed

19 files changed

+593
-38
lines changed

docs/reference/elasticsearch/mapping-reference/dense-vector.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ The following mapping parameters are accepted:
274274
$$$dense-vector-element-type$$$
275275

276276
`element_type`
277-
: (Optional, string) The data type used to encode vectors. The supported data types are `float` (default), `byte`, and bit.
277+
: (Optional, string) The data type used to encode vectors. The supported data types are `float` (default), `byte`, and `bit`.
278278

279279
::::{dropdown} Valid values for element_type
280280
`float`

docs/reference/elasticsearch/mapping-reference/rank-vectors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ The `rank_vectors` field type supports the following parameters:
9090
$$$rank-vectors-element-type$$$
9191

9292
`element_type`
93-
: (Optional, string) The data type used to encode vectors. The supported data types are `float` (default), `byte`, and bit.
93+
: (Optional, string) The data type used to encode vectors. The supported data types are `float` (default), `byte`, and `bit`.
9494

9595
::::{dropdown} Valid values for element_type
9696
`float`

libs/exponential-histogram/src/main/java/org/elasticsearch/exponentialhistogram/AbstractExponentialHistogram.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,54 @@ public boolean equals(Object obj) {
4646
}
4747
return false;
4848
}
49+
50+
@Override
51+
public String toString() {
52+
StringBuilder sb = new StringBuilder(getClassNameWithoutPackage()).append("{");
53+
sb.append("scale=").append(scale());
54+
sb.append(", sum=").append(sum());
55+
sb.append(", valueCount=").append(valueCount());
56+
sb.append(", min=").append(min());
57+
sb.append(", max=").append(max());
58+
ZeroBucket zb = zeroBucket();
59+
if (zb.zeroThreshold() != 0) {
60+
sb.append(", zeroThreshold=").append(zb.zeroThreshold());
61+
}
62+
if (zb.count() != 0) {
63+
sb.append(", zeroCount=").append(zb.count());
64+
}
65+
BucketIterator neg = negativeBuckets().iterator();
66+
if (neg.hasNext()) {
67+
sb.append(", negative=[");
68+
appendsBucketsAsString(sb, neg);
69+
sb.append("]");
70+
}
71+
BucketIterator pos = positiveBuckets().iterator();
72+
if (pos.hasNext()) {
73+
sb.append(", positive=[");
74+
appendsBucketsAsString(sb, pos);
75+
sb.append("]");
76+
}
77+
sb.append("}");
78+
return sb.toString();
79+
}
80+
81+
private String getClassNameWithoutPackage() {
82+
String fqn = getClass().getName();
83+
int lastDot = fqn.lastIndexOf('.');
84+
return fqn.substring(lastDot + 1);
85+
}
86+
87+
private static void appendsBucketsAsString(StringBuilder out, BucketIterator it) {
88+
boolean first = true;
89+
while (it.hasNext()) {
90+
if (first) {
91+
first = false;
92+
} else {
93+
out.append(", ");
94+
}
95+
out.append(it.peekIndex()).append(": ").append(it.peekCount());
96+
it.advance();
97+
}
98+
}
4999
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright Elasticsearch B.V., and/or licensed to Elasticsearch B.V.
3+
* under one or more license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*
19+
* This file is based on a modification of https://github.com/open-telemetry/opentelemetry-java which is licensed under the Apache 2.0 License.
20+
*/
21+
22+
package org.elasticsearch.exponentialhistogram;
23+
24+
import static org.hamcrest.Matchers.equalTo;
25+
26+
public class ExponentialHistogramToStringTests extends ExponentialHistogramTestCase {
27+
28+
public void testFullHistogram() {
29+
try (FixedCapacityExponentialHistogram histogram = FixedCapacityExponentialHistogram.create(10, breaker())) {
30+
histogram.setZeroBucket(ZeroBucket.create(42.0, 7));
31+
histogram.resetBuckets(10);
32+
histogram.setMin(-100);
33+
histogram.setMax(200);
34+
histogram.setSum(1234.5);
35+
histogram.tryAddBucket(2, 3, false); // negative bucket
36+
histogram.tryAddBucket(3, 4, false); // negative bucket
37+
histogram.tryAddBucket(4, 2, false); // negative bucket
38+
histogram.tryAddBucket(1, 5, true); // positive bucket
39+
histogram.tryAddBucket(5, 7, true); // positive bucket
40+
histogram.tryAddBucket(6, 1, true); // positive bucket
41+
String expected = "FixedCapacityExponentialHistogram{"
42+
+ "scale=10, sum=1234.5, valueCount=29, min=-100.0, max=200.0, zeroThreshold=42.0, zeroCount=7,"
43+
+ " negative=[2: 3, 3: 4, 4: 2], positive=[1: 5, 5: 7, 6: 1]}";
44+
assertThat(histogram.toString(), equalTo(expected));
45+
}
46+
}
47+
48+
public void testEmptyHistogram() {
49+
ExponentialHistogram emptyHistogram = ExponentialHistogram.empty();
50+
String expected = "EmptyExponentialHistogram{scale=" + emptyHistogram.scale() + ", sum=0.0, valueCount=0, min=NaN, max=NaN}";
51+
assertThat(emptyHistogram.toString(), equalTo(expected));
52+
}
53+
}

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/RerouteProcessor.java

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package org.elasticsearch.ingest.common;
1111

12+
import org.elasticsearch.cluster.metadata.DataStream;
1213
import org.elasticsearch.cluster.metadata.ProjectId;
1314
import org.elasticsearch.core.Nullable;
1415
import org.elasticsearch.ingest.AbstractProcessor;
@@ -17,11 +18,9 @@
1718
import org.elasticsearch.ingest.Processor;
1819

1920
import java.util.List;
20-
import java.util.Locale;
2121
import java.util.Map;
2222
import java.util.Objects;
2323
import java.util.function.Function;
24-
import java.util.regex.Pattern;
2524

2625
import static org.elasticsearch.core.Strings.format;
2726
import static org.elasticsearch.ingest.ConfigurationUtils.newConfigurationException;
@@ -221,11 +220,6 @@ public RerouteProcessor create(
221220
*/
222221
static final class DataStreamValueSource {
223222

224-
private static final int MAX_LENGTH = 100;
225-
private static final String REPLACEMENT = "_";
226-
private static final Pattern DISALLOWED_IN_TYPE = Pattern.compile("[\\\\/*?\"<>| ,#:-]");
227-
private static final Pattern DISALLOWED_IN_DATASET = Pattern.compile("[\\\\/*?\"<>| ,#:-]");
228-
private static final Pattern DISALLOWED_IN_NAMESPACE = Pattern.compile("[\\\\/*?\"<>| ,#:]");
229223
static final DataStreamValueSource TYPE_VALUE_SOURCE = type("{{" + DATA_STREAM_TYPE + "}}");
230224
static final DataStreamValueSource DATASET_VALUE_SOURCE = dataset("{{" + DATA_STREAM_DATASET + "}}");
231225
static final DataStreamValueSource NAMESPACE_VALUE_SOURCE = namespace("{{" + DATA_STREAM_NAMESPACE + "}}");
@@ -235,24 +229,15 @@ static final class DataStreamValueSource {
235229
private final Function<String, String> sanitizer;
236230

237231
public static DataStreamValueSource type(String type) {
238-
return new DataStreamValueSource(type, ds -> sanitizeDataStreamField(ds, DISALLOWED_IN_TYPE));
232+
return new DataStreamValueSource(type, DataStream::sanitizeType);
239233
}
240234

241235
public static DataStreamValueSource dataset(String dataset) {
242-
return new DataStreamValueSource(dataset, ds -> sanitizeDataStreamField(ds, DISALLOWED_IN_DATASET));
236+
return new DataStreamValueSource(dataset, DataStream::sanitizeDataset);
243237
}
244238

245239
public static DataStreamValueSource namespace(String namespace) {
246-
return new DataStreamValueSource(namespace, nsp -> sanitizeDataStreamField(nsp, DISALLOWED_IN_NAMESPACE));
247-
}
248-
249-
private static String sanitizeDataStreamField(String s, Pattern disallowedInDataset) {
250-
if (s == null) {
251-
return null;
252-
}
253-
s = s.toLowerCase(Locale.ROOT);
254-
s = s.substring(0, Math.min(s.length(), MAX_LENGTH));
255-
return disallowedInDataset.matcher(s).replaceAll(REPLACEMENT);
240+
return new DataStreamValueSource(namespace, DataStream::sanitizeNamespace);
256241
}
257242

258243
private DataStreamValueSource(String value, Function<String, String> sanitizer) {

rest-api-spec/src/main/resources/rest-api-spec/api/search_application.delete.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-delete",
55
"description": "Delete a search application"
66
},
7-
"stability": "experimental",
7+
"stability": "beta",
88
"visibility": "public",
99
"headers": {
1010
"accept": [

rest-api-spec/src/main/resources/rest-api-spec/api/search_application.get.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-get",
55
"description": "Get search application details"
66
},
7-
"stability": "experimental",
7+
"stability": "beta",
88
"visibility": "public",
99
"headers": {
1010
"accept": [

rest-api-spec/src/main/resources/rest-api-spec/api/search_application.list.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-get-behavioral-analytics",
55
"description": "Get search applications"
66
},
7-
"stability": "experimental",
7+
"stability": "beta",
88
"visibility": "public",
99
"headers": {
1010
"accept": [

rest-api-spec/src/main/resources/rest-api-spec/api/search_application.put.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-put",
55
"description": "Create or update a search application"
66
},
7-
"stability": "experimental",
7+
"stability": "beta",
88
"visibility": "public",
99
"headers": {
1010
"accept": [

rest-api-spec/src/main/resources/rest-api-spec/api/search_application.search.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-search-application-search",
55
"description": "Run a search application search"
66
},
7-
"stability": "experimental",
7+
"stability": "beta",
88
"visibility": "public",
99
"headers": {
1010
"accept": [

0 commit comments

Comments
 (0)