Skip to content

Commit 58222a0

Browse files
Merge branch 'main' into feature/timestamp-doc-values-spars-index-setting
2 parents c18febe + 95f8454 commit 58222a0

File tree

15 files changed

+348
-187
lines changed

15 files changed

+348
-187
lines changed

muted-tests.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,6 @@ tests:
388388
- class: org.elasticsearch.xpack.inference.mapper.SemanticInferenceMetadataFieldsRecoveryTests
389389
method: testSnapshotRecovery {p0=false p1=true}
390390
issue: https://github.com/elastic/elasticsearch/issues/122551
391-
- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedIT
392-
issue: https://github.com/elastic/elasticsearch/issues/122566
393-
- class: org.elasticsearch.entitlement.qa.EntitlementsAllowedIT
394-
issue: https://github.com/elastic/elasticsearch/issues/122567
395-
- class: org.elasticsearch.entitlement.qa.EntitlementsAllowedNonModularIT
396-
issue: https://github.com/elastic/elasticsearch/issues/122568
397-
- class: org.elasticsearch.entitlement.qa.EntitlementsDeniedNonModularIT
398-
issue: https://github.com/elastic/elasticsearch/issues/122569
399391

400392
# Examples:
401393
#

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);

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsDBPlugin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
import java.util.function.Predicate;
4141
import java.util.function.Supplier;
4242

43-
import static org.elasticsearch.xpack.logsdb.SyntheticSourceLicenseService.FALLBACK_SETTING;
43+
import static org.elasticsearch.xpack.logsdb.LogsdbLicenseService.FALLBACK_SETTING;
4444

4545
public class LogsDBPlugin extends Plugin implements ActionPlugin {
4646

4747
private final Settings settings;
48-
private final SyntheticSourceLicenseService licenseService;
48+
private final LogsdbLicenseService licenseService;
4949
private static final Setting<Boolean> LOGSDB_PRIOR_LOGS_USAGE = Setting.boolSetting(
5050
"logsdb.prior_logs_usage",
5151
false,
@@ -63,7 +63,7 @@ public class LogsDBPlugin extends Plugin implements ActionPlugin {
6363

6464
public LogsDBPlugin(Settings settings) {
6565
this.settings = settings;
66-
this.licenseService = new SyntheticSourceLicenseService(settings);
66+
this.licenseService = new LogsdbLicenseService(settings);
6767
this.logsdbIndexModeSettingsProvider = new LogsdbIndexModeSettingsProvider(licenseService, settings);
6868
}
6969

@@ -82,7 +82,6 @@ public Collection<?> createComponents(PluginServices services) {
8282
CLUSTER_LOGSDB_ENABLED,
8383
logsdbIndexModeSettingsProvider::updateClusterIndexModeLogsdbEnabled
8484
);
85-
8685
// Nothing to share here:
8786
return super.createComponents(services);
8887
}
@@ -95,6 +94,7 @@ public Collection<IndexSettingProvider> getAdditionalIndexSettingProviders(Index
9594
IndexVersion.current(),
9695
parameters.clusterService().state().nodes().getMaxDataNodeCompatibleIndexVersion()
9796
),
97+
DiscoveryNode.isStateless(settings) == false,
9898
DiscoveryNode.isStateless(settings) == false
9999
);
100100
return List.of(logsdbIndexModeSettingsProvider);

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsDBUsageTransportAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected void masterOperation(
6464
}
6565
}
6666
final boolean enabled = LogsDBPlugin.CLUSTER_LOGSDB_ENABLED.get(clusterService.getSettings());
67-
final boolean hasCustomCutoffDate = System.getProperty(SyntheticSourceLicenseService.CUTOFF_DATE_SYS_PROP_NAME) != null;
67+
final boolean hasCustomCutoffDate = System.getProperty(LogsdbLicenseService.CUTOFF_DATE_SYS_PROP_NAME) != null;
6868
final DiscoveryNode[] nodes = state.nodes().getDataNodes().values().toArray(DiscoveryNode[]::new);
6969
final var statsRequest = new IndexModeStatsActionType.StatsRequest(nodes);
7070
final int finalNumIndices = numIndices;

0 commit comments

Comments
 (0)