Skip to content

Commit

Permalink
2.11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jhinch-at-atlassian-com committed Nov 21, 2023
1 parent 3ce91d7 commit c2bda69
Show file tree
Hide file tree
Showing 60 changed files with 172 additions and 171 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ validateNebulaPom.enabled = false
buildscript {
ext {
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
opensearch_version = System.getProperty("opensearch.version", "2.9.0")
opensearch_version = System.getProperty("opensearch.version", "2.11.0")
lucene_version = "9.7.0"
plugin_version = opensearch_version + ".0"
if (isSnapshot) {
Expand Down
4 changes: 2 additions & 2 deletions src/javaRestTest/java/com/o19s/es/ltr/NodeSettingsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.o19s.es.ltr.ranker.LtrRanker;
import org.apache.lucene.util.Accountable;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.ByteSizeUnit;
import org.opensearch.common.unit.ByteSizeValue;
import org.opensearch.core.common.unit.ByteSizeUnit;
import org.opensearch.core.common.unit.ByteSizeValue;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ public <FactoryType> FactoryType compile(String scriptName, String scriptSource,
+ "]");
}
// we use the script "source" as the script identifier
ScoreScript.Factory factory = (p, lookup) ->
ScoreScript.Factory factory = (p, lookup, searcher) ->
new ScoreScript.LeafFactory() {
@Override
public ScoreScript newInstance(LeafReaderContext ctx) throws IOException {
return new ScoreScript(p, lookup, ctx) {
return new ScoreScript(p, lookup, searcher, ctx) {
@Override
public double execute(ExplanationHolder explainationHolder) {
// For testing purposes just look for the "terms" key and see if stats were injected
Expand Down Expand Up @@ -239,7 +239,7 @@ public <FactoryType> FactoryType compile(String scriptName, String scriptSource,
}
// we use the script "source" as the script identifier
if (FEATURE_EXTRACTOR.equals(scriptSource)) {
ScoreScript.Factory factory = (p, lookup) ->
ScoreScript.Factory factory = (p, lookup, searcher) ->
new ScoreScript.LeafFactory() {
final Map<String, Float> featureSupplier;
final String dependentFeature;
Expand Down Expand Up @@ -267,7 +267,7 @@ public <FactoryType> FactoryType compile(String scriptName, String scriptSource,

@Override
public ScoreScript newInstance(LeafReaderContext ctx) throws IOException {
return new ScoreScript(p, lookup, ctx) {
return new ScoreScript(p, lookup, searcher, ctx) {
@Override
public double execute(ExplanationHolder explainationHolder ) {
return extraMultiplier == 0.0d ?
Expand All @@ -286,7 +286,7 @@ public boolean needs_score() {
return context.factoryClazz.cast(factory);
}
else if (scriptSource.equals(FEATURE_EXTRACTOR + "_extra_logging")) {
ScoreScript.Factory factory = (p, lookup) ->
ScoreScript.Factory factory = (p, lookup, searcher) ->
new ScoreScript.LeafFactory() {
{
if (!p.containsKey(FEATURE_VECTOR)) {
Expand All @@ -299,7 +299,7 @@ else if (scriptSource.equals(FEATURE_EXTRACTOR + "_extra_logging")) {

@Override
public ScoreScript newInstance(LeafReaderContext ctx) throws IOException {
return new ScoreScript(p, lookup, ctx) {
return new ScoreScript(p, lookup, searcher, ctx) {

@Override
public double execute(ExplanationHolder explanation) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/o19s/es/explore/ExplorerQueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import org.apache.lucene.search.Query;
import org.opensearch.core.ParseField;
import org.opensearch.common.ParsingException;
import org.opensearch.common.io.stream.NamedWriteable;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.ParsingException;
import org.opensearch.core.common.io.stream.NamedWriteable;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ObjectParser;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.core.xcontent.XContentParser;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/o19s/es/ltr/LtrQueryParserPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@
import org.apache.lucene.analysis.miscellaneous.LengthFilter;
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionResponse;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.client.Client;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.CheckedFunction;
import org.opensearch.core.ParseField;
import org.opensearch.common.io.stream.NamedWriteableRegistry;
import org.opensearch.common.io.stream.NamedWriteableRegistry.Entry;
import org.opensearch.core.common.io.stream.NamedWriteableRegistry;
import org.opensearch.core.common.io.stream.NamedWriteableRegistry.Entry;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.IndexScopedSettings;
import org.opensearch.common.settings.Setting;
Expand All @@ -87,7 +87,7 @@
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.env.Environment;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.index.Index;
import org.opensearch.core.index.Index;
import org.opensearch.index.analysis.PreConfiguredTokenFilter;
import org.opensearch.index.analysis.PreConfiguredTokenizer;
import org.opensearch.plugins.ActionPlugin;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/o19s/es/ltr/action/AddFeaturesToSetAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionResponse;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.action.ActionType;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable.Reader;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable.Reader;
import org.opensearch.common.xcontent.StatusToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.rest.RestStatus;
import org.opensearch.core.rest.RestStatus;

import java.io.IOException;
import java.util.List;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/o19s/es/ltr/action/CachesStatsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.opensearch.client.OpenSearchClient;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.XContentBuilder;

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/o19s/es/ltr/action/ClearCachesAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import org.opensearch.client.OpenSearchClient;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;

import java.io.IOException;
import java.util.List;
import java.util.Objects;
import org.opensearch.common.io.stream.Writeable.Reader;
import org.opensearch.core.common.io.stream.Writeable.Reader;

import static org.opensearch.action.ValidateActions.addValidationError;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionResponse;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.action.ActionType;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.StatusToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.rest.RestStatus;
import org.opensearch.core.rest.RestStatus;

import java.io.IOException;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/o19s/es/ltr/action/FeatureStoreAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import org.opensearch.action.ActionRequest;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionResponse;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.action.ActionType;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable.Reader;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable.Reader;
import org.opensearch.common.xcontent.StatusToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.rest.RestStatus;
import org.opensearch.core.rest.RestStatus;

import java.io.IOException;
import java.util.Objects;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/o19s/es/ltr/action/LTRStatsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.opensearch.client.OpenSearchClient;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/o19s/es/ltr/action/ListStoresAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import com.o19s.es.ltr.feature.store.index.IndexFeatureStore;
import org.opensearch.action.ActionRequestBuilder;
import org.opensearch.action.ActionRequestValidationException;
import org.opensearch.action.ActionResponse;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.action.ActionType;
import org.opensearch.action.support.master.MasterNodeReadRequest;
import org.opensearch.client.OpenSearchClient;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.common.io.stream.Writeable.Reader;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.common.io.stream.Writeable.Reader;
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.o19s.es.ltr.feature.store.StoredFeature;
import com.o19s.es.ltr.feature.store.StoredFeatureSet;
import com.o19s.es.ltr.feature.store.index.IndexFeatureStore;
import org.opensearch.action.ActionListener;
import org.opensearch.core.action.ActionListener;
import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.GetResponse;
import org.opensearch.action.get.TransportGetAction;
Expand Down Expand Up @@ -52,7 +52,7 @@
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;

import static org.opensearch.action.ActionListener.wrap;
import static org.opensearch.core.action.ActionListener.wrap;

public class TransportAddFeatureToSetAction extends HandledTransportAction<AddFeaturesToSetRequest, AddFeaturesToSetResponse> {
private final ClusterService clusterService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.common.settings.Settings;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.common.settings.Settings;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import com.o19s.es.ltr.feature.store.StoredFeatureSet;
import com.o19s.es.ltr.feature.store.StoredLtrModel;
import com.o19s.es.ltr.feature.store.index.IndexFeatureStore;
import org.opensearch.action.ActionListener;
import org.opensearch.core.action.ActionListener;
import org.opensearch.action.get.GetRequest;
import org.opensearch.action.get.GetResponse;
import org.opensearch.action.get.TransportGetAction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.o19s.es.ltr.ranker.parser.LtrRankerParserFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionListener;
import org.opensearch.core.action.ActionListener;
import org.opensearch.action.index.IndexAction;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.search.SearchAction;
Expand All @@ -47,7 +47,7 @@
import java.io.IOException;
import java.util.Optional;

import static org.opensearch.action.ActionListener.wrap;
import static org.opensearch.core.action.ActionListener.wrap;

public class TransportFeatureStoreAction extends HandledTransportAction<FeatureStoreRequest, FeatureStoreResponse> {
private final LtrRankerParserFactory factory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.opensearch.action.support.nodes.TransportNodesAction;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.o19s.es.ltr.action.ListStoresAction.ListStoresActionRequest;
import com.o19s.es.ltr.action.ListStoresAction.ListStoresActionResponse;
import com.o19s.es.ltr.feature.store.index.IndexFeatureStore;
import org.opensearch.action.ActionListener;
import org.opensearch.core.action.ActionListener;
import org.opensearch.action.admin.cluster.state.ClusterStateRequest;
import org.opensearch.action.search.MultiSearchRequestBuilder;
import org.opensearch.action.search.MultiSearchResponse;
Expand All @@ -34,7 +34,7 @@
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.collect.Tuple;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.common.settings.Settings;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.search.aggregations.AggregationBuilders;
Expand All @@ -54,7 +54,7 @@

import static com.o19s.es.ltr.feature.store.index.IndexFeatureStore.STORE_VERSION_PROP;
import static java.util.stream.Collectors.toMap;
import static org.opensearch.action.ActionListener.wrap;
import static org.opensearch.core.action.ActionListener.wrap;
import static org.opensearch.common.collect.Tuple.tuple;

public class TransportListStoresAction extends TransportMasterNodeReadAction<ListStoresActionRequest, ListStoresActionResponse> {
Expand All @@ -68,7 +68,7 @@ public TransportListStoresAction(Settings settings, TransportService transportSe
actionFilters, ListStoresActionRequest::new, indexNameExpressionResolver);
this.client = client;
}

@Override
protected String executor() {
return ThreadPool.Names.SAME;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/o19s/es/ltr/feature/FeatureValidation.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.o19s.es.ltr.feature;

import org.opensearch.core.ParseField;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.ConstructingObjectParser;
import org.opensearch.core.xcontent.ObjectParser;
import org.opensearch.core.xcontent.ToXContentObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.o19s.es.ltr.feature.store;

import com.o19s.es.ltr.ranker.normalizer.Normalizer;
import org.opensearch.common.io.stream.Writeable;
import org.opensearch.core.common.io.stream.Writeable;
import org.opensearch.core.xcontent.ToXContent;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.o19s.es.ltr.ranker.normalizer.MinMaxFeatureNormalizer;
import com.o19s.es.ltr.ranker.normalizer.Normalizer;
import org.opensearch.core.ParseField;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ObjectParser;
import org.opensearch.core.xcontent.XContentBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import org.apache.lucene.search.Query;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.RamUsageEstimator;
import org.opensearch.common.ParsingException;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.common.ParsingException;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.XContentParser;
Expand Down Expand Up @@ -92,7 +93,7 @@ public Query doToQuery(LtrQueryContext context, FeatureSet set, Map<String, Obje

String query = MustacheUtils.execute(template, params);
try {
XContentParser parser = XContentFactory.xContent(query)
XContentParser parser = XContentType.JSON.xContent()
.createParser(context.getQueryShardContext().getXContentRegistry(),
LoggingDeprecationHandler.INSTANCE, query);
QueryBuilder queryBuilder = parseInnerQueryBuilder(parser);
Expand Down
Loading

0 comments on commit c2bda69

Please sign in to comment.