Skip to content

Commit

Permalink
8.5 (#443)
Browse files Browse the repository at this point in the history
* wip towards 8

* Various fixes

* More fixes

* More fixes

* Final test fix?

* Update workflows

* Changes for ES 8.5 / Lucene 9.4.0

* WIP attempt at swapping out scripting for the new flavor

* Need the init

* Execute from compile to maintain similar legacy functionality

* Branch es 8.5 wrapped (#437)

* Convert to RawDoubleValuesScript

* Rename new class, add test expression plugin.

* Checkstyle fixes, bring mock expressions into Base integ test

* Fix floating point assertion error, final style fix

* Tidy code a bit.

Co-authored-by: Daniel Worley <[email protected]>

* Cleanup build config

* Little more cleanup

* Add missing override

Co-authored-by: Nathan Day <[email protected]>
Co-authored-by: Nikola Grcevski <[email protected]>
With support by: mmcmahon-ag
  • Loading branch information
worleydl authored Nov 2, 2022
1 parent 9c1bb9a commit 6dbd7ff
Show file tree
Hide file tree
Showing 86 changed files with 588 additions and 393 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- uses: actions/checkout@v2
- name: Set release version Name
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up JDK 14.0
- name: Set up JDK 17.0
uses: actions/setup-java@v1
with:
java-version: 14.0
java-version: 17.0
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 14.0
- name: Set up JDK 17.0
uses: actions/setup-java@v1
with:
java-version: 14.0
java-version: 17.0
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ allprojects {

runtimeOnly 'org.locationtech.spatial4j:spatial4j:0.7'
runtimeOnly 'org.locationtech.jts:jts-core:1.15.0'
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.17.1'
}
}

Expand Down
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 = 7.17.7
luceneVersion = 8.11.1
elasticsearchVersion = 8.5.0
luceneVersion = 9.4.1
ow2Version = 8.0.1
antlrVersion = 4.5.1-1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.o19s.es.ltr.action;

import com.o19s.es.TestExpressionsPlugin;
import com.o19s.es.ltr.LtrQueryParserPlugin;
import com.o19s.es.ltr.action.FeatureStoreAction.FeatureStoreRequestBuilder;
import com.o19s.es.ltr.action.FeatureStoreAction.FeatureStoreResponse;
Expand All @@ -37,7 +38,6 @@
import org.elasticsearch.script.ScriptContext;
import org.elasticsearch.script.ScriptEngine;
import org.elasticsearch.test.ESSingleNodeTestCase;
import org.elasticsearch.test.TestGeoShapeFieldMapperPlugin;
import org.junit.Before;

import java.io.IOException;
Expand All @@ -59,10 +59,13 @@ public abstract class BaseIntegrationTest extends ESSingleNodeTestCase {
public static final ScriptContext<ScoreScript.Factory> AGGS_CONTEXT = new ScriptContext<>("aggs", ScoreScript.Factory.class);

@Override
// TODO: Remove the TestGeoShapeFieldMapperPlugin once upstream has completed the migration.
protected Collection<Class<? extends Plugin>> getPlugins() {
return Arrays.asList(LtrQueryParserPlugin.class, NativeScriptPlugin.class, InjectionScriptPlugin.class,
TestGeoShapeFieldMapperPlugin.class);
return Arrays.asList(
LtrQueryParserPlugin.class,
NativeScriptPlugin.class,
InjectionScriptPlugin.class,
TestExpressionsPlugin.class
);
}

public void createStore(String name) throws Exception {
Expand Down Expand Up @@ -125,7 +128,6 @@ public FeatureStoreResponse addElement(StorableElement element,
builder.request().setValidation(validation);
FeatureStoreResponse response = builder.execute().get();
assertEquals(1, response.getResponse().getVersion());
assertEquals(IndexFeatureStore.ES_TYPE, response.getResponse().getType());
assertEquals(DocWriteResponse.Result.CREATED, response.getResponse().getResult());
assertEquals(element.id(), response.getResponse().getId());
assertEquals(store, response.getResponse().getIndex());
Expand Down
65 changes: 29 additions & 36 deletions src/javaRestTest/java/com/o19s/es/ltr/logging/LoggingIT.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void testInvalidDerived() throws Exception {

public void buildIndex() {
client().admin().indices().prepareCreate("test_index").get();
client().prepareIndex("test_index", "test")
client().prepareIndex("test_index")
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.setSource("field1", "hello world", "field2", "bonjour world")
.get();
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/com/o19s/es/explore/ExplorerQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermStates;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Weight;
Expand Down Expand Up @@ -60,7 +61,6 @@ private boolean isCollectionScoped() {

public String getType() { return this.type; }

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object other) {
return sameClassAs(other) &&
Expand Down Expand Up @@ -94,9 +94,8 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo
if (!scoreMode.needsScores()) {
return searcher.createWeight(query, scoreMode, boost);
}
final Weight subWeight = searcher.createWeight(query, scoreMode, boost);
Set<Term> terms = new HashSet<>();
subWeight.extractTerms(terms);
final Set<Term> terms = new HashSet<>();
this.visit(QueryVisitor.termCollector(terms));
if (isCollectionScoped()) {
ClassicSimilarity sim = new ClassicSimilarity();
StatisticsHelper df_stats = new StatisticsHelper();
Expand Down Expand Up @@ -241,9 +240,8 @@ static class ExplorerWeight extends Weight {
this.type = type;
}

@Override
public void extractTerms(Set<Term> terms) {
weight.extractTerms(terms);
QueryVisitor.termCollector(terms);
}

@Override
Expand Down Expand Up @@ -279,4 +277,9 @@ public Scorer scorer(LeafReaderContext context) throws IOException {
public String toString(String field) {
return query.toString();
}

@Override
public void visit(QueryVisitor visitor) {
this.query.visit(visitor.getSubVisitor(BooleanClause.Occur.MUST, this));
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/o19s/es/explore/ExplorerQueryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.apache.lucene.search.Query;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down Expand Up @@ -152,4 +153,10 @@ public ExplorerQueryBuilder statsType(String type) {
this.type = type;
return this;
}


@Override
public Version getMinimalSupportedVersion() {
return Version.V_7_0_0;
}
}
18 changes: 12 additions & 6 deletions src/main/java/com/o19s/es/explore/PostingsExplorerQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
import org.apache.lucene.index.TermState;
import org.apache.lucene.index.TermStates;
import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreMode;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.DocIdSetIterator;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -62,7 +63,6 @@ public String toString(String field) {
return buffer.toString();
}

@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object obj) {
return this.sameClassAs(obj)
Expand Down Expand Up @@ -117,7 +117,6 @@ static class PostingsExplorerWeight extends Weight {
this.type = type;
}

@Override
public void extractTerms(Set<Term> terms) {
terms.add(term);
}
Expand Down Expand Up @@ -245,4 +244,11 @@ public float getMaxScore(int upTo) throws IOException {
return Float.POSITIVE_INFINITY;
}
}

@Override
public void visit(QueryVisitor visitor) {
if (visitor.acceptField(this.term.field()) != false) {
visitor.consumeTerms(this, term);
}
}
}
12 changes: 10 additions & 2 deletions src/main/java/com/o19s/es/ltr/LtrQueryParserPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,18 @@
import com.o19s.es.ltr.stats.suppliers.PluginHealthStatusSupplier;
import com.o19s.es.ltr.stats.suppliers.StoreStatsSupplier;
import com.o19s.es.ltr.utils.FeatureStoreLoader;
import com.o19s.es.ltr.utils.Scripting;
import com.o19s.es.ltr.utils.Suppliers;
import com.o19s.es.termstat.TermStatQueryBuilder;
import org.apache.lucene.analysis.core.KeywordTokenizer;
import org.apache.lucene.analysis.miscellaneous.LengthFilter;
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.internal.Client;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.core.CheckedFunction;
import org.elasticsearch.xcontent.ParseField;
Expand Down Expand Up @@ -103,6 +105,7 @@
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.fetch.FetchSubPhase;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.tracing.Tracer;
import org.elasticsearch.watcher.ResourceWatcherService;

import java.io.IOException;
Expand Down Expand Up @@ -248,14 +251,19 @@ public Collection<Object> createComponents(Client client,
NodeEnvironment nodeEnvironment,
NamedWriteableRegistry namedWriteableRegistry,
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<RepositoriesService> repositoriesServiceSupplier) {
Supplier<RepositoriesService> repositoriesServiceSupplier,
Tracer tracer,
AllocationDeciders AllocationDeciders) {
clusterService.addListener(event -> {
for (Index i : event.indicesDeleted()) {
if (IndexFeatureStore.isIndexStore(i.getName())) {
caches.evict(i.getName());
}
}
});

Scripting.initScriptService(scriptService);

return asList(caches, parserFactory, getStats(client, clusterService, indexNameExpressionResolver));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable.Reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.StatusToXContentObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable.Reader;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/o19s/es/ltr/action/LTRStatsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.nodes.BaseNodeRequest;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentFragment;
import org.elasticsearch.xcontent.XContentBuilder;
Expand Down Expand Up @@ -39,7 +39,7 @@ public LTRStatsRequestBuilder(ElasticsearchClient client) {
}
}

public static class LTRStatsNodeRequest extends BaseNodeRequest {
public static class LTRStatsNodeRequest extends TransportRequest {
private final LTRStatsNodesRequest nodesRequest;

public LTRStatsNodeRequest(LTRStatsNodesRequest nodesRequest) {
Expand Down Expand Up @@ -158,7 +158,7 @@ protected void writeNodesTo(StreamOutput out, List<LTRStatsNodeResponse> nodeRes
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeMap(clusterStats);
out.writeGenericMap(clusterStats);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/o19s/es/ltr/action/ListStoresAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.client.ElasticsearchClient;
import org.elasticsearch.client.internal.ElasticsearchClient;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down
Loading

0 comments on commit 6dbd7ff

Please sign in to comment.