diff --git a/pom.xml b/pom.xml index dc86f6c..61e4a2e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.ansj elasticsearch-analysis-ansj - 7.17.5.0 + 8.3.3.0 elasticsearch analysis by ansj elasticsearch-analysis-ansj http://maven.nlpcn.org @@ -13,8 +13,8 @@ UTF-8 **/MainTestSuite.class elasticsearch-analysis-ansj - 1.8 - 7.17.5 + 17 + 8.3.3 org.ansj.elasticsearch.plugin.AnalysisAnsjPlugin @@ -66,8 +66,8 @@ maven-compiler-plugin 3.3 - ${elasticsearch.plugin.java.version} - ${elasticsearch.plugin.java.version} + 8 + 8 diff --git a/src/main/java/org/ansj/elasticsearch/action/AnsjRequest.java b/src/main/java/org/ansj/elasticsearch/action/AnsjRequest.java index ea89073..d01edae 100644 --- a/src/main/java/org/ansj/elasticsearch/action/AnsjRequest.java +++ b/src/main/java/org/ansj/elasticsearch/action/AnsjRequest.java @@ -3,7 +3,7 @@ import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.single.shard.SingleShardRequest; -import org.elasticsearch.client.Requests; +import org.elasticsearch.client.internal.Requests; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; @@ -61,7 +61,7 @@ public ActionRequestValidationException validate() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(path); - out.writeMap(args); + out.writeGenericMap(args); out.writeBytesReference(source); } diff --git a/src/main/java/org/ansj/elasticsearch/action/AnsjResponse.java b/src/main/java/org/ansj/elasticsearch/action/AnsjResponse.java index c344e85..adeafee 100644 --- a/src/main/java/org/ansj/elasticsearch/action/AnsjResponse.java +++ b/src/main/java/org/ansj/elasticsearch/action/AnsjResponse.java @@ -52,6 +52,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) { @Override public void writeTo(StreamOutput out) throws IOException { - out.writeMap(map); + out.writeGenericMap(map); } } diff --git a/src/main/java/org/ansj/elasticsearch/cat/AnalyzerCatAction.java b/src/main/java/org/ansj/elasticsearch/cat/AnalyzerCatAction.java index 057ce18..86079b0 100644 --- a/src/main/java/org/ansj/elasticsearch/cat/AnalyzerCatAction.java +++ b/src/main/java/org/ansj/elasticsearch/cat/AnalyzerCatAction.java @@ -6,7 +6,7 @@ import org.ansj.library.StopLibrary; import org.ansj.library.SynonymsLibrary; import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction; -import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; diff --git a/src/main/java/org/ansj/elasticsearch/cat/AnsjCatAction.java b/src/main/java/org/ansj/elasticsearch/cat/AnsjCatAction.java index 06d8503..ecfdee4 100644 --- a/src/main/java/org/ansj/elasticsearch/cat/AnsjCatAction.java +++ b/src/main/java/org/ansj/elasticsearch/cat/AnsjCatAction.java @@ -8,7 +8,7 @@ import org.ansj.library.DicLibrary; import org.ansj.library.StopLibrary; import org.ansj.library.SynonymsLibrary; -import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.common.Table; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; diff --git a/src/main/java/org/ansj/elasticsearch/cat/ChineseRestTable.java b/src/main/java/org/ansj/elasticsearch/cat/ChineseRestTable.java index cd6f249..b75ea54 100644 --- a/src/main/java/org/ansj/elasticsearch/cat/ChineseRestTable.java +++ b/src/main/java/org/ansj/elasticsearch/cat/ChineseRestTable.java @@ -19,21 +19,29 @@ * under the License. */ -import org.elasticsearch.core.Booleans; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; import org.elasticsearch.common.io.UTF8StreamWriter; -import org.elasticsearch.common.io.stream.BytesStreamOutput; +import org.elasticsearch.common.io.stream.BytesStream; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.SizeValue; +import org.elasticsearch.core.Booleans; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.rest.BytesRestResponse; +import org.elasticsearch.rest.RestChannel; +import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.rest.RestResponse; +import org.elasticsearch.rest.RestStatus; import org.elasticsearch.xcontent.XContentBuilder; import org.elasticsearch.xcontent.XContentType; -import org.elasticsearch.rest.*; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; /** */ @@ -42,7 +50,7 @@ public class ChineseRestTable { public static RestResponse buildResponse(Table table, RestChannel channel) throws Exception { RestRequest request = channel.request(); XContentType xContentType = XContentType - .fromMediaTypeOrFormat(request.param("format", request.header("Content-Type"))); + .fromMediaType(request.param("format", request.header("Content-Type"))); if (xContentType != null) { return buildXContentBuilder(table, channel); } @@ -50,7 +58,7 @@ public static RestResponse buildResponse(Table table, RestChannel channel) throw } public static RestResponse response(RestChannel channel, String text) throws IOException { - try (UTF8StreamWriter out = new UTF8StreamWriter(); BytesStreamOutput bytesOut = channel.bytesOutput()) { + try (UTF8StreamWriter out = new UTF8StreamWriter(); BytesStream bytesOut = channel.bytesOutput()) { out.setOutput(bytesOut); out.append(text); return new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, bytesOut.bytes()); @@ -89,7 +97,7 @@ public static RestResponse buildTextPlainResponse(Table table, RestChannel chann List headers = buildDisplayHeaders(table, request); int[] width = buildWidths(table, request, verbose, headers); - try (BytesStreamOutput bytesOut = channel.bytesOutput(); UTF8StreamWriter out = new UTF8StreamWriter().setOutput(bytesOut)) { + try (BytesStream bytesOut = channel.bytesOutput(); UTF8StreamWriter out = new UTF8StreamWriter().setOutput(bytesOut)) { if (verbose) { for (int col = 0; col < headers.size(); col++) { DisplayHeader header = headers.get(col); diff --git a/src/main/java/org/ansj/elasticsearch/index/analysis/AnsjAnalyzerProvider.java b/src/main/java/org/ansj/elasticsearch/index/analysis/AnsjAnalyzerProvider.java index 9e2ea71..cfec64c 100644 --- a/src/main/java/org/ansj/elasticsearch/index/analysis/AnsjAnalyzerProvider.java +++ b/src/main/java/org/ansj/elasticsearch/index/analysis/AnsjAnalyzerProvider.java @@ -5,7 +5,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider; @@ -20,8 +19,8 @@ public class AnsjAnalyzerProvider extends AbstractIndexAnalyzerProvider createGuiceModules() { - return Collections.singletonList(new AnsjModule()); + public Collection createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, IndexNameExpressionResolver indexNameExpressionResolver, Supplier repositoriesServiceSupplier) { + return Collections.singletonList(new AnsjElasticConfigurator(environment)); } @Override @@ -87,11 +95,4 @@ public Map getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver, Supplier nodesInCluster) { return Arrays.asList(new RestAnsjAction(), new AnalyzerCatAction(), new AnsjCatAction()); } - - private class AnsjModule extends AbstractModule { - @Override - protected void configure() { - bind(AnsjElasticConfigurator.class).asEagerSingleton(); - } - } } diff --git a/src/main/java/org/ansj/elasticsearch/rest/RestAnsjAction.java b/src/main/java/org/ansj/elasticsearch/rest/RestAnsjAction.java index 416d3ba..6357210 100644 --- a/src/main/java/org/ansj/elasticsearch/rest/RestAnsjAction.java +++ b/src/main/java/org/ansj/elasticsearch/rest/RestAnsjAction.java @@ -7,12 +7,11 @@ import org.ansj.library.DicLibrary; import org.ansj.library.StopLibrary; import org.ansj.library.SynonymsLibrary; -import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.client.internal.node.NodeClient; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestToXContentListener; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -40,7 +39,7 @@ public List routes() { } @Override - protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException { + protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) { AnsjRequest ansjRequest = new AnsjRequest(); ansjRequest.asMap().putAll(request.params());