Skip to content

Commit

Permalink
Upgrade to Elasticsearch 8.14.0 (#488)
Browse files Browse the repository at this point in the history
* Bump ES to 8.14.0
  • Loading branch information
trakos authored Jun 10, 2024
1 parent 8420298 commit 27c8b8a
Show file tree
Hide file tree
Showing 30 changed files with 190 additions and 223 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ltrVersion = 1.5.8
elasticsearchVersion = 8.11.4
luceneVersion = 9.8.0
elasticsearchVersion = 8.14.0
luceneVersion = 9.10.0
ow2Version = 8.0.1
antlrVersion = 4.5.1-1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.o19s.es.ltr.ranker.parser.LtrRankerParserFactory;
import com.o19s.es.ltr.ranker.ranklib.RankLibScriptEngine;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexAction;
import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.core.Nullable;
Expand Down Expand Up @@ -70,7 +70,7 @@ protected Collection<Class<? extends Plugin>> getPlugins() {

public void createStore(String name) throws Exception {
assert IndexFeatureStore.isIndexStore(name);
CreateIndexResponse resp = client().execute(CreateIndexAction.INSTANCE, IndexFeatureStore.buildIndexRequest(name)).get();
CreateIndexResponse resp = client().execute(TransportCreateIndexAction.TYPE, IndexFeatureStore.buildIndexRequest(name)).get();
assertTrue(resp.isAcknowledged());
}

Expand Down
71 changes: 30 additions & 41 deletions src/javaRestTest/java/com/o19s/es/ltr/logging/LoggingIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;

Expand Down Expand Up @@ -213,9 +214,7 @@ public void testLog() throws Exception {
new LoggingSearchExtBuilder()
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));

SearchResponse resp = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));
sbuilder.featureSetName(null);
sbuilder.modelName("my_model");
sbuilder.boost(random().nextInt(3));
Expand All @@ -234,8 +233,7 @@ public void testLog() throws Exception {
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));

SearchResponse resp2 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp2);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));

query = QueryBuilders.boolQuery()
.must(new WrapperQueryBuilder(sbuilder.toString()))
Expand All @@ -254,8 +252,7 @@ public void testLog() throws Exception {
new LoggingSearchExtBuilder()
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));
SearchResponse resp3 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp3);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));

query = QueryBuilders.boolQuery().filter(QueryBuilders.idsQuery().addIds(ids));
sourceBuilder = new SearchSourceBuilder().query(query)
Expand All @@ -268,8 +265,7 @@ public void testLog() throws Exception {
.addRescoreLogging("first_log", 0, false)
.addRescoreLogging("second_log", 1, true)));

SearchResponse resp4 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp4);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));
}

public void testLogExtraLogging() throws Exception {
Expand Down Expand Up @@ -304,8 +300,7 @@ public void testLogExtraLogging() throws Exception {
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));

SearchResponse resp = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHitsExtraLogging(docs, resp);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHitsExtraLogging(docs, resp));
sbuilder.featureSetName(null);
sbuilder.modelName("my_model");
sbuilder.boost(random().nextInt(3));
Expand All @@ -324,8 +319,7 @@ public void testLogExtraLogging() throws Exception {
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));

SearchResponse resp2 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHitsExtraLogging(docs, resp2);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHitsExtraLogging(docs, resp));

query = QueryBuilders.boolQuery()
.must(new WrapperQueryBuilder(sbuilder.toString()))
Expand All @@ -344,8 +338,7 @@ public void testLogExtraLogging() throws Exception {
new LoggingSearchExtBuilder()
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));
SearchResponse resp3 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHitsExtraLogging(docs, resp3);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHitsExtraLogging(docs, resp));
}

public void testLogWithFeatureScoreCache() throws Exception {
Expand Down Expand Up @@ -386,8 +379,7 @@ public void testLogWithFeatureScoreCache() throws Exception {
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));

SearchResponse resp = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));
sbuilder.featureSetName(null);
sbuilder.modelName("my_model");
sbuilder_rescore.featureSetName(null);
Expand All @@ -404,8 +396,7 @@ public void testLogWithFeatureScoreCache() throws Exception {
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));

SearchResponse resp2 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp2);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));

query = QueryBuilders.boolQuery()
.must(new WrapperQueryBuilder(sbuilder.toString()))
Expand All @@ -424,8 +415,7 @@ public void testLogWithFeatureScoreCache() throws Exception {
new LoggingSearchExtBuilder()
.addQueryLogging("first_log", "test", false)
.addRescoreLogging("second_log", 0, true)));
SearchResponse resp3 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp3);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));

query = QueryBuilders.boolQuery().filter(QueryBuilders.idsQuery().addIds(ids));
sourceBuilder = new SearchSourceBuilder().query(query)
Expand All @@ -438,8 +428,7 @@ public void testLogWithFeatureScoreCache() throws Exception {
.addRescoreLogging("first_log", 0, false)
.addRescoreLogging("second_log", 1, true)));

SearchResponse resp4 = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertSearchHits(docs, resp4);
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> assertSearchHits(docs, resp));
}

public void testScriptLogInternalParams() throws Exception {
Expand Down Expand Up @@ -467,17 +456,17 @@ public void testScriptLogInternalParams() throws Exception {
new LoggingSearchExtBuilder()
.addQueryLogging("first_log", "test", false)));

SearchResponse resp = client().prepareSearch("test_index").setSource(sourceBuilder).get();

SearchHits hits = resp.getHits();
SearchHit testHit = hits.getAt(0);
Map<String, List<Map<String, Object>>> logs = testHit.getFields().get("_ltrlog").getValue();
assertResponse( client().prepareSearch("test_index").setSource(sourceBuilder), resp -> {
SearchHits hits = resp.getHits();
SearchHit testHit = hits.getAt(0);
Map<String, List<Map<String, Object>>> logs = testHit.getFields().get("_ltrlog").getValue();

assertTrue(logs.containsKey("first_log"));
List<Map<String, Object>> log = logs.get("first_log");
assertTrue(logs.containsKey("first_log"));
List<Map<String, Object>> log = logs.get("first_log");

assertEquals(log.get(0).get("name"), "test_inject");
assertTrue((Float)log.get(0).get("value") > 0.0F);
assertEquals(log.get(0).get("name"), "test_inject");
assertTrue((Float)log.get(0).get("value") > 0.0F);
});
}

public void testScriptLogExternalParams() throws Exception {
Expand Down Expand Up @@ -513,17 +502,17 @@ public void testScriptLogExternalParams() throws Exception {
new LoggingSearchExtBuilder()
.addQueryLogging("first_log", "test", false)));

SearchResponse resp = client().prepareSearch("test_index").setSource(sourceBuilder).get();
assertResponse(client().prepareSearch("test_index").setSource(sourceBuilder), resp -> {
SearchHits hits = resp.getHits();
SearchHit testHit = hits.getAt(0);
Map<String, List<Map<String, Object>>> logs = testHit.getFields().get("_ltrlog").getValue();

SearchHits hits = resp.getHits();
SearchHit testHit = hits.getAt(0);
Map<String, List<Map<String, Object>>> logs = testHit.getFields().get("_ltrlog").getValue();

assertTrue(logs.containsKey("first_log"));
List<Map<String, Object>> log = logs.get("first_log");
assertTrue(logs.containsKey("first_log"));
List<Map<String, Object>> log = logs.get("first_log");

assertEquals(log.get(0).get("name"), "test_inject");
assertTrue((Float)log.get(0).get("value") > 0.0F);
assertEquals(log.get(0).get("name"), "test_inject");
assertTrue((Float)log.get(0).get("value") > 0.0F);
});
}

public void testScriptLogInvalidExternalParams() throws Exception {
Expand Down
Loading

0 comments on commit 27c8b8a

Please sign in to comment.