Skip to content

Commit aacb010

Browse files
authored
Merge branch 'main' into cleanup-registered-domain-processor
2 parents 3fda796 + 2fa6651 commit aacb010

File tree

68 files changed

+945
-271
lines changed

Some content is hidden

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

68 files changed

+945
-271
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def generateUpgradeCompatibilityFile = tasks.register("generateUpgradeCompatibil
241241
}
242242

243243
def upgradeCompatibilityZip = tasks.register("upgradeCompatibilityZip", Zip) {
244-
archiveFile.set(project.layout.buildDirectory.file("rolling-upgrade-compatible-${VersionProperties.elasticsearch}.zip"))
244+
archiveFile.set(project.layout.buildDirectory.file("distributions/rolling-upgrade-compatible-${VersionProperties.elasticsearch}.zip"))
245245
from(generateUpgradeCompatibilityFile)
246246
}
247247

docs/changelog/123743.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123743
2+
summary: Adjust exception thrown when unable to load hunspell dict
3+
area: Analysis
4+
type: bug
5+
issues: []

docs/changelog/124050.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 124050
2+
summary: Use `FallbackSyntheticSourceBlockLoader` for boolean and date fields
3+
area: Mapping
4+
type: enhancement
5+
issues: []

modules/analysis-common/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* your election, the "Elastic License 2.0", the "GNU Affero General Public
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
9-
import org.elasticsearch.gradle.Version
10-
119
apply plugin: 'elasticsearch.internal-yaml-rest-test'
1210
apply plugin: 'elasticsearch.yaml-rest-compat-test'
1311
apply plugin: 'elasticsearch.internal-cluster-test'
@@ -36,6 +34,7 @@ artifacts {
3634

3735
tasks.named("yamlRestCompatTestTransform").configure { task ->
3836
task.replaceValueInMatch("tokens.0.token", "absenț", "romanian")
37+
task.skipTest("indices.analyze/15_analyze/Custom analyzer is not buildable", "error response changed with #123743")
3938
}
4039

4140
tasks.named("yamlRestTest").configure {

modules/analysis-common/src/yamlRestTest/resources/rest-api-spec/test/indices.analyze/15_analyze.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
"Custom analyzer is not buildable":
6565
- requires:
6666
test_runner_features: [ capabilities ]
67-
reason: This capability required to run test
6867
capabilities:
69-
- method: GET
70-
path: /_analyze
71-
capabilities: [ wrong_custom_analyzer_returns_400 ]
68+
- method: PUT
69+
path: /{index}
70+
capabilities: [ hunspell_dict_400 ]
71+
reason: "bugfix 'hunspell_dict_400' capability required"
7272

7373
- do:
7474
catch: bad_request
@@ -80,7 +80,3 @@
8080
filter:
8181
type: hunspell
8282
locale: en_US
83-
84-
- match: { status: 400 }
85-
- match: { error.type: illegal_argument_exception }
86-
- match: { error.reason: "Can not build a custom analyzer" }

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/RegisteredDomainProcessorTests.java

Lines changed: 75 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,45 @@
1313
import org.elasticsearch.ingest.TestIngestDocument;
1414
import org.elasticsearch.test.ESTestCase;
1515

16+
import java.util.Collections;
1617
import java.util.Map;
1718

18-
import static org.hamcrest.Matchers.containsString;
19-
import static org.hamcrest.Matchers.equalTo;
19+
import static java.util.Map.entry;
20+
import static org.hamcrest.Matchers.anEmptyMap;
21+
import static org.hamcrest.Matchers.is;
2022

2123
/**
2224
* Test parsing of an eTLD from a FQDN. The list of eTLDs is maintained here:
2325
* https://github.com/publicsuffix/list/blob/master/public_suffix_list.dat
24-
*
25-
* Effective TLDs (eTLS) are not the same as DNS TLDs. Uses for eTLDs are listed here.
26+
* <p>
27+
* Effective TLDs (eTLDs) are not the same as DNS TLDs. Uses for eTLDs are listed here:
2628
* https://publicsuffix.org/learn/
2729
*/
2830
public class RegisteredDomainProcessorTests extends ESTestCase {
29-
private Map<String, Object> buildEvent(String domain) {
30-
return Map.of("domain", domain);
31-
}
3231

3332
public void testBasic() throws Exception {
34-
testRegisteredDomainProcessor(buildEvent("www.google.com"), "www.google.com", "google.com", "com", "www");
35-
testRegisteredDomainProcessor(buildEvent("google.com"), "google.com", "google.com", "com", null);
36-
testRegisteredDomainProcessor(buildEvent(""), null, null, null, null);
37-
testRegisteredDomainProcessor(buildEvent("."), null, null, null, null);
38-
testRegisteredDomainProcessor(buildEvent("$"), null, null, null, null);
39-
testRegisteredDomainProcessor(buildEvent("foo.bar.baz"), null, null, null, null);
40-
testRegisteredDomainProcessor(buildEvent("www.books.amazon.co.uk"), "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books");
33+
testRegisteredDomainProcessor("www.google.com", "www.google.com", "google.com", "com", "www");
34+
testRegisteredDomainProcessor("google.com", "google.com", "google.com", "com", null);
35+
testRegisteredDomainProcessor("", null, null, null, null);
36+
testRegisteredDomainProcessor(".", null, null, null, null);
37+
testRegisteredDomainProcessor("$", null, null, null, null);
38+
testRegisteredDomainProcessor("foo.bar.baz", null, null, null, null);
39+
testRegisteredDomainProcessor("www.books.amazon.co.uk", "www.books.amazon.co.uk", "amazon.co.uk", "co.uk", "www.books");
4140
// Verify "com" is returned as the eTLD, for that FQDN or subdomain
42-
testRegisteredDomainProcessor(buildEvent("com"), "com", null, "com", null);
43-
testRegisteredDomainProcessor(buildEvent("example.com"), "example.com", "example.com", "com", null);
44-
testRegisteredDomainProcessor(buildEvent("googleapis.com"), "googleapis.com", "googleapis.com", "com", null);
41+
testRegisteredDomainProcessor("com", "com", null, "com", null);
42+
testRegisteredDomainProcessor("example.com", "example.com", "example.com", "com", null);
43+
testRegisteredDomainProcessor("googleapis.com", "googleapis.com", "googleapis.com", "com", null);
4544
testRegisteredDomainProcessor(
46-
buildEvent("content-autofill.googleapis.com"),
45+
"content-autofill.googleapis.com",
4746
"content-autofill.googleapis.com",
4847
"googleapis.com",
4948
"com",
5049
"content-autofill"
5150
);
5251
// Verify "ssl.fastly.net" is returned as the eTLD, for that FQDN or subdomain
52+
testRegisteredDomainProcessor("global.ssl.fastly.net", "global.ssl.fastly.net", "global.ssl.fastly.net", "ssl.fastly.net", null);
5353
testRegisteredDomainProcessor(
54-
buildEvent("global.ssl.fastly.net"),
55-
"global.ssl.fastly.net",
56-
"global.ssl.fastly.net",
57-
"ssl.fastly.net",
58-
null
59-
);
60-
testRegisteredDomainProcessor(
61-
buildEvent("1.www.global.ssl.fastly.net"),
54+
"1.www.global.ssl.fastly.net",
6255
"1.www.global.ssl.fastly.net",
6356
"global.ssl.fastly.net",
6457
"ssl.fastly.net",
@@ -67,76 +60,81 @@ public void testBasic() throws Exception {
6760
}
6861

6962
public void testUseRoot() throws Exception {
70-
Map<String, Object> source = buildEvent("www.google.co.uk");
71-
72-
String domainField = "domain";
73-
String registeredDomainField = "registered_domain";
74-
String topLevelDomainField = "top_level_domain";
75-
String subdomainField = "subdomain";
76-
7763
var processor = new RegisteredDomainProcessor(null, null, "domain", "", false);
78-
79-
IngestDocument input = TestIngestDocument.withDefaultVersion(source);
80-
IngestDocument output = processor.execute(input);
81-
82-
String domain = output.getFieldValue(domainField, String.class);
83-
assertThat(domain, equalTo("www.google.co.uk"));
84-
String registeredDomain = output.getFieldValue(registeredDomainField, String.class);
85-
assertThat(registeredDomain, equalTo("google.co.uk"));
86-
String eTLD = output.getFieldValue(topLevelDomainField, String.class);
87-
assertThat(eTLD, equalTo("co.uk"));
88-
String subdomain = output.getFieldValue(subdomainField, String.class);
89-
assertThat(subdomain, equalTo("www"));
64+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of("domain", "www.google.co.uk"));
65+
processor.execute(document);
66+
assertThat(
67+
document.getSource(),
68+
is(
69+
Map.ofEntries(
70+
entry("domain", "www.google.co.uk"),
71+
entry("registered_domain", "google.co.uk"),
72+
entry("top_level_domain", "co.uk"),
73+
entry("subdomain", "www")
74+
)
75+
)
76+
);
9077
}
9178

9279
public void testError() throws Exception {
93-
IllegalArgumentException e = expectThrows(
94-
IllegalArgumentException.class,
95-
() -> testRegisteredDomainProcessor(buildEvent("foo.bar.baz"), null, null, null, null, false)
96-
);
97-
assertThat(e.getMessage(), containsString("unable to set domain information for document"));
98-
e = expectThrows(
99-
IllegalArgumentException.class,
100-
() -> testRegisteredDomainProcessor(buildEvent("$"), null, null, null, null, false)
101-
);
102-
assertThat(e.getMessage(), containsString("unable to set domain information for document"));
80+
var processor = new RegisteredDomainProcessor(null, null, "domain", "", false);
81+
82+
{
83+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of("domain", "foo.bar.baz"));
84+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processor.execute(document));
85+
assertThat(e.getMessage(), is("unable to set domain information for document"));
86+
assertThat(document.getSource(), is(Map.of("domain", "foo.bar.baz")));
87+
}
88+
89+
{
90+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of("domain", "$"));
91+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processor.execute(document));
92+
assertThat(e.getMessage(), is("unable to set domain information for document"));
93+
assertThat(document.getSource(), is(Map.of("domain", "$")));
94+
}
10395
}
10496

105-
private void testRegisteredDomainProcessor(
106-
Map<String, Object> source,
107-
String expectedDomain,
108-
String expectedRegisteredDomain,
109-
String expectedETLD,
110-
String expectedSubdomain
111-
) throws Exception {
112-
testRegisteredDomainProcessor(source, expectedDomain, expectedRegisteredDomain, expectedETLD, expectedSubdomain, true);
97+
public void testIgnoreMissing() throws Exception {
98+
{
99+
var processor = new RegisteredDomainProcessor(null, null, "domain", "", false);
100+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of());
101+
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processor.execute(document));
102+
assertThat(e.getMessage(), is("field [domain] not present as part of path [domain]"));
103+
assertThat(document.getSource(), is(anEmptyMap()));
104+
}
105+
106+
{
107+
var processor = new RegisteredDomainProcessor(null, null, "domain", "", true);
108+
IngestDocument document = TestIngestDocument.withDefaultVersion(Collections.singletonMap("domain", null));
109+
processor.execute(document);
110+
assertThat(document.getSource(), is(Collections.singletonMap("domain", null)));
111+
}
113112
}
114113

115114
private void testRegisteredDomainProcessor(
116-
Map<String, Object> source,
115+
String fqdn,
117116
String expectedDomain,
118117
String expectedRegisteredDomain,
119118
String expectedETLD,
120-
String expectedSubdomain,
121-
boolean ignoreMissing
119+
String expectedSubdomain
122120
) throws Exception {
123121
String domainField = "url.domain";
124122
String registeredDomainField = "url.registered_domain";
125123
String topLevelDomainField = "url.top_level_domain";
126124
String subdomainField = "url.subdomain";
127125

128-
var processor = new RegisteredDomainProcessor(null, null, "domain", "url", ignoreMissing);
126+
var processor = new RegisteredDomainProcessor(null, null, "domain", "url", true);
129127

130-
IngestDocument input = TestIngestDocument.withDefaultVersion(source);
131-
IngestDocument output = processor.execute(input);
128+
IngestDocument document = TestIngestDocument.withDefaultVersion(Map.of("domain", fqdn));
129+
processor.execute(document);
132130

133-
String domain = output.getFieldValue(domainField, String.class, expectedDomain == null);
134-
assertThat(domain, equalTo(expectedDomain));
135-
String registeredDomain = output.getFieldValue(registeredDomainField, String.class, expectedRegisteredDomain == null);
136-
assertThat(registeredDomain, equalTo(expectedRegisteredDomain));
137-
String eTLD = output.getFieldValue(topLevelDomainField, String.class, expectedETLD == null);
138-
assertThat(eTLD, equalTo(expectedETLD));
139-
String subdomain = output.getFieldValue(subdomainField, String.class, expectedSubdomain == null);
140-
assertThat(subdomain, equalTo(expectedSubdomain));
131+
String domain = document.getFieldValue(domainField, String.class, expectedDomain == null);
132+
assertThat(domain, is(expectedDomain));
133+
String registeredDomain = document.getFieldValue(registeredDomainField, String.class, expectedRegisteredDomain == null);
134+
assertThat(registeredDomain, is(expectedRegisteredDomain));
135+
String eTLD = document.getFieldValue(topLevelDomainField, String.class, expectedETLD == null);
136+
assertThat(eTLD, is(expectedETLD));
137+
String subdomain = document.getFieldValue(subdomainField, String.class, expectedSubdomain == null);
138+
assertThat(subdomain, is(expectedSubdomain));
141139
}
142140
}

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public Builder builder(BlockFactory factory, int expectedCount) {
342342
private FallbackSyntheticSourceBlockLoader.Reader<?> fallbackSyntheticSourceBlockLoaderReader() {
343343
var nullValueAdjusted = nullValue != null ? adjustSourceValue(nullValue, scalingFactor) : null;
344344

345-
return new FallbackSyntheticSourceBlockLoader.ReaderWithNullValueSupport<>(nullValue) {
345+
return new FallbackSyntheticSourceBlockLoader.ReaderWithNullValueSupport<Double>(nullValue) {
346346
@Override
347347
public void convertValue(Object value, List<Double> accumulator) {
348348
if (coerce && value.equals("")) {

muted-tests.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,15 @@ tests:
333333
- class: org.elasticsearch.smoketest.MlWithSecurityIT
334334
method: test {yaml=ml/3rd_party_deployment/Test start deployment fails while model download in progress}
335335
issue: https://github.com/elastic/elasticsearch/issues/120814
336-
- class: org.elasticsearch.test.apmintegration.MetricsApmIT
337-
method: testApmIntegration
338-
issue: https://github.com/elastic/elasticsearch/issues/124106
336+
- class: org.elasticsearch.xpack.esql.plugin.MatchOperatorIT
337+
method: testScoring_Zero_OutsideQuery
338+
issue: https://github.com/elastic/elasticsearch/issues/124132
339+
- class: org.elasticsearch.search.query.QueryPhaseTimeoutTests
340+
method: testScorerTimeoutPoints
341+
issue: https://github.com/elastic/elasticsearch/issues/124140
342+
- class: org.elasticsearch.search.query.QueryPhaseTimeoutTests
343+
method: testScorerTimeoutTerms
344+
issue: https://github.com/elastic/elasticsearch/issues/124141
339345

340346
# Examples:
341347
#

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.create/10_basic.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,30 @@
273273

274274
- match: { error.type: "mapper_parsing_exception" }
275275
- match: { error.reason: "Failed to parse mapping: The mapper type [invalid] declared on field [raw] does not exist. It might have been created within a future version or requires a plugin to be installed. Check the documentation." }
276+
---
277+
"Create index with hunspell missing dict":
278+
- requires:
279+
test_runner_features: [ capabilities ]
280+
capabilities:
281+
- method: PUT
282+
path: /{index}
283+
capabilities: [ hunspell_dict_400 ]
284+
reason: "bugfix 'hunspell_dict_400' capability required"
285+
286+
- do:
287+
catch: bad_request
288+
indices.create:
289+
index: bad_hunspell_index
290+
body:
291+
settings:
292+
analysis:
293+
analyzer:
294+
en:
295+
tokenizer: standard
296+
filter:
297+
- my_en_US_dict_stemmer
298+
filter:
299+
my_en_US_dict_stemmer:
300+
type: hunspell
301+
locale: en_US
302+
dedup: false

0 commit comments

Comments
 (0)