Skip to content

Commit aff64ec

Browse files
authored
Merge branch 'main' into feature/use-new-lucene-scorers
2 parents 7a77fbc + 64b8574 commit aff64ec

File tree

100 files changed

+2496
-346
lines changed

Some content is hidden

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

100 files changed

+2496
-346
lines changed

docs/changelog/135051.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@ summary: Ban Limit + `MvExpand` before remote Enrich
33
area: ES|QL
44
type: bug
55
issues: []
6+
highlight:
7+
title: Prevent LIMIT + MV_EXPAND before remote ENRICH
8+
body: |-
9+
Queries using LIMIT followed by MV_EXPAND before a remote ENRICH can produce incorrect results due to distributed execution semantics.
10+
These queries are now unsupported and produce an error. Example:
11+
[source,yaml]
12+
----------------------------
13+
FROM *:events | SORT @timestamp | LIMIT 2 | MV_EXPAND ip | ENRICH _remote:clientip_policy ON ip
14+
----------------------------
15+
To avoid this error, reorder your query, for example by moving ENRICH earlier in the pipeline.

docs/changelog/135204.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 135204
2+
summary: Make `_tsid` available in metadata
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 133205

docs/changelog/135337.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135337
2+
summary: Do not pass `ProjectMetadata` to lazy index permissions builder
3+
area: Security
4+
type: enhancement
5+
issues: []

docs/reference/enrich-processor/geoip-processor.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,18 @@ PUT my_ip_locations
206206

207207
If you can’t [automatically update](#geoip-automatic-updates) your IP geolocation databases from the Elastic endpoint, you have a few other options:
208208

209-
* [Use a proxy endpoint](#use-proxy-geoip-endpoint)
209+
* [Use a reverse proxy endpoint](#use-proxy-geoip-endpoint)
210210
* [Use a custom endpoint](#use-custom-geoip-endpoint)
211211
* [Manually update your IP geolocation databases](#manually-update-geoip-databases)
212212

213213
$$$use-proxy-geoip-endpoint$$$
214-
**Use a proxy endpoint**
214+
**Use a reverse proxy endpoint**
215215

216-
If you can’t connect directly to the Elastic GeoIP endpoint, consider setting up a secure proxy. You can then specify the proxy endpoint URL in the [`ingest.geoip.downloader.endpoint`](#ingest-geoip-downloader-endpoint) setting of each node’s `elasticsearch.yml` file.
216+
If you can’t connect directly to the Elastic GeoIP endpoint, consider setting up a secure reverse proxy. You can then specify the reverse proxy endpoint URL in the [`ingest.geoip.downloader.endpoint`](#ingest-geoip-downloader-endpoint) setting of each node’s `elasticsearch.yml` file.
217+
218+
:::{note}
219+
True HTTP proxy support for GeoIP database downloads is not currently available in {{es}}.
220+
:::
217221

218222
In a strict setup the following domains may need to be added to the allowed domains list:
219223

docs/reference/query-languages/esql/_snippets/functions/description/count_distinct.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/count_distinct.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/functions/count_distinct.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/ESUTF8StreamJsonParser.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
import java.util.ArrayList;
2626
import java.util.List;
2727

28+
/**
29+
* Provides the method getValueAsText that is a best-effort optimization for UTF8 fields. If the
30+
* {@link UTF8StreamJsonParser} has already parsed the text, then the caller should fall back to getText.
31+
* This is sufficient because when we call getText, jackson stores the parsed UTF-16 value for future calls.
32+
* Once we've already got the parsed UTF-16 value, the optimization isn't necessary.
33+
*/
2834
public class ESUTF8StreamJsonParser extends UTF8StreamJsonParser implements OptimizedTextCapable {
2935
protected int stringEnd = -1;
3036
protected int stringLength;
@@ -53,6 +59,7 @@ public ESUTF8StreamJsonParser(
5359
*/
5460
@Override
5561
public Text getValueAsText() throws IOException {
62+
// _tokenIncomplete is true when UTF8StreamJsonParser has already processed this value.
5663
if (_currToken == JsonToken.VALUE_STRING && _tokenIncomplete) {
5764
if (lastOptimisedValue != null) {
5865
return new Text(new XContentString.UTF8Bytes(lastOptimisedValue), stringLength);
@@ -148,33 +155,33 @@ protected Text _finishAndReturnText() throws IOException {
148155

149156
@Override
150157
public JsonToken nextToken() throws IOException {
151-
maybeResetCurrentTokenState();
152-
stringEnd = -1;
158+
resetCurrentTokenState();
153159
return super.nextToken();
154160
}
155161

156162
@Override
157163
public boolean nextFieldName(SerializableString str) throws IOException {
158-
maybeResetCurrentTokenState();
159-
stringEnd = -1;
164+
resetCurrentTokenState();
160165
return super.nextFieldName(str);
161166
}
162167

163168
@Override
164169
public String nextFieldName() throws IOException {
165-
maybeResetCurrentTokenState();
166-
stringEnd = -1;
170+
resetCurrentTokenState();
167171
return super.nextFieldName();
168172
}
169173

170174
/**
171-
* Resets the current token state before moving to the next.
175+
* Resets the current token state before moving to the next. It resets the _inputPtr and the
176+
* _tokenIncomplete only if {@link UTF8StreamJsonParser#getText()} or {@link UTF8StreamJsonParser#getValueAsString()}
177+
* hasn't run yet.
172178
*/
173-
private void maybeResetCurrentTokenState() {
179+
private void resetCurrentTokenState() {
174180
if (_currToken == JsonToken.VALUE_STRING && _tokenIncomplete && stringEnd > 0) {
175181
_inputPtr = stringEnd;
176182
_tokenIncomplete = false;
177-
lastOptimisedValue = null;
178183
}
184+
lastOptimisedValue = null;
185+
stringEnd = -1;
179186
}
180187
}

libs/x-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentParser.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.fasterxml.jackson.core.JsonToken;
1717
import com.fasterxml.jackson.core.exc.InputCoercionException;
1818
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
19+
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
1920
import com.fasterxml.jackson.core.io.JsonEOFException;
2021

2122
import org.elasticsearch.core.IOUtils;
@@ -26,6 +27,7 @@
2627
import org.elasticsearch.xcontent.XContentParserConfiguration;
2728
import org.elasticsearch.xcontent.XContentString;
2829
import org.elasticsearch.xcontent.XContentType;
30+
import org.elasticsearch.xcontent.provider.OptimizedTextCapable;
2931
import org.elasticsearch.xcontent.provider.XContentParserConfigurationImpl;
3032
import org.elasticsearch.xcontent.support.AbstractXContentParser;
3133

@@ -143,7 +145,19 @@ public String text() throws IOException {
143145

144146
@Override
145147
public XContentString optimizedText() throws IOException {
146-
// TODO: enable utf-8 parsing optimization once verified it is completely safe
148+
if (currentToken().isValue() == false) {
149+
throwOnNoText();
150+
}
151+
var parser = this.parser;
152+
if (parser instanceof FilteringParserDelegate delegate) {
153+
parser = delegate.delegate();
154+
}
155+
if (parser instanceof OptimizedTextCapable optimizedTextCapableParser) {
156+
var bytesRef = optimizedTextCapableParser.getValueAsText();
157+
if (bytesRef != null) {
158+
return bytesRef;
159+
}
160+
}
147161
return new Text(text());
148162
}
149163

libs/x-content/impl/src/test/java/org/elasticsearch/xcontent/provider/cbor/ESCborParserTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Map;
2424

2525
import static org.hamcrest.Matchers.equalTo;
26+
import static org.hamcrest.Matchers.nullValue;
2627

2728
public class ESCborParserTests extends ESTestCase {
2829

@@ -54,8 +55,15 @@ private void testStringValue(String expected) throws IOException {
5455
assertThat(text.hasBytes(), equalTo(true));
5556
assertThat(text.stringLength(), equalTo(expected.length()));
5657
assertThat(text.string(), equalTo(expected));
58+
// Retrieve twice
5759
assertThat(parser.getValueAsText().string(), equalTo(expected));
5860
assertThat(parser.getValueAsString(), equalTo(expected));
61+
// Use the getText() to ensure _tokenIncomplete works
62+
assertThat(parser.getText(), equalTo(expected));
63+
// The optimisation is not used after the getText()
64+
assertThat(parser.getValueAsText(), nullValue());
65+
// Original CBOR getValueAsString works.
66+
assertThat(parser.getValueAsString(), equalTo(expected));
5967
assertThat(parser.nextToken(), equalTo(JsonToken.END_OBJECT));
6068
}
6169
}

0 commit comments

Comments
 (0)