Skip to content

Commit 4c783c3

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 4950d14 + f2098e0 commit 4c783c3

File tree

17 files changed

+358
-189
lines changed

17 files changed

+358
-189
lines changed

muted-tests.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ tests:
7272
- class: org.elasticsearch.action.search.SearchPhaseControllerTests
7373
method: testProgressListener
7474
issue: https://github.com/elastic/elasticsearch/issues/116149
75-
- class: org.elasticsearch.search.basic.SearchWithRandomDisconnectsIT
76-
method: testSearchWithRandomDisconnects
77-
issue: https://github.com/elastic/elasticsearch/issues/116175
7875
- class: org.elasticsearch.xpack.deprecation.DeprecationHttpIT
7976
method: testDeprecatedSettingsReturnWarnings
8077
issue: https://github.com/elastic/elasticsearch/issues/108628
@@ -201,8 +198,6 @@ tests:
201198
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
202199
method: test {p0=ml/3rd_party_deployment/Test start deployment fails while model download in progress}
203200
issue: https://github.com/elastic/elasticsearch/issues/120810
204-
- class: org.elasticsearch.indices.mapping.UpdateMappingIntegrationIT
205-
issue: https://github.com/elastic/elasticsearch/issues/116126
206201
- class: org.elasticsearch.xpack.security.authc.service.ServiceAccountIT
207202
method: testAuthenticateShouldNotFallThroughInCaseOfFailure
208203
issue: https://github.com/elastic/elasticsearch/issues/120902

server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWithRandomDisconnectsIT.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.elasticsearch.action.search.SearchResponse;
1515
import org.elasticsearch.action.support.PlainActionFuture;
1616
import org.elasticsearch.common.settings.Settings;
17+
import org.elasticsearch.common.util.concurrent.ListenableFuture;
1718
import org.elasticsearch.discovery.AbstractDisruptionTestCase;
1819
import org.elasticsearch.index.IndexModule;
1920
import org.elasticsearch.index.IndexSettings;
@@ -67,11 +68,15 @@ public void onFailure(Exception e) {
6768
}
6869

6970
private void runMoreSearches() {
70-
if (done.get() == false) {
71-
prepareRandomSearch().execute(this);
72-
} else {
73-
finishFuture.onResponse(null);
71+
while (done.get() == false) {
72+
final ListenableFuture<SearchResponse> f = new ListenableFuture<>();
73+
prepareRandomSearch().execute(f);
74+
if (f.isDone() == false) {
75+
f.addListener(this);
76+
return;
77+
}
7478
}
79+
finishFuture.onResponse(null);
7580
}
7681
});
7782
}

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
17831783
}
17841784
}
17851785
for (CountDownLatch operation : inFlightAsyncOperations) {
1786-
safeAwait(operation);
1786+
safeAwait(operation, TEST_REQUEST_TIMEOUT);
17871787
}
17881788
if (bogusIds.isEmpty() == false) {
17891789
// delete the bogus types again - it might trigger merges or at least holes in the segments and enforces deleted docs!

x-pack/plugin/inference/qa/test-service-plugin/src/main/java/org/elasticsearch/xpack/inference/mock/TestRerankingServiceExtension.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import java.io.IOException;
3838
import java.util.ArrayList;
39+
import java.util.Comparator;
3940
import java.util.EnumSet;
4041
import java.util.HashMap;
4142
import java.util.List;
@@ -148,16 +149,28 @@ public void chunkedInfer(
148149
}
149150

150151
private RankedDocsResults makeResults(List<String> input) {
151-
List<RankedDocsResults.RankedDoc> results = new ArrayList<>();
152152
int totalResults = input.size();
153-
float minScore = random.nextFloat(-1f, 1f);
154-
float resultDiff = 0.2f;
155-
for (int i = 0; i < input.size(); i++) {
156-
results.add(
157-
new RankedDocsResults.RankedDoc(totalResults - 1 - i, minScore + resultDiff * (totalResults - i), input.get(i))
158-
);
153+
try {
154+
List<RankedDocsResults.RankedDoc> results = new ArrayList<>();
155+
for (int i = 0; i < totalResults; i++) {
156+
results.add(new RankedDocsResults.RankedDoc(i, Float.parseFloat(input.get(i)), input.get(i)));
157+
}
158+
return new RankedDocsResults(results.stream().sorted(Comparator.reverseOrder()).toList());
159+
} catch (NumberFormatException ex) {
160+
List<RankedDocsResults.RankedDoc> results = new ArrayList<>();
161+
float minScore = random.nextFloat(-1f, 1f);
162+
float resultDiff = 0.2f;
163+
for (int i = 0; i < input.size(); i++) {
164+
results.add(
165+
new RankedDocsResults.RankedDoc(
166+
totalResults - 1 - i,
167+
minScore + resultDiff * (totalResults - i),
168+
input.get(totalResults - 1 - i)
169+
)
170+
);
171+
}
172+
return new RankedDocsResults(results);
159173
}
160-
return new RankedDocsResults(results);
161174
}
162175

163176
protected ServiceSettings getServiceSettingsFromMap(Map<String, Object> serviceSettingsMap) {

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferenceFeatures.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class InferenceFeatures implements FeatureSpecification {
2727

2828
private static final NodeFeature SEMANTIC_TEXT_HIGHLIGHTER = new NodeFeature("semantic_text.highlighter");
2929
private static final NodeFeature SEMANTIC_TEXT_HIGHLIGHTER_DEFAULT = new NodeFeature("semantic_text.highlighter.default");
30+
private static final NodeFeature TEST_RERANKING_SERVICE_PARSE_TEXT_AS_SCORE = new NodeFeature(
31+
"test_reranking_service.parse_text_as_score"
32+
);
3033

3134
@Override
3235
public Set<NodeFeature> getTestFeatures() {
@@ -45,7 +48,8 @@ public Set<NodeFeature> getTestFeatures() {
4548
TextSimilarityRankRetrieverBuilder.TEXT_SIMILARITY_RERANKER_ALIAS_HANDLING_FIX,
4649
SemanticInferenceMetadataFieldsMapper.INFERENCE_METADATA_FIELDS_ENABLED_BY_DEFAULT,
4750
SEMANTIC_TEXT_HIGHLIGHTER_DEFAULT,
48-
SEMANTIC_KNN_FILTER_FIX
51+
SEMANTIC_KNN_FILTER_FIX,
52+
TEST_RERANKING_SERVICE_PARSE_TEXT_AS_SCORE
4953
);
5054
}
5155
}

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/70_text_similarity_rank_retriever.yml

Lines changed: 87 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ setup:
22
- skip:
33
features:
44
- close_to
5-
- contains
65
- requires:
76
test_runner_features: "close_to"
87

@@ -33,16 +32,8 @@ setup:
3332
type: keyword
3433
subtopic:
3534
type: keyword
36-
37-
- do:
38-
index:
39-
index: test-index
40-
id: doc_1
41-
body:
42-
text: "As seen from Earth, a solar eclipse happens when the Moon is directly between the Earth and the Sun."
43-
topic: [ "science" ]
44-
subtopic: [ "technology" ]
45-
refresh: true
35+
inference_text_field:
36+
type: text
4637

4738
- do:
4839
index:
@@ -52,6 +43,7 @@ setup:
5243
text: "The phases of the Moon come from the position of the Moon relative to the Earth and Sun."
5344
topic: [ "science" ]
5445
subtopic: [ "astronomy" ]
46+
inference_text_field: "0"
5547
refresh: true
5648

5749
- do:
@@ -61,11 +53,27 @@ setup:
6153
body:
6254
text: "Sun Moon Lake is a lake in Nantou County, Taiwan. It is the largest lake in Taiwan."
6355
topic: [ "geography" ]
56+
inference_text_field: "1"
57+
refresh: true
58+
59+
- do:
60+
index:
61+
index: test-index
62+
id: doc_1
63+
body:
64+
text: "As seen from Earth, a solar eclipse happens when the Moon is directly between the Earth and the Sun."
65+
topic: [ "science" ]
66+
subtopic: [ "technology" ]
67+
inference_text_field: "-1"
6468
refresh: true
6569

6670
---
6771
"Simple text similarity rank retriever":
6872

73+
- requires:
74+
cluster_features: "test_reranking_service.parse_text_as_score"
75+
reason: test_reranking_service can now parse provided input as score to provide deterministic ranks
76+
6977
- do:
7078
search:
7179
index: test-index
@@ -75,14 +83,37 @@ setup:
7583
retriever:
7684
text_similarity_reranker:
7785
retriever:
86+
# this one returns docs 1 and 2
7887
standard:
7988
query:
80-
term:
81-
topic: "science"
89+
bool: {
90+
should: [
91+
{
92+
constant_score: {
93+
filter: {
94+
term: {
95+
subtopic: "technology"
96+
}
97+
},
98+
boost: 10
99+
}
100+
},
101+
{
102+
constant_score: {
103+
filter: {
104+
term: {
105+
subtopic: "astronomy"
106+
}
107+
},
108+
boost: 1
109+
}
110+
}
111+
]
112+
}
82113
rank_window_size: 10
83114
inference_id: my-rerank-model
84115
inference_text: "How often does the moon hide the sun?"
85-
field: text
116+
field: inference_text_field
86117
size: 10
87118

88119
- match: { hits.total.value: 2 }
@@ -94,6 +125,10 @@ setup:
94125
---
95126
"Simple text similarity rank retriever and filtering":
96127

128+
- requires:
129+
cluster_features: "test_reranking_service.parse_text_as_score"
130+
reason: test_reranking_service can now parse provided input as score to provide deterministic ranks
131+
97132
- do:
98133
search:
99134
index: test-index
@@ -103,6 +138,7 @@ setup:
103138
retriever:
104139
text_similarity_reranker:
105140
retriever:
141+
# this one returns doc 1
106142
standard:
107143
query:
108144
term:
@@ -113,7 +149,7 @@ setup:
113149
rank_window_size: 10
114150
inference_id: my-rerank-model
115151
inference_text: "How often does the moon hide the sun?"
116-
field: text
152+
field: inference_text_field
117153
size: 10
118154

119155
- match: { hits.total.value: 1 }
@@ -143,7 +179,7 @@ setup:
143179
rank_window_size: 10
144180
inference_id: i-dont-exist
145181
inference_text: "How often does the moon hide the sun?"
146-
field: text
182+
field: inference_text_field
147183
size: 10
148184

149185
---
@@ -169,13 +205,17 @@ setup:
169205
rank_window_size: 10
170206
inference_id: i-dont-exist
171207
inference_text: "asdfasdf"
172-
field: text
208+
field: inference_text_field
173209
size: 10
174210

175211

176212
---
177213
"text similarity reranking with explain":
178214

215+
- requires:
216+
cluster_features: "test_reranking_service.parse_text_as_score"
217+
reason: test_reranking_service can now parse provided input as score to provide deterministic ranks
218+
179219
- do:
180220
search:
181221
index: test-index
@@ -186,28 +226,50 @@ setup:
186226
text_similarity_reranker: {
187227
retriever:
188228
{
229+
# this one returns doc 1 and 2
189230
standard: {
190231
query: {
191-
term: {
192-
topic: "science"
232+
bool: {
233+
should: [
234+
{
235+
constant_score: {
236+
filter: {
237+
term: {
238+
subtopic: "technology"
239+
}
240+
},
241+
boost: 10
242+
}
243+
},
244+
{
245+
constant_score: {
246+
filter: {
247+
term: {
248+
subtopic: "astronomy"
249+
}
250+
},
251+
boost: 1
252+
}
253+
}
254+
]
193255
}
194256
}
195257
}
196258
},
197259
rank_window_size: 10,
198260
inference_id: my-rerank-model,
199261
inference_text: "How often does the moon hide the sun?",
200-
field: text
262+
field: inference_text_field
201263
}
202264
}
203265
size: 10
204266
explain: true
205267

206-
- contains: { hits.hits: { _id: "doc_2" } }
207-
- contains: { hits.hits: { _id: "doc_1" } }
268+
- match: { hits.hits.0._id: "doc_2" }
269+
- match: { hits.hits.1._id: "doc_1" }
208270

209-
- match: {hits.hits.0._explanation.description: "/text_similarity_reranker.match.using.inference.endpoint:.\\[my-rerank-model\\].on.document.field:.\\[text\\].*/" }
210-
- match: {hits.hits.0._explanation.details.0.description: "/weight.*science.*/" }
271+
- match: {hits.hits.0._explanation.description: "/text_similarity_reranker.match.using.inference.endpoint:.\\[my-rerank-model\\].on.document.field:.\\[inference_text_field\\].*/" }
272+
- match: {hits.hits.0._explanation.details.0.details.0.description: "/subtopic.*astronomy.*/" }
211273

212274
---
213275
"text similarity reranker properly handles aliases":
@@ -281,7 +343,7 @@ setup:
281343
rank_window_size: 10
282344
inference_id: my-rerank-model
283345
inference_text: "How often does the moon hide the sun?"
284-
field: text
346+
field: inference_text_field
285347
size: 10
286348

287349
- match: { hits.total.value: 1 }

x-pack/plugin/logsdb/qa/with-basic/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/LogsdbWithBasicRestIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public void testLogsdbRouteOnSortFields() throws IOException {
235235
var settings = (Map<?, ?>) ((Map<?, ?>) getIndexSettings(index).get(index)).get("settings");
236236
assertEquals("logsdb", settings.get("index.mode"));
237237
assertEquals(SourceFieldMapper.Mode.STORED.toString(), settings.get("index.mapping.source.mode"));
238-
assertEquals("true", settings.get(IndexSettings.LOGSDB_ROUTE_ON_SORT_FIELDS.getKey()));
239-
assertEquals(List.of("host.name", "message"), settings.get(IndexMetadata.INDEX_ROUTING_PATH.getKey()));
238+
assertEquals("false", settings.get(IndexSettings.LOGSDB_ROUTE_ON_SORT_FIELDS.getKey()));
239+
assertNull(settings.get(IndexMetadata.INDEX_ROUTING_PATH.getKey()));
240240
}
241241
}

x-pack/plugin/logsdb/src/javaRestTest/java/org/elasticsearch/xpack/logsdb/LogsdbRestIT.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.List;
2626
import java.util.Map;
2727

28+
import static org.hamcrest.Matchers.anyOf;
2829
import static org.hamcrest.Matchers.equalTo;
2930

3031
public class LogsdbRestIT extends ESRestTestCase {
@@ -66,9 +67,15 @@ public void testFeatureUsageWithLogsdbIndex() throws IOException {
6667
List<Map<?, ?>> features = (List<Map<?, ?>>) response.get("features");
6768
logger.info("response's features: {}", features);
6869
assertThat(features, Matchers.not(Matchers.empty()));
69-
Map<?, ?> feature = features.stream().filter(map -> "mappings".equals(map.get("family"))).findFirst().get();
70-
assertThat(feature.get("name"), equalTo("synthetic-source"));
71-
assertThat(feature.get("license_level"), equalTo("enterprise"));
70+
boolean found = false;
71+
for (var feature : features) {
72+
if (feature.get("family") != null) {
73+
assertThat(feature.get("name"), anyOf(equalTo("synthetic-source"), equalTo("logsdb-routing-on-sort-fields")));
74+
assertThat(feature.get("license_level"), equalTo("enterprise"));
75+
found = true;
76+
}
77+
}
78+
assertTrue(found);
7279

7380
var indexResponse = (Map<?, ?>) getIndexSettings("test-index", true).get("test-index");
7481
logger.info("indexResponse: {}", indexResponse);

0 commit comments

Comments
 (0)