Skip to content

Commit 12b0d36

Browse files
committed
Merge remote-tracking branch 'kingherc/main' into non-issue/ES-12112-termvectors
2 parents fde5fe0 + c666679 commit 12b0d36

File tree

30 files changed

+671
-118
lines changed

30 files changed

+671
-118
lines changed

docs/changelog/131541.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 131541
2+
summary: Added Sample operator `NamedWritable` to plugin
3+
area: ES|QL
4+
type: bug
5+
issues: []

docs/reference/elasticsearch/jvm-settings.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,18 @@ To override the default heap size, set the minimum and maximum heap size setting
8787

8888
The heap size should be based on the available RAM:
8989

90-
* Set `Xms` and `Xmx` to no more than 50% of your total memory. {{es}} requires memory for purposes other than the JVM heap. For example, {{es}} uses off-heap buffers for efficient network communication and relies on the operating system’s filesystem cache for efficient access to files. The JVM itself also requires some memory. It’s normal for {{es}} to use more memory than the limit configured with the `Xmx` setting.
90+
* Set `Xms` and `Xmx` to no more than 50% of the total memory available to each {{es}} node. {{es}} requires memory for purposes other than the JVM heap. For example, {{es}} uses off-heap buffers for efficient network communication and relies on the operating system’s filesystem cache for efficient access to files. The JVM itself also requires some memory. It’s normal for {{es}} to use more memory than the limit configured with the `Xmx` setting.
9191

9292
::::{note}
93-
When running in a container, such as [Docker](docs-content://deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md), total memory is defined as the amount of memory visible to the container, not the total system memory on the host.
93+
When running in a container, such as [Docker](docs-content://deploy-manage/deploy/self-managed/install-elasticsearch-with-docker.md), the total memory available to {{es}} means the amount of memory available within the container, not the total system memory on the host.
94+
95+
If you are running multiple {{es}} nodes on the same host, or in the same container, the total of all the nodes' heap sizes should not exceed 50% of the total available memory.
96+
97+
Account for the memory usage of other processes running on the same host, or in the same container, when computing the total memory available to {{es}}.
98+
99+
The 50% guideline is intended as a safe upper bound on the heap size. You may find that heap sizes smaller than this maximum offer better performance, for instance by allowing your operating system to use a larger filesystem cache.
100+
101+
If you set the heap size too large, {{es}} may perform poorly and nodes may be terminated by the operating system.
94102
::::
95103

96104
* Set `Xms` and `Xmx` to no more than the threshold for compressed ordinary object pointers (oops). The exact threshold varies but 26GB is safe on most systems and can be as large as 30GB on some systems. To verify you are under the threshold, check the {{es}} log for an entry like this:

docs/reference/elasticsearch/security-privileges.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,20 @@ This section lists the privileges that you can assign to a role.
286286
`create`
287287
: Privilege to index documents.
288288

289-
:::{admonition} Deprecated in 8.0
290-
Also grants the permission to update the index mapping (but not the data streams mapping), using the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or by relying on [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md). In a future major release, this privilege will not grant any mapping update permissions.
291-
:::
292-
293289
::::{note}
294290
This privilege does not restrict the index operation to the creation of documents but instead restricts API use to the index API. The index API allows a user to overwrite a previously indexed document. See the `create_doc` privilege for an alternative.
295291
::::
296292

293+
:::{important}
294+
Starting from 8.0, this privilege no longer grants the permission to update index mappings.
295+
In earlier versions, it implicitly permitted index mapping updates (excluding data stream mappings) via the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or through [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md).
296+
Mapping update capabilities will be fully removed in a future major release.
297+
:::
298+
297299

298300
`create_doc`
299301
: Privilege to index documents. It does not grant the permission to update or overwrite existing documents.
300302

301-
:::{admonition} Deprecated in 8.0
302-
Also grants the permission to update the index mapping (but not the data streams mapping), using the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or by relying on [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md). In a future major release, this privilege will not grant any mapping update permissions.
303-
:::
304-
305303
::::{note}
306304
This privilege relies on the `op_type` of indexing requests ([Index](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-create) and [Bulk](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk)). When ingesting documents as a user who has the `create_doc` privilege (and no higher privilege such as `index` or `write`), you must ensure that *op_type* is set to *create* through one of the following:
307305

@@ -311,6 +309,12 @@ This section lists the privileges that you can assign to a role.
311309

312310
::::
313311

312+
:::{important}
313+
Starting from 8.0, this privilege no longer grants the permission to update index mappings.
314+
In earlier versions, it implicitly permitted index mapping updates (excluding data stream mappings) via the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or through [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md).
315+
Mapping update capabilities will be fully removed in a future major release.
316+
:::
317+
314318

315319
`create_index`
316320
: Privilege to create an index or data stream. A create index request may contain aliases to be added to the index once created. In that case the request requires the `manage` privilege as well, on both the index and the aliases names.
@@ -340,8 +344,10 @@ This section lists the privileges that you can assign to a role.
340344
`index`
341345
: Privilege to index and update documents.
342346

343-
:::{admonition} Deprecated in 8.0
344-
Also grants the permission to update the index mapping (but not the data streams mapping), using the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or by relying on [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md). In a future major release, this privilege will not grant any mapping update permissions.
347+
:::{important}
348+
Starting from 8.0, this privilege no longer grants the permission to update index mappings.
349+
In earlier versions, it implicitly permitted index mapping updates (excluding data stream mappings) via the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or through [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md).
350+
Mapping update capabilities will be fully removed in a future major release.
345351
:::
346352

347353
`maintenance`
@@ -389,8 +395,10 @@ This section lists the privileges that you can assign to a role.
389395
`write`
390396
: Privilege to perform all write operations to documents, which includes the permission to index, update, and delete documents as well as performing bulk operations, while also allowing to dynamically update the index mapping.
391397

392-
:::{admonition} Deprecated in 8.0
393-
It also grants the permission to update the index mapping (but not the data streams mapping), using the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping). This will be retracted in a future major release.
398+
:::{important}
399+
Starting from 8.0, this privilege no longer grants the permission to update index mappings.
400+
In earlier versions, it implicitly permitted index mapping updates (excluding data stream mappings) via the [updating mapping API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-mapping) or through [dynamic field mapping](docs-content://manage-data/data-store/mapping/dynamic-mapping.md).
401+
Mapping update capabilities will be fully removed in a future major release.
394402
:::
395403

396404
## Run as privilege [_run_as_privilege]

modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ public class KibanaPlugin extends Plugin implements SystemIndexPlugin {
3838
.setAllowedElasticProductOrigins(KIBANA_PRODUCT_ORIGIN)
3939
.build();
4040

41+
public static final SystemIndexDescriptor ONECHAT_INDEX_DESCRIPTOR = SystemIndexDescriptor.builder()
42+
.setIndexPattern(".chat-*")
43+
.setDescription("Onechat system index")
44+
.setType(Type.EXTERNAL_UNMANAGED)
45+
.setAllowedElasticProductOrigins(KIBANA_PRODUCT_ORIGIN)
46+
.build();
47+
4148
public static final SystemIndexDescriptor APM_AGENT_CONFIG_INDEX_DESCRIPTOR = SystemIndexDescriptor.builder()
4249
.setIndexPattern(".apm-agent-configuration*")
4350
.setDescription("system index for APM agent configuration")
@@ -57,6 +64,7 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
5764
return List.of(
5865
KIBANA_INDEX_DESCRIPTOR,
5966
REPORTING_INDEX_DESCRIPTOR,
67+
ONECHAT_INDEX_DESCRIPTOR,
6068
APM_AGENT_CONFIG_INDEX_DESCRIPTOR,
6169
APM_CUSTOM_LINK_INDEX_DESCRIPTOR
6270
);

modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class KibanaPluginTests extends ESTestCase {
2020
public void testKibanaIndexNames() {
2121
assertThat(
2222
new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY).stream().map(SystemIndexDescriptor::getIndexPattern).toList(),
23-
contains(".kibana_*", ".reporting-*", ".apm-agent-configuration*", ".apm-custom-link*")
23+
contains(".kibana_*", ".reporting-*", ".chat-*", ".apm-agent-configuration*", ".apm-custom-link*")
2424
);
2525
}
2626
}

modules/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3BlobContainer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,13 @@ void run(BytesReference expected, BytesReference updated, ActionListener<Optiona
830830

831831
.<Void>newForked(l -> ensureOtherUploadsComplete(uploadId, uploadIndex, currentUploads, l))
832832

833-
// Step 4: Read the current register value.
833+
// Step 4: Read the current register value. Note that getRegister only has read-after-write semantics but that's ok here as:
834+
// - all earlier uploads are now complete,
835+
// - our upload is not completing yet, and
836+
// - later uploads can only be completing if they have already aborted ours.
837+
// Thus if our operation ultimately succeeds then there cannot have been any concurrent writes in flight, so this read
838+
// cannot have observed a stale value, whereas if our operation ultimately fails then it doesn't matter what this read
839+
// observes.
834840

835841
.<OptionalBytesReference>andThen(l -> getRegister(purpose, rawKey, l))
836842

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ tests:
490490
- class: org.elasticsearch.test.rest.yaml.RcsCcsCommonYamlTestSuiteIT
491491
method: test {p0=search/40_indices_boost/Indices boost with alias}
492492
issue: https://github.com/elastic/elasticsearch/issues/131598
493+
- class: org.elasticsearch.compute.lucene.read.SortedSetOrdinalsBuilderTests
494+
method: testReader
495+
issue: https://github.com/elastic/elasticsearch/issues/131573
493496

494497
# Examples:
495498
#

server/src/internalClusterTest/java/org/elasticsearch/search/sort/FieldSortIT.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package org.elasticsearch.search.sort;
1111

12+
import org.apache.http.util.EntityUtils;
1213
import org.apache.lucene.tests.util.TestUtil;
1314
import org.apache.lucene.util.BytesRef;
1415
import org.apache.lucene.util.UnicodeUtil;
@@ -20,6 +21,9 @@
2021
import org.elasticsearch.action.search.SearchRequestBuilder;
2122
import org.elasticsearch.action.search.SearchResponse;
2223
import org.elasticsearch.action.search.ShardSearchFailure;
24+
import org.elasticsearch.client.Request;
25+
import org.elasticsearch.client.Response;
26+
import org.elasticsearch.client.RestClient;
2327
import org.elasticsearch.cluster.metadata.IndexMetadata;
2428
import org.elasticsearch.common.settings.Settings;
2529
import org.elasticsearch.core.Strings;
@@ -36,6 +40,7 @@
3640
import org.elasticsearch.search.SearchHits;
3741
import org.elasticsearch.test.ESIntegTestCase;
3842
import org.elasticsearch.test.InternalSettingsPlugin;
43+
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
3944
import org.elasticsearch.xcontent.XContentBuilder;
4045
import org.elasticsearch.xcontent.XContentFactory;
4146
import org.elasticsearch.xcontent.XContentType;
@@ -84,6 +89,12 @@
8489
import static org.hamcrest.Matchers.not;
8590
import static org.hamcrest.Matchers.nullValue;
8691

92+
@TestIssueLogging(
93+
issueUrl = "https://github.com/elastic/elasticsearch/issues/129445",
94+
value = "org.elasticsearch.action.search.SearchQueryThenFetchAsyncAction:DEBUG,"
95+
+ "org.elasticsearch.action.search.SearchPhaseController:DEBUG,"
96+
+ "org.elasticsearch.search:TRACE"
97+
)
8798
public class FieldSortIT extends ESIntegTestCase {
8899
public static class CustomScriptPlugin extends MockScriptPlugin {
89100
@Override
@@ -112,6 +123,10 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
112123
return Arrays.asList(InternalSettingsPlugin.class, CustomScriptPlugin.class);
113124
}
114125

126+
protected boolean addMockHttpTransport() {
127+
return false;
128+
}
129+
115130
public void testIssue8226() {
116131
int numIndices = between(5, 10);
117132
final boolean useMapping = randomBoolean();
@@ -2145,7 +2160,7 @@ public void testLongSortOptimizationCorrectResults() {
21452160
);
21462161
}
21472162

2148-
public void testSortMixedFieldTypes() {
2163+
public void testSortMixedFieldTypes() throws IOException {
21492164
assertAcked(
21502165
prepareCreate("index_long").setMapping("foo", "type=long"),
21512166
prepareCreate("index_integer").setMapping("foo", "type=integer"),
@@ -2159,6 +2174,16 @@ public void testSortMixedFieldTypes() {
21592174
prepareIndex("index_keyword").setId("1").setSource("foo", "123").get();
21602175
refresh();
21612176

2177+
// for debugging, we try to see where the documents are located
2178+
try (RestClient restClient = createRestClient()) {
2179+
Request checkShardsRequest = new Request(
2180+
"GET",
2181+
"/_cat/shards/index_long,index_double,index_keyword?format=json&h=index,node,shard,prirep,state,docs,index"
2182+
);
2183+
Response response = restClient.performRequest(checkShardsRequest);
2184+
logger.info("FieldSortIT#testSortMixedFieldTypes document distribution: " + EntityUtils.toString(response.getEntity()));
2185+
}
2186+
21622187
{ // mixing long and integer types is ok, as we convert integer sort to long sort
21632188
assertNoFailures(prepareSearch("index_long", "index_integer").addSort(new FieldSortBuilder("foo")).setSize(10));
21642189
}

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ static TransportVersion def(int id) {
330330
public static final TransportVersion MAPPINGS_IN_DATA_STREAMS = def(9_112_0_00);
331331
public static final TransportVersion ESQL_SPLIT_ON_BIG_VALUES_9_1 = def(9_112_0_01);
332332
public static final TransportVersion ESQL_FIXED_INDEX_LIKE_9_1 = def(9_112_0_02);
333+
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS_9_1 = def(9_112_0_03);
333334
// Below is the first version in 9.2 and NOT in 9.1.
334335
public static final TransportVersion PROJECT_STATE_REGISTRY_RECORDS_DELETIONS = def(9_113_0_00);
335336
public static final TransportVersion ESQL_SERIALIZE_TIMESERIES_FIELD_TYPE = def(9_114_0_00);
@@ -345,6 +346,7 @@ static TransportVersion def(int id) {
345346
public static final TransportVersion PROJECT_STATE_REGISTRY_ENTRY = def(9_124_0_00);
346347
public static final TransportVersion ML_INFERENCE_LLAMA_ADDED = def(9_125_0_00);
347348
public static final TransportVersion SHARD_WRITE_LOAD_IN_CLUSTER_INFO = def(9_126_0_00);
349+
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS = def(9_127_0_00);
348350

349351
/*
350352
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/action/search/SearchPhaseController.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.action.search;
1111

12+
import org.apache.logging.log4j.LogManager;
13+
import org.apache.logging.log4j.Logger;
1214
import org.apache.lucene.search.FieldDoc;
1315
import org.apache.lucene.search.ScoreDoc;
1416
import org.apache.lucene.search.Sort;
@@ -72,6 +74,8 @@
7274

7375
public final class SearchPhaseController {
7476

77+
private static final Logger logger = LogManager.getLogger(SearchPhaseController.class);
78+
7579
private final BiFunction<
7680
Supplier<Boolean>,
7781
AggregatorFactories.Builder,
@@ -153,17 +157,22 @@ static TopDocs mergeTopDocs(List<TopDocs> results, int topN, int from) {
153157
return topDocs;
154158
}
155159
final TopDocs mergedTopDocs;
156-
if (topDocs instanceof TopFieldGroups firstTopDocs) {
157-
final Sort sort = validateSameSortTypesAndMaybeRewrite(results, firstTopDocs.fields);
158-
TopFieldGroups[] shardTopDocs = topDocsList.toArray(new TopFieldGroups[0]);
159-
mergedTopDocs = TopFieldGroups.merge(sort, from, topN, shardTopDocs, false);
160-
} else if (topDocs instanceof TopFieldDocs firstTopDocs) {
161-
TopFieldDocs[] shardTopDocs = topDocsList.toArray(new TopFieldDocs[0]);
162-
final Sort sort = validateSameSortTypesAndMaybeRewrite(results, firstTopDocs.fields);
163-
mergedTopDocs = TopDocs.merge(sort, from, topN, shardTopDocs);
164-
} else {
165-
final TopDocs[] shardTopDocs = topDocsList.toArray(new TopDocs[0]);
166-
mergedTopDocs = TopDocs.merge(from, topN, shardTopDocs);
160+
try {
161+
if (topDocs instanceof TopFieldGroups firstTopDocs) {
162+
final Sort sort = validateSameSortTypesAndMaybeRewrite(results, firstTopDocs.fields);
163+
TopFieldGroups[] shardTopDocs = topDocsList.toArray(new TopFieldGroups[0]);
164+
mergedTopDocs = TopFieldGroups.merge(sort, from, topN, shardTopDocs, false);
165+
} else if (topDocs instanceof TopFieldDocs firstTopDocs) {
166+
TopFieldDocs[] shardTopDocs = topDocsList.toArray(new TopFieldDocs[0]);
167+
final Sort sort = validateSameSortTypesAndMaybeRewrite(results, firstTopDocs.fields);
168+
mergedTopDocs = TopDocs.merge(sort, from, topN, shardTopDocs);
169+
} else {
170+
final TopDocs[] shardTopDocs = topDocsList.toArray(new TopDocs[0]);
171+
mergedTopDocs = TopDocs.merge(from, topN, shardTopDocs);
172+
}
173+
} catch (IllegalArgumentException e) {
174+
logger.debug("Failed to merge top docs: ", e);
175+
throw e;
167176
}
168177
return mergedTopDocs;
169178
}

0 commit comments

Comments
 (0)