mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
Use CLDR locale provider on JDK 23+ (#110222)
JDK 23 removes the COMPAT locale provider, leaving CLDR as the only option. This commit configures Elasticsearch to use the CLDR provider when on JDK 23, but still use the existing COMPAT provider when on JDK 22 and below. This causes some differences in locale behaviour; this also adapts various tests to still work whether run on COMPAT or CLDR.
This commit is contained in:
parent
0074c14bfa
commit
a36d90cf34
30 changed files with 73 additions and 92 deletions
|
@ -167,7 +167,7 @@ if (providers.systemProperty('idea.active').getOrNull() == 'true') {
|
|||
vmParameters = [
|
||||
'-ea',
|
||||
'-Djava.security.manager=allow',
|
||||
'-Djava.locale.providers=SPI,COMPAT',
|
||||
'-Djava.locale.providers=SPI,CLDR',
|
||||
'-Des.nativelibs.path="' + testLibraryPath + '"',
|
||||
// TODO: only open these for mockito when it is modularized
|
||||
'--add-opens=java.base/java.security.cert=ALL-UNNAMED',
|
||||
|
|
|
@ -92,7 +92,7 @@ public abstract class ElasticsearchTestBasePlugin implements Plugin<Project> {
|
|||
mkdirs(test.getWorkingDir().toPath().resolve("temp").toFile());
|
||||
|
||||
// TODO remove once jvm.options are added to test system properties
|
||||
test.systemProperty("java.locale.providers", "SPI,COMPAT");
|
||||
test.systemProperty("java.locale.providers", "SPI,CLDR");
|
||||
}
|
||||
});
|
||||
test.getJvmArgumentProviders().add(nonInputProperties);
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.elasticsearch.server.cli;
|
|||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.core.UpdateForV9;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -59,11 +60,7 @@ final class SystemJvmOptions {
|
|||
"-Dlog4j.shutdownHookEnabled=false",
|
||||
"-Dlog4j2.disable.jmx=true",
|
||||
"-Dlog4j2.formatMsgNoLookups=true",
|
||||
/*
|
||||
* Due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise time/date
|
||||
* parsing will break in an incompatible way for some date patterns and locales.
|
||||
*/
|
||||
"-Djava.locale.providers=SPI,COMPAT",
|
||||
"-Djava.locale.providers=" + getLocaleProviders(),
|
||||
maybeEnableNativeAccess(),
|
||||
maybeOverrideDockerCgroup(distroType),
|
||||
maybeSetActiveProcessorCount(nodeSettings),
|
||||
|
@ -75,6 +72,16 @@ final class SystemJvmOptions {
|
|||
).filter(e -> e.isEmpty() == false).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@UpdateForV9 // only use CLDR in v9+
|
||||
private static String getLocaleProviders() {
|
||||
/*
|
||||
* Specify SPI to load IsoCalendarDataProvider (see #48209), specifying the first day of week as Monday.
|
||||
* When on pre-23, use COMPAT instead to maintain existing date formats as much as we can.
|
||||
* When on JDK 23+, use the default CLDR locale database, as COMPAT was removed in JDK 23.
|
||||
*/
|
||||
return Runtime.version().feature() >= 23 ? "SPI,CLDR" : "SPI,COMPAT";
|
||||
}
|
||||
|
||||
/*
|
||||
* The virtual file /proc/self/cgroup should list the current cgroup
|
||||
* membership. For each hierarchy, you can follow the cgroup path from
|
||||
|
|
|
@ -71,7 +71,7 @@ GET seats/_search
|
|||
"script_fields": {
|
||||
"day-of-week": {
|
||||
"script": {
|
||||
"source": "doc['datetime'].value.getDayOfWeekEnum().getDisplayName(TextStyle.FULL, Locale.ROOT)"
|
||||
"source": "doc['datetime'].value.getDayOfWeekEnum().getDisplayName(TextStyle.FULL, Locale.ENGLISH)"
|
||||
}
|
||||
},
|
||||
"number-of-actors": {
|
||||
|
|
|
@ -749,7 +749,7 @@ POST /_scripts/painless/_execute
|
|||
{
|
||||
"script": {
|
||||
"source": """
|
||||
emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
"""
|
||||
},
|
||||
"context": "keyword_field",
|
||||
|
|
|
@ -156,7 +156,7 @@ GET /_search
|
|||
"type": "keyword",
|
||||
"script": """
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum
|
||||
.getDisplayName(TextStyle.FULL, Locale.ROOT))
|
||||
.getDisplayName(TextStyle.FULL, Locale.ENGLISH))
|
||||
"""
|
||||
}
|
||||
},
|
||||
|
|
|
@ -819,7 +819,7 @@ POST /sales/_search?size=0
|
|||
"runtime_mappings": {
|
||||
"date.day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": "emit(doc['date'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"script": "emit(doc['date'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
},
|
||||
"aggs": {
|
||||
|
|
|
@ -102,7 +102,7 @@ PUT _component_template/runtime_component_template
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ PUT my-index-000001/
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -291,7 +291,7 @@ GET my-index-000001/_search
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -667,7 +667,7 @@ PUT my-index-000001/
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -951,7 +951,7 @@ For example:
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ GET /my-index-000001/_search
|
|||
"script": {
|
||||
"source":
|
||||
"""emit(doc['@timestamp'].value.dayOfWeekEnum
|
||||
.getDisplayName(TextStyle.FULL, Locale.ROOT))"""
|
||||
.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"""
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -12,7 +12,7 @@ setup:
|
|||
script:
|
||||
source: |
|
||||
for (date in field('date')) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
total_value_double:
|
||||
type: double
|
||||
|
@ -55,7 +55,7 @@ setup:
|
|||
source: |
|
||||
if (doc.containsKey('date')) {
|
||||
for (date in doc['date']) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
doc_total_value_double:
|
||||
|
@ -737,7 +737,7 @@ setup:
|
|||
script:
|
||||
source: |
|
||||
for (date in field('date')) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
script_fields:
|
||||
|
@ -758,7 +758,7 @@ setup:
|
|||
script:
|
||||
source: |
|
||||
for (date in field('date')) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
script_fields:
|
||||
|
@ -924,7 +924,7 @@ setup:
|
|||
source: |
|
||||
if (doc.containsKey('date')) {
|
||||
for (date in doc['date']) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
|
@ -947,7 +947,7 @@ setup:
|
|||
source: |
|
||||
if (doc.containsKey('date')) {
|
||||
for (date in doc['date']) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
|
@ -1133,7 +1133,7 @@ setup:
|
|||
script:
|
||||
source: |
|
||||
for (date in field('date')) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
script_fields:
|
||||
|
@ -1156,7 +1156,7 @@ setup:
|
|||
script:
|
||||
source: |
|
||||
for (date in field('date')) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
script_fields:
|
||||
|
@ -1337,7 +1337,7 @@ setup:
|
|||
source: |
|
||||
if (doc.containsKey('date')) {
|
||||
for (date in doc['date']) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
|
@ -1362,7 +1362,7 @@ setup:
|
|||
source: |
|
||||
if (doc.containsKey('date')) {
|
||||
for (date in doc['date']) {
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(date.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
sort: [ { rank: asc } ]
|
||||
|
|
|
@ -12,7 +12,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script: |
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
# Test fetching from _source
|
||||
day_of_week_from_source:
|
||||
type: keyword
|
||||
|
@ -75,7 +75,7 @@ setup:
|
|||
- match: {sensor.mappings.runtime.day_of_week.type: keyword }
|
||||
- match:
|
||||
sensor.mappings.runtime.day_of_week.script.source: |
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
- match: {sensor.mappings.runtime.day_of_week.script.lang: painless }
|
||||
|
||||
# --- TODO get field mappings needs to be adapted
|
||||
|
@ -90,7 +90,7 @@ setup:
|
|||
# type: keyword
|
||||
# script:
|
||||
# source: |
|
||||
# emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
# emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
# lang: painless
|
||||
# meta: {}
|
||||
#
|
||||
|
|
|
@ -21,7 +21,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script: |
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
# Test fetching from _source
|
||||
day_of_week_from_source:
|
||||
type: keyword
|
||||
|
@ -74,7 +74,7 @@ setup:
|
|||
- match: {sensor.mappings.properties.day_of_week.type: keyword }
|
||||
- match:
|
||||
sensor.mappings.properties.day_of_week.script.source: |
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
- match: {sensor.mappings.properties.day_of_week.script.lang: painless }
|
||||
|
||||
---
|
||||
|
|
|
@ -34,7 +34,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script:
|
||||
source: "emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
source: "emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
|
||||
- match: {indices: ["test-1"]}
|
||||
- length: {fields.timestamp: 1}
|
||||
|
@ -78,7 +78,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script:
|
||||
source: "emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
source: "emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
|
||||
- match: {indices: ["test-1", "test-2"]}
|
||||
- length: {fields.day_of_week: 1}
|
||||
|
|
|
@ -12,7 +12,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script: |
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));
|
||||
emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));
|
||||
tomorrow:
|
||||
type: date
|
||||
script:
|
||||
|
|
|
@ -1,25 +1,10 @@
|
|||
tests:
|
||||
- class: "org.elasticsearch.xpack.textstructure.structurefinder.TimestampFormatFinderTests"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/108855"
|
||||
method: "testGuessIsDayFirstFromLocale"
|
||||
- class: "org.elasticsearch.test.rest.ClientYamlTestSuiteIT"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/108857"
|
||||
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale dependent mappings / dates}"
|
||||
- class: "org.elasticsearch.upgrades.SearchStatesIT"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/108991"
|
||||
method: "testCanMatch"
|
||||
- class: "org.elasticsearch.upgrades.MlTrainedModelsUpgradeIT"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/108993"
|
||||
method: "testTrainedModelInference"
|
||||
- class: "org.elasticsearch.xpack.security.CoreWithSecurityClientYamlTestSuiteIT"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/109188"
|
||||
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale dependent mappings / dates}"
|
||||
- class: "org.elasticsearch.xpack.esql.qa.mixed.EsqlClientYamlIT"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/109189"
|
||||
method: "test {p0=esql/70_locale/Date format with Italian locale}"
|
||||
- class: "org.elasticsearch.xpack.test.rest.XPackRestIT"
|
||||
issue: "https://github.com/elastic/elasticsearch/issues/109200"
|
||||
method: "test {p0=esql/70_locale/Date format with Italian locale}"
|
||||
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
|
||||
method: test {yaml=reference/esql/esql-async-query-api/line_17}
|
||||
issue: https://github.com/elastic/elasticsearch/issues/109260
|
||||
|
|
|
@ -13,7 +13,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script:
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
|
|
|
@ -9,7 +9,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script:
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
|
|
|
@ -11,26 +11,26 @@
|
|||
date_field:
|
||||
type: date
|
||||
format: "E, d MMM yyyy HH:mm:ss Z"
|
||||
locale: "de"
|
||||
locale: "fr"
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
body:
|
||||
- '{"index": {"_index": "test_index", "_id": "1"}}'
|
||||
- '{"date_field": "Mi, 06 Dez 2000 02:55:00 -0800"}'
|
||||
- '{"date_field": "mer., 6 déc. 2000 02:55:00 -0800"}'
|
||||
- '{"index": {"_index": "test_index", "_id": "2"}}'
|
||||
- '{"date_field": "Do, 07 Dez 2000 02:55:00 -0800"}'
|
||||
- '{"date_field": "jeu., 7 déc. 2000 02:55:00 -0800"}'
|
||||
|
||||
- do:
|
||||
search:
|
||||
rest_total_hits_as_int: true
|
||||
index: test_index
|
||||
body: {"query" : {"range" : {"date_field" : {"gte": "Di, 05 Dez 2000 02:55:00 -0800", "lte": "Do, 07 Dez 2000 00:00:00 -0800"}}}}
|
||||
body: {"query" : {"range" : {"date_field" : {"gte": "mar., 5 déc. 2000 02:55:00 -0800", "lte": "jeu., 7 déc. 2000 00:00:00 -0800"}}}}
|
||||
- match: { hits.total: 1 }
|
||||
|
||||
- do:
|
||||
search:
|
||||
rest_total_hits_as_int: true
|
||||
index: test_index
|
||||
body: {"query" : {"range" : {"date_field" : {"gte": "Di, 05 Dez 2000 02:55:00 -0800", "lte": "Fr, 08 Dez 2000 00:00:00 -0800"}}}}
|
||||
body: {"query" : {"range" : {"date_field" : {"gte": "mar., 5 déc. 2000 02:55:00 -0800", "lte": "ven., 8 déc. 2000 00:00:00 -0800"}}}}
|
||||
- match: { hits.total: 2 }
|
||||
|
|
|
@ -1629,14 +1629,8 @@ public class SearchQueryIT extends ESIntegTestCase {
|
|||
* Test range with a custom locale, e.g. "de" in this case. Documents here mention the day of week
|
||||
* as "Mi" for "Mittwoch (Wednesday" and "Do" for "Donnerstag (Thursday)" and the month in the query
|
||||
* as "Dez" for "Dezember (December)".
|
||||
* Note: this test currently needs the JVM arg `-Djava.locale.providers=SPI,COMPAT` to be set.
|
||||
* When running with gradle this is done implicitly through the BuildPlugin, but when running from
|
||||
* an IDE this might need to be set manually in the run configuration. See also CONTRIBUTING.md section
|
||||
* on "Configuring IDEs And Running Tests".
|
||||
*/
|
||||
public void testRangeQueryWithLocaleMapping() throws Exception {
|
||||
assert ("SPI,COMPAT".equals(System.getProperty("java.locale.providers"))) : "`-Djava.locale.providers=SPI,COMPAT` needs to be set";
|
||||
|
||||
assertAcked(
|
||||
prepareCreate("test").setMapping(
|
||||
jsonBuilder().startObject()
|
||||
|
@ -1644,7 +1638,7 @@ public class SearchQueryIT extends ESIntegTestCase {
|
|||
.startObject("date_field")
|
||||
.field("type", "date")
|
||||
.field("format", "E, d MMM yyyy HH:mm:ss Z")
|
||||
.field("locale", "de")
|
||||
.field("locale", "fr")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
|
@ -1653,19 +1647,19 @@ public class SearchQueryIT extends ESIntegTestCase {
|
|||
|
||||
indexRandom(
|
||||
true,
|
||||
prepareIndex("test").setId("1").setSource("date_field", "Mi, 06 Dez 2000 02:55:00 -0800"),
|
||||
prepareIndex("test").setId("2").setSource("date_field", "Do, 07 Dez 2000 02:55:00 -0800")
|
||||
prepareIndex("test").setId("1").setSource("date_field", "mer., 6 déc. 2000 02:55:00 -0800"),
|
||||
prepareIndex("test").setId("2").setSource("date_field", "jeu., 7 déc. 2000 02:55:00 -0800")
|
||||
);
|
||||
|
||||
assertHitCount(
|
||||
prepareSearch("test").setQuery(
|
||||
QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Do, 07 Dez 2000 00:00:00 -0800")
|
||||
QueryBuilders.rangeQuery("date_field").gte("mar., 5 déc. 2000 02:55:00 -0800").lte("jeu., 7 déc. 2000 00:00:00 -0800")
|
||||
),
|
||||
1L
|
||||
);
|
||||
assertHitCount(
|
||||
prepareSearch("test").setQuery(
|
||||
QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Fr, 08 Dez 2000 00:00:00 -0800")
|
||||
QueryBuilders.rangeQuery("date_field").gte("mar., 5 déc. 2000 02:55:00 -0800").lte("ven., 8 déc. 2000 00:00:00 -0800")
|
||||
),
|
||||
2L
|
||||
);
|
||||
|
|
|
@ -270,7 +270,7 @@ public class ReservedComposableIndexTemplateActionTests extends ESTestCase {
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ public class ReservedComposableIndexTemplateActionTests extends ESTestCase {
|
|||
"day_of_week": {
|
||||
"type": "keyword",
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -880,11 +880,11 @@ public class DateFormattersTests extends ESTestCase {
|
|||
|
||||
public void testCustomLocales() {
|
||||
// also ensure that locale based dates are the same
|
||||
DateFormatter formatter = DateFormatter.forPattern("E, d MMM yyyy HH:mm:ss Z").withLocale(LocaleUtils.parse("de"));
|
||||
assertParses("Di, 05 Dez 2000 02:55:00 -0800", formatter);
|
||||
assertParses("Mi, 06 Dez 2000 02:55:00 -0800", formatter);
|
||||
assertParses("Do, 07 Dez 2000 00:00:00 -0800", formatter);
|
||||
assertParses("Fr, 08 Dez 2000 00:00:00 -0800", formatter);
|
||||
DateFormatter formatter = DateFormatter.forPattern("E, d MMM yyyy HH:mm:ss Z").withLocale(LocaleUtils.parse("fr"));
|
||||
assertParses("mar., 5 déc. 2000 02:55:00 -0800", formatter);
|
||||
assertParses("mer., 6 déc. 2000 02:55:00 -0800", formatter);
|
||||
assertParses("jeu., 7 déc. 2000 00:00:00 -0800", formatter);
|
||||
assertParses("ven., 8 déc. 2000 00:00:00 -0800", formatter);
|
||||
}
|
||||
|
||||
public void testFormatsValidParsing() {
|
||||
|
|
|
@ -183,10 +183,10 @@ public class DateFieldMapperTests extends MapperTestCase {
|
|||
|
||||
public void testChangeLocale() throws IOException {
|
||||
DocumentMapper mapper = createDocumentMapper(
|
||||
fieldMapping(b -> b.field("type", "date").field("format", "E, d MMM yyyy HH:mm:ss Z").field("locale", "de"))
|
||||
fieldMapping(b -> b.field("type", "date").field("format", "E, d MMM yyyy HH:mm:ss Z").field("locale", "fr"))
|
||||
);
|
||||
|
||||
mapper.parse(source(b -> b.field("field", "Mi, 06 Dez 2000 02:55:00 -0800")));
|
||||
mapper.parse(source(b -> b.field("field", "mer., 6 déc. 2000 02:55:00 -0800")));
|
||||
}
|
||||
|
||||
public void testNullValue() throws IOException {
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
|||
public class LicenseUtils {
|
||||
|
||||
public static final String EXPIRED_FEATURE_METADATA = "es.license.expired.feature";
|
||||
public static final DateFormatter DATE_FORMATTER = DateFormatter.forPattern("EEEE, MMMM dd, yyyy");
|
||||
public static final DateFormatter DATE_FORMATTER = DateFormatter.forPattern("EEEE, MMMM dd, yyyy").withLocale(Locale.ENGLISH);
|
||||
|
||||
/**
|
||||
* Exception to be thrown when a feature action requires a valid license, but license
|
||||
|
|
|
@ -65,11 +65,6 @@ import static org.mockito.Mockito.times;
|
|||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Due to changes in JDK9 where locale data is used from CLDR, the licence message will differ in jdk 8 and jdk9+
|
||||
* https://openjdk.java.net/jeps/252
|
||||
* We run ES with -Djava.locale.providers=SPI,COMPAT and same option has to be applied when running this test from IDE
|
||||
*/
|
||||
public class ClusterStateLicenseServiceTests extends ESTestCase {
|
||||
|
||||
// must use member mock for generic
|
||||
|
|
|
@ -13,7 +13,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script:
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
|
|
|
@ -9,7 +9,7 @@ setup:
|
|||
day_of_week:
|
||||
type: keyword
|
||||
script:
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
|
||||
source: "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))"
|
||||
- do:
|
||||
bulk:
|
||||
refresh: true
|
||||
|
|
|
@ -157,12 +157,12 @@ public class DateTimeFormatProcessorTests extends AbstractSqlWireSerializingTest
|
|||
new DateTimeFormat(Source.EMPTY, dateTime, l("YYYY-MM-dd HH:mm:ss.SSSSSSSS"), zoneId).makePipe().asProcessor().process(null)
|
||||
);
|
||||
assertEquals("+1000", new DateTimeFormat(Source.EMPTY, dateTime, l("Z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("Etc/GMT-10", new DateTimeFormat(Source.EMPTY, dateTime, l("z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("GMT+10:00", new DateTimeFormat(Source.EMPTY, dateTime, l("z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("Etc/GMT-10", new DateTimeFormat(Source.EMPTY, dateTime, l("VV"), zoneId).makePipe().asProcessor().process(null));
|
||||
|
||||
zoneId = ZoneId.of("America/Sao_Paulo");
|
||||
assertEquals("-0300", new DateTimeFormat(Source.EMPTY, dateTime, l("Z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("BRT", new DateTimeFormat(Source.EMPTY, dateTime, l("z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("GMT-03:00", new DateTimeFormat(Source.EMPTY, dateTime, l("z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals(
|
||||
"America/Sao_Paulo",
|
||||
new DateTimeFormat(Source.EMPTY, dateTime, l("VV"), zoneId).makePipe().asProcessor().process(null)
|
||||
|
@ -208,7 +208,7 @@ public class DateTimeFormatProcessorTests extends AbstractSqlWireSerializingTest
|
|||
);
|
||||
assertEquals("Z", new Format(Source.EMPTY, dateTime, l("Z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("+10", new Format(Source.EMPTY, dateTime, l("z"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("Etc/GMT-10", new Format(Source.EMPTY, dateTime, l("K"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("GMT+10:00", new Format(Source.EMPTY, dateTime, l("K"), zoneId).makePipe().asProcessor().process(null));
|
||||
|
||||
assertEquals("1", new Format(Source.EMPTY, dateTime, l("F"), zoneId).makePipe().asProcessor().process(null));
|
||||
assertEquals("12", new Format(Source.EMPTY, dateTime, l("FF"), zoneId).makePipe().asProcessor().process(null));
|
||||
|
|
|
@ -290,7 +290,7 @@ public class PermissionsIT extends ESRestTestCase {
|
|||
painlessExecute.setJsonEntity("""
|
||||
{
|
||||
"script": {
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT));"
|
||||
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH));"
|
||||
},
|
||||
"context": "keyword_field",
|
||||
"context_setup": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue