diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 226f6e92..3187c677 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,37 +14,7 @@ jobs: strategy: matrix: es-version: - - 'es:8.15.2' - - 'es:8.14.3' - - 'es:8.13.4' - - 'es:8.12.2' - - 'es:8.11.4' - - 'es:8.10.4' - - 'es:8.9.2' - - 'es:8.8.2' - - 'es:8.7.1' - - 'es:8.6.2' - - 'es:8.5.3' - - 'es:8.4.3' - - 'es:8.3.3' - - 'es:8.2.3' - - 'es:7.17.24' - - 'es:7.17.8' - - 'es:7.14.2' - - 'es:7.10.2' - - 'os:2.18.0' - - 'os:2.17.1' - - 'os:2.16.0' - - 'os:2.15.0' - - 'os:2.14.0' - - 'os:2.13.0' - - 'os:2.12.0' - - 'os:2.11.1' - - 'os:2.10.0' - - 'os:2.9.0' - - 'os:2.8.0' - - 'os:2.7.0' - - 'os:2.6.0' + - 'es:8.18.3' env: mainJob: ${{ matrix.es-version == 'es:8.15.2' }} sudachiVersion: 20241021 diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e2968f..f165be25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ # Change log -## [Unreleased] +## [3.4.0](https://github.com/WorksApplications/elasticsearch-sudachi/releases/tag/v3.4.0) - 2025-08-18 ### Added - Support OpenSearch 2.18.0 +- Support Elasticsearch 8.16.6, 8.17.8, and 8.18.3 + +### Removed +- Elasticsearch 7.x and versions earlier than 8.10 will no longer be supported.$ ## [3.3.0](https://github.com/WorksApplications/elasticsearch-sudachi/releases/tag/v3.3.0) - 2024-11-13 diff --git a/README.md b/README.md index a65e86b8..fd90db1f 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,9 @@ analysis-sudachi is an Elasticsearch plugin for tokenization of Japanese text us # What's new? -- [3.3.0] - - `allow_empty_morpheme` is added to the `sudachi_tokenizer` settings (#151) - - Offset correction of `SudachiSplitFilter` now works properly with char filters (#149) - - spi changed to implement #149 +- [3.4.0] + - Support Elasticsearch 8.16.6, 8.17.8, and 8.18.3. + - Elasticsearch 7.x and versions earlier than 8.10 will no longer be supported. Check [changelog](./CHANGELOG.md) for more. @@ -18,19 +17,14 @@ Check [changelog](./CHANGELOG.md) for more. 1. Build analysis-sudachi. ``` - $ ./gradlew -PengineVersion=es:8.15.2 build + $ ./gradlew -PengineVersion=es:8.19.2 build ``` Use `-PengineVersion=os:2.18.0` for OpenSearch. ## Supported ElasticSearch versions -1. 8.0.* until 8.15.* supported, integration tests in CI -2. 7.17.* (latest patch version) - supported, integration tests in CI -3. 7.11.* until 7.16.* - best effort support, not tested in CI -4. 7.10.* integration tests for the latest patch version -5. 7.9.* and below - not tested in CI at all, may be broken -6. 7.3.* and below - broken, not supported +1. 8.10.* until 8.19.* supported, integration tests in CI ## Supported OpenSearch versions diff --git a/build.gradle b/build.gradle index 484df01b..5e8a31b2 100644 --- a/build.gradle +++ b/build.gradle @@ -17,11 +17,11 @@ archivesBaseName = 'analysis-sudachi' version = properties["pluginVersion"] compileKotlin { - compilerOptions.jvmTarget.set(JvmTarget.JVM_11) + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } compileTestKotlin { - compilerOptions.jvmTarget.set(JvmTarget.JVM_11) + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } configurations { @@ -86,6 +86,9 @@ def distZip = tasks.register('distZip', Zip) { dependsOn embedVersion, packageJars, packageSpiJars archiveBaseName.set("${esKind.engine.kind}-${esKind.version}-$archivesBaseName") from("build/package/${version}/${esKind.engine.kind}-${esKind.version}", 'LICENSE', 'README.md') + from('src/main/extras') { + include 'entitlement-policy.yaml' + } } artifacts { diff --git a/buildSrc/src/main/groovy/com/worksap/nlp/tools/EsConventions.groovy b/buildSrc/src/main/groovy/com/worksap/nlp/tools/EsConventions.groovy index d503d671..b512b64c 100644 --- a/buildSrc/src/main/groovy/com/worksap/nlp/tools/EsConventions.groovy +++ b/buildSrc/src/main/groovy/com/worksap/nlp/tools/EsConventions.groovy @@ -8,7 +8,7 @@ class EsConventions implements Plugin { @Override void apply(Project target) { target.tasks.withType(JavaCompile).configureEach { - options.release.set(11) + options.release.set(17) options.encoding = 'UTF-8' } diff --git a/buildSrc/src/main/groovy/com/worksap/nlp/tools/engines.groovy b/buildSrc/src/main/groovy/com/worksap/nlp/tools/engines.groovy index 4bdfb308..4e5d5638 100644 --- a/buildSrc/src/main/groovy/com/worksap/nlp/tools/engines.groovy +++ b/buildSrc/src/main/groovy/com/worksap/nlp/tools/engines.groovy @@ -5,14 +5,10 @@ trait EngineSupport { } enum EsSupport implements EngineSupport { - Es74("es-7.04"), - Es78("es-7.08"), - Es715("es-7.15"), - Es80("es-8.00"), - Es83("es-8.03"), - Es84("es-8.04"), Es810("es-8.10"), Es812("es-8.12"), + Es816("es-8.16"), + Es818("es-8.18"), String tag List keys @@ -23,24 +19,16 @@ enum EsSupport implements EngineSupport { } static EsSupport supportVersion(Version vers) { - if (vers.lt(7, 4)) { - throw new IllegalArgumentException("versions below 7.4 are not supported") - } else if (vers.ge(7, 4) && vers.lt(7, 8)) { - return Es74 - } else if (vers.ge(7, 8) && vers.lt(7, 15)) { - return Es78 - } else if (vers.ge(7, 15) && vers.lt(8, 0)) { - return Es715 - } else if (vers.ge(8, 0) && vers.lt(8, 3)) { - return Es80 - } else if (vers.ge(8, 3) && vers.lt(8, 4)) { - return Es83 - } else if (vers.ge(8, 4) && vers.lt(8, 10)) { - return Es84 + if (vers.lt(8, 10)) { + throw new IllegalArgumentException("versions below 8.10 are not supported") } else if (vers.ge(8, 10) && vers.lt(8, 12)) { return Es810 - } else if (vers.ge(8, 12) && vers.lt(9, 0)) { + } else if (vers.ge(8, 12) && vers.lt(8, 16)) { return Es812 + } else if (vers.ge(8, 16) && vers.lt(8, 18)) { + return Es816 + } else if (vers.ge(8, 18) && vers.lt(9, 0)) { + return Es818 } else { throw new IllegalArgumentException("unsupported ElasticSearch version: " + vers.raw) } @@ -169,4 +157,4 @@ class ProjectKind { Version parsedVersion() { return Version.fromRaw(version) } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 2e70ac41..08c15a21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ -# elasticsearch versions: 8.15.2, 8.14.3, 8.13.4, 8.12.2, 8.11.4, 8.10.4, 8.9.2, -# 8.8.1, 8.6.2, 8.5.3, 8.4.3, 8.2.3, 7.17.24, 7.14.2, 7.10.2 +# elasticsearch versions: 8.18.3, 8.17.8, 8.16.6, 8.15.2, 8.14.3, 8.13.4, 8.12.2, +# 8.11.4, 8.10.4 # opensearch version: 2.18.0, 2.17.1, 2.16.0, 2.15.0, 2.14.0, 2.13.0, 2.12.0, 2.11.1, # 2.10.0, 2.9.0, 2.8.0, 2.7.0, 2.6.0 -engineVersion=es:8.15.2 +engineVersion=es:8.19.2 org.gradle.jvmargs=-XX:MaxMetaspaceSize=350m \ --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \ --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \ diff --git a/integration/build.gradle b/integration/build.gradle index ea7f65a6..fde93a58 100644 --- a/integration/build.gradle +++ b/integration/build.gradle @@ -14,11 +14,11 @@ plugins { version = properties["pluginVersion"] compileKotlin { - compilerOptions.jvmTarget.set(JvmTarget.JVM_11) + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } compileTestKotlin { - compilerOptions.jvmTarget.set(JvmTarget.JVM_11) + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } configurations { buildSudachiDict } diff --git a/integration/src/test/ext/es-8.00-lt/com.worksap.nlp.elasticsearch.sudachi/aliases.kt b/integration/src/test/ext/es-8.00-lt/com.worksap.nlp.elasticsearch.sudachi/aliases.kt deleted file mode 100644 index e781024c..00000000 --- a/integration/src/test/ext/es-8.00-lt/com.worksap.nlp.elasticsearch.sudachi/aliases.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.worksap.nlp.elasticsearch.sudachi - -import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction -import org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.env.Environment -import org.elasticsearch.indices.analysis.AnalysisModule -import org.elasticsearch.plugins.AnalysisPlugin -import org.elasticsearch.plugins.PluginsService - -typealias SearchEngineTestCase = org.elasticsearch.test.ESTestCase - -typealias PluginsServiceAlias = PluginsService - -typealias AnalysisRegistryAlias = org.elasticsearch.index.analysis.AnalysisRegistry - -typealias EnvironmentAlias = Environment - -typealias SettingsAlias = Settings - -typealias AnalysisPluginAlias = AnalysisPlugin - -typealias AnalyzeActionRequestAlias = AnalyzeAction.Request - -typealias TransportAnalyzeActionAlias = TransportAnalyzeAction - -fun SudachiInSearchEngineEnv.makePluginService(): PluginsServiceAlias { - return PluginsService(settings(), configPath, null, pluginsPath, emptyList()) -} - -fun SudachiInSearchEngineEnv.makeAnalysisModule(): AnalysisModule { - val plugins = makePluginService() - val analysisPlugins = plugins.filterPlugins(AnalysisPlugin::class.java) - val env = environment() - return AnalysisModule(env, analysisPlugins) -} diff --git a/integration/src/test/ext/es-8.03/SudachiInSearchEngineEnv.kt b/integration/src/test/ext/es-8.03/SudachiInSearchEngineEnv.kt deleted file mode 100644 index 07770b51..00000000 --- a/integration/src/test/ext/es-8.03/SudachiInSearchEngineEnv.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.worksap.nlp.elasticsearch.sudachi - -import org.elasticsearch.indices.analysis.AnalysisModule -import org.elasticsearch.plugins.AnalysisPlugin -import org.elasticsearch.plugins.PluginsService - -typealias PluginsServiceAlias = PluginsService - -fun SudachiInSearchEngineEnv.makePluginService(): PluginsServiceAlias { - return PluginsService(settings(), configPath, null, pluginsPath) -} - -fun SudachiInSearchEngineEnv.makeAnalysisModule(): AnalysisModule { - val plugins = makePluginService() - val analysisPlugins = plugins.filterPlugins(AnalysisPlugin::class.java) - val env = environment() - return AnalysisModule(env, analysisPlugins, plugins.stablePluginRegistry) -} diff --git a/integration/src/test/ext/es-8.00-ge/com.worksap.nlp.elasticsearch.sudachi/aliases.kt b/integration/src/test/ext/es-8.10-ge/com.worksap.nlp.elasticsearch.sudachi/aliases.kt similarity index 95% rename from integration/src/test/ext/es-8.00-ge/com.worksap.nlp.elasticsearch.sudachi/aliases.kt rename to integration/src/test/ext/es-8.10-ge/com.worksap.nlp.elasticsearch.sudachi/aliases.kt index 4f5ae2a4..f69ba08c 100644 --- a/integration/src/test/ext/es-8.00-ge/com.worksap.nlp.elasticsearch.sudachi/aliases.kt +++ b/integration/src/test/ext/es-8.10-ge/com.worksap.nlp.elasticsearch.sudachi/aliases.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/integration/src/test/ext/es-8.12-ge/SudachiInSearchEngineEnv.kt b/integration/src/test/ext/es-8.12/SudachiInSearchEngineEnv.kt similarity index 95% rename from integration/src/test/ext/es-8.12-ge/SudachiInSearchEngineEnv.kt rename to integration/src/test/ext/es-8.12/SudachiInSearchEngineEnv.kt index c141aa95..1357dd1f 100644 --- a/integration/src/test/ext/es-8.12-ge/SudachiInSearchEngineEnv.kt +++ b/integration/src/test/ext/es-8.12/SudachiInSearchEngineEnv.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Works Applications Co., Ltd. + * Copyright (c) 2024-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/integration/src/test/ext/es-8.04/SudachiInSearchEngineEnv.kt b/integration/src/test/ext/es-8.16/SudachiInSearchEngineEnv.kt similarity index 94% rename from integration/src/test/ext/es-8.04/SudachiInSearchEngineEnv.kt rename to integration/src/test/ext/es-8.16/SudachiInSearchEngineEnv.kt index 07770b51..1357dd1f 100644 --- a/integration/src/test/ext/es-8.04/SudachiInSearchEngineEnv.kt +++ b/integration/src/test/ext/es-8.16/SudachiInSearchEngineEnv.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Works Applications Co., Ltd. + * Copyright (c) 2024-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ fun SudachiInSearchEngineEnv.makePluginService(): PluginsServiceAlias { fun SudachiInSearchEngineEnv.makeAnalysisModule(): AnalysisModule { val plugins = makePluginService() - val analysisPlugins = plugins.filterPlugins(AnalysisPlugin::class.java) + val analysisPlugins = plugins.filterPlugins(AnalysisPlugin::class.java).toList() val env = environment() return AnalysisModule(env, analysisPlugins, plugins.stablePluginRegistry) } diff --git a/integration/src/test/ext/es-8.00/SudachiInSearchEngineEnv.kt b/integration/src/test/ext/es-8.18/SudachiInSearchEngineEnv.kt similarity index 79% rename from integration/src/test/ext/es-8.00/SudachiInSearchEngineEnv.kt rename to integration/src/test/ext/es-8.18/SudachiInSearchEngineEnv.kt index 07770b51..a03d6aec 100644 --- a/integration/src/test/ext/es-8.00/SudachiInSearchEngineEnv.kt +++ b/integration/src/test/ext/es-8.18/SudachiInSearchEngineEnv.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Works Applications Co., Ltd. + * Copyright (c) 2024-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,17 +18,22 @@ package com.worksap.nlp.elasticsearch.sudachi import org.elasticsearch.indices.analysis.AnalysisModule import org.elasticsearch.plugins.AnalysisPlugin +import org.elasticsearch.plugins.PluginsLoader import org.elasticsearch.plugins.PluginsService typealias PluginsServiceAlias = PluginsService fun SudachiInSearchEngineEnv.makePluginService(): PluginsServiceAlias { - return PluginsService(settings(), configPath, null, pluginsPath) + return PluginsService( + settings(), + configPath, + PluginsLoader.createPluginsLoader( + null, PluginsLoader.loadPluginsBundles(pluginsPath), null, false)) } fun SudachiInSearchEngineEnv.makeAnalysisModule(): AnalysisModule { val plugins = makePluginService() - val analysisPlugins = plugins.filterPlugins(AnalysisPlugin::class.java) + val analysisPlugins = plugins.filterPlugins(AnalysisPlugin::class.java).toList() val env = environment() return AnalysisModule(env, analysisPlugins, plugins.stablePluginRegistry) } diff --git a/src/main/ext/es-7.15-lt/xcontent-aliases.kt b/src/main/ext/es-7.15-lt/xcontent-aliases.kt deleted file mode 100644 index 5fdcb844..00000000 --- a/src/main/ext/es-7.15-lt/xcontent-aliases.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("PackageDirectoryMismatch") - -package com.worksap.nlp.lucene.aliases - -typealias ToXContent = org.elasticsearch.common.xcontent.ToXContent - -typealias ToXContentParams = org.elasticsearch.common.xcontent.ToXContent.Params - -typealias XContentBuilder = org.elasticsearch.common.xcontent.XContentBuilder diff --git a/src/main/ext/es-8.00-ge/lucene-aliases.kt b/src/main/ext/es-8.00-ge/lucene-aliases.kt deleted file mode 100644 index 76def36e..00000000 --- a/src/main/ext/es-8.00-ge/lucene-aliases.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("PackageDirectoryMismatch") - -package com.worksap.nlp.lucene.aliases - -typealias TokenFilterFactory = org.apache.lucene.analysis.TokenFilterFactory - -typealias ResourceLoaderArgument = org.apache.lucene.util.ResourceLoader - -typealias ResourceLoaderAware = org.apache.lucene.util.ResourceLoaderAware diff --git a/src/main/ext/es-8.00-lt/lucene-aliases.kt b/src/main/ext/es-8.00-lt/lucene-aliases.kt deleted file mode 100644 index 143e404c..00000000 --- a/src/main/ext/es-8.00-lt/lucene-aliases.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("PackageDirectoryMismatch") - -package com.worksap.nlp.lucene.aliases - -typealias TokenFilterFactory = org.apache.lucene.analysis.util.TokenFilterFactory - -typealias ResourceLoaderArgument = org.apache.lucene.analysis.util.ResourceLoader - -typealias ResourceLoaderAware = org.apache.lucene.analysis.util.ResourceLoaderAware diff --git a/src/main/ext/es-8.03-lt/factory-adapters.kt b/src/main/ext/es-8.03-lt/factory-adapters.kt deleted file mode 100644 index c17f8ec4..00000000 --- a/src/main/ext/es-8.03-lt/factory-adapters.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022-2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("UNUSED_PARAMETER", "PackageDirectoryMismatch") - -package com.worksap.nlp.search.aliases - -import org.apache.lucene.analysis.Analyzer - -abstract class AbstractTokenizerFactory( - indexSettings: IndexSettings?, - environment: Environment?, - name: String?, - settings: Settings? -) : org.elasticsearch.index.analysis.AbstractTokenizerFactory(indexSettings, settings, name) - -abstract class AbstractTokenFilterFactory( - indexSettings: IndexSettings?, - environment: Environment?, - name: String?, - settings: Settings? -) : org.elasticsearch.index.analysis.AbstractTokenFilterFactory(indexSettings, name, settings) - -abstract class AbstractIndexAnalyzerProvider( - indexSettings: IndexSettings?, - environment: Environment?, - name: String?, - settings: Settings? -) : - org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider( - indexSettings, name, settings) diff --git a/src/main/ext/es-8.03/factory-adapters.kt b/src/main/ext/es-8.03/factory-adapters.kt deleted file mode 100644 index 442cb6fe..00000000 --- a/src/main/ext/es-8.03/factory-adapters.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022-2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("UNUSED_PARAMETER", "PackageDirectoryMismatch") - -package com.worksap.nlp.search.aliases - -import org.apache.lucene.analysis.Analyzer -import org.elasticsearch.common.settings.Settings -import org.elasticsearch.index.IndexSettings - -abstract class AbstractTokenizerFactory( - indexSettings: IndexSettings?, - environment: Environment?, - name: String?, - settings: Settings? -) : org.elasticsearch.index.analysis.AbstractTokenizerFactory(indexSettings, settings, name) - -abstract class AbstractTokenFilterFactory( - indexSettings: IndexSettings?, - environment: Environment?, - name: String?, - settings: Settings? -) : org.elasticsearch.index.analysis.AbstractTokenFilterFactory(indexSettings, name, settings) - -abstract class AbstractIndexAnalyzerProvider( - indexSettings: IndexSettings?, - environment: Environment?, - name: String?, - settings: Settings? -) : org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider(name, settings) diff --git a/src/main/ext/es-8.04-ge/factory-adapters.kt b/src/main/ext/es-8.10-ge/factory-adapters.kt similarity index 96% rename from src/main/ext/es-8.04-ge/factory-adapters.kt rename to src/main/ext/es-8.10-ge/factory-adapters.kt index 75b53414..4e99d8e0 100644 --- a/src/main/ext/es-8.04-ge/factory-adapters.kt +++ b/src/main/ext/es-8.10-ge/factory-adapters.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Works Applications Co., Ltd. + * Copyright (c) 2022-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/ext/es-7.04-ge/search-engine-aliases.kt b/src/main/ext/es-8.10-ge/search-engine-aliases.kt similarity index 97% rename from src/main/ext/es-7.04-ge/search-engine-aliases.kt rename to src/main/ext/es-8.10-ge/search-engine-aliases.kt index c772fa6e..7d27445b 100644 --- a/src/main/ext/es-7.04-ge/search-engine-aliases.kt +++ b/src/main/ext/es-8.10-ge/search-engine-aliases.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/ext/es-7.15-ge/xcontent-aliases.kt b/src/main/ext/es-8.10-ge/xcontent-aliases.kt similarity index 93% rename from src/main/ext/es-7.15-ge/xcontent-aliases.kt rename to src/main/ext/es-8.10-ge/xcontent-aliases.kt index 036a5cb4..6a41401b 100644 --- a/src/main/ext/es-7.15-ge/xcontent-aliases.kt +++ b/src/main/ext/es-8.10-ge/xcontent-aliases.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Works Applications Co., Ltd. + * Copyright (c) 2024-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/ext/es-8.10-ge/TestSudachiAnalyzer.kt b/src/main/ext/es-8.18-lt/ConfigAdapter.kt similarity index 57% rename from src/test/ext/es-8.10-ge/TestSudachiAnalyzer.kt rename to src/main/ext/es-8.18-lt/ConfigAdapter.kt index 00ad3070..636b3dc8 100644 --- a/src/test/ext/es-8.10-ge/TestSudachiAnalyzer.kt +++ b/src/main/ext/es-8.18-lt/ConfigAdapter.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Works Applications Co., Ltd. + * Copyright (c) 2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,14 @@ * limitations under the License. */ -package com.worksap.nlp.lucene.sudachi.ja +package com.worksap.nlp.elasticsearch.sudachi -import org.apache.lucene.document.Document -import org.apache.lucene.search.IndexSearcher +import com.worksap.nlp.search.aliases.Environment +import com.worksap.nlp.search.aliases.Settings +import java.nio.file.Path -fun TestSudachiAnalyzer.getDocumentFromSearcher(searcher: IndexSearcher, docId: Int): Document { - return searcher.getIndexReader().storedFields().document(docId) +fun resourcesPath(env: Environment, settings: Settings): Path { + return env.configFile() + .resolve( + settings.get(ConfigAdapter.PARAM_RESOURCES_PATH, ConfigAdapter.DEFAULT_RESOURCE_PATH)) } diff --git a/src/test/ext/es-7.08-lt/metadata-aliases.kt b/src/main/ext/es-8.18/ConfigAdapter.kt similarity index 57% rename from src/test/ext/es-7.08-lt/metadata-aliases.kt rename to src/main/ext/es-8.18/ConfigAdapter.kt index 1961f139..aa6e2826 100644 --- a/src/test/ext/es-7.08-lt/metadata-aliases.kt +++ b/src/main/ext/es-8.18/ConfigAdapter.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Works Applications Co., Ltd. + * Copyright (c) 2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,14 @@ * limitations under the License. */ -package com.worksap.nlp.elasticsearch.sudachi.aliases +package com.worksap.nlp.elasticsearch.sudachi -import org.elasticsearch.cluster.metadata.IndexMetaData +import com.worksap.nlp.search.aliases.Environment +import com.worksap.nlp.search.aliases.Settings +import java.nio.file.Path -object MetadataConstants { - const val SETTING_VERSION_CREATED = IndexMetaData.SETTING_VERSION_CREATED +fun resourcesPath(env: Environment, settings: Settings): Path { + return env.configDir() + .resolve( + settings.get(ConfigAdapter.PARAM_RESOURCES_PATH, ConfigAdapter.DEFAULT_RESOURCE_PATH)) } diff --git a/src/main/ext/os-2.00-ge/ConfigAdapter.kt b/src/main/ext/os-2.00-ge/ConfigAdapter.kt new file mode 100644 index 00000000..636b3dc8 --- /dev/null +++ b/src/main/ext/os-2.00-ge/ConfigAdapter.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Works Applications Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.worksap.nlp.elasticsearch.sudachi + +import com.worksap.nlp.search.aliases.Environment +import com.worksap.nlp.search.aliases.Settings +import java.nio.file.Path + +fun resourcesPath(env: Environment, settings: Settings): Path { + return env.configFile() + .resolve( + settings.get(ConfigAdapter.PARAM_RESOURCES_PATH, ConfigAdapter.DEFAULT_RESOURCE_PATH)) +} diff --git a/src/main/extras/entitlement-policy.yaml b/src/main/extras/entitlement-policy.yaml new file mode 100644 index 00000000..91a57566 --- /dev/null +++ b/src/main/extras/entitlement-policy.yaml @@ -0,0 +1,6 @@ +ALL-UNNAMED: + - files: + - path: "<>/..." + mode: read + - path: "<>/sudachi/..." + mode: read diff --git a/src/main/java/com/worksap/nlp/elasticsearch/sudachi/ConfigAdapter.kt b/src/main/java/com/worksap/nlp/elasticsearch/sudachi/ConfigAdapter.kt index c4f72117..daa03911 100644 --- a/src/main/java/com/worksap/nlp/elasticsearch/sudachi/ConfigAdapter.kt +++ b/src/main/java/com/worksap/nlp/elasticsearch/sudachi/ConfigAdapter.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Works Applications Co., Ltd. + * Copyright (c) 2022-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,11 +76,6 @@ class ConfigAdapter(anchor: PathAnchor, settings: Settings, env: Environment) { return SplitModeFlag.get(settings) } - @JvmStatic - fun resourcesPath(env: Environment, settings: Settings): Path { - return env.configFile().resolve(settings.get(PARAM_RESOURCES_PATH, DEFAULT_RESOURCE_PATH)) - } - private fun readDefaultConfig(root: Path, baseAnchor: PathAnchor): Config { val anchor = PathAnchor.filesystem(root).andThen(baseAnchor) val resolved = root.resolve(DEFAULT_SETTINGS_FILENAME) diff --git a/src/main/ext/os-2.00-ge/lucene-aliases.kt b/src/main/java/com/worksap/nlp/lucene/aliases/lucene-aliases.kt similarity index 93% rename from src/main/ext/os-2.00-ge/lucene-aliases.kt rename to src/main/java/com/worksap/nlp/lucene/aliases/lucene-aliases.kt index 76def36e..0d1f0671 100644 --- a/src/main/ext/os-2.00-ge/lucene-aliases.kt +++ b/src/main/java/com/worksap/nlp/lucene/aliases/lucene-aliases.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/ext/es-7.15-lt/xcontent-alias.kt b/src/test/ext/es-7.15-lt/xcontent-alias.kt deleted file mode 100644 index 1d1f4a0e..00000000 --- a/src/test/ext/es-7.15-lt/xcontent-alias.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("PackageDirectoryMismatch") - -package com.worksap.nlp.search.aliases - -typealias XContentType = org.elasticsearch.common.xcontent.XContentType diff --git a/src/test/ext/es-8.00-lt/BaseTokenStreamTestCase.kt b/src/test/ext/es-8.00-lt/BaseTokenStreamTestCase.kt deleted file mode 100644 index d98c37bf..00000000 --- a/src/test/ext/es-8.00-lt/BaseTokenStreamTestCase.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022-2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("UNUSED_PARAMETER", "PackageDirectoryMismatch") - -package com.worksap.nlp.lucene.sudachi.aliases - -abstract class BaseTokenStreamTestCase : org.apache.lucene.analysis.BaseTokenStreamTestCase() diff --git a/src/test/ext/es-8.00-lt/engine-aliases-test.kt b/src/test/ext/es-8.00-lt/engine-aliases-test.kt deleted file mode 100644 index 2c5a7e49..00000000 --- a/src/test/ext/es-8.00-lt/engine-aliases-test.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("PackageDirectoryMismatch") - -package com.worksap.nlp.search.aliases - -typealias Version = org.elasticsearch.Version - -typealias LogConfigurator = org.elasticsearch.common.logging.LogConfigurator - -typealias TestEnvironment = org.elasticsearch.env.TestEnvironment - -typealias Index = org.elasticsearch.index.Index - -typealias AnalysisModule = org.elasticsearch.indices.analysis.AnalysisModule - -typealias IndexSettingsModule = org.elasticsearch.test.IndexSettingsModule - -typealias NamedAnalyzer = org.elasticsearch.index.analysis.NamedAnalyzer - -typealias IndexAnalyzers = org.elasticsearch.index.analysis.IndexAnalyzers diff --git a/src/test/ext/es-8.00-ge/engine-aliases-test.kt b/src/test/ext/es-8.10-ge/engine-aliases-test.kt similarity index 95% rename from src/test/ext/es-8.00-ge/engine-aliases-test.kt rename to src/test/ext/es-8.10-ge/engine-aliases-test.kt index 2c5a7e49..5ffdb97c 100644 --- a/src/test/ext/es-8.00-ge/engine-aliases-test.kt +++ b/src/test/ext/es-8.10-ge/engine-aliases-test.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/ext/es-7.08-ge/metadata-aliases.kt b/src/test/ext/es-8.10-ge/metadata-aliases.kt similarity index 93% rename from src/test/ext/es-7.08-ge/metadata-aliases.kt rename to src/test/ext/es-8.10-ge/metadata-aliases.kt index cbad83d4..dfe9757c 100644 --- a/src/test/ext/es-7.08-ge/metadata-aliases.kt +++ b/src/test/ext/es-8.10-ge/metadata-aliases.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Works Applications Co., Ltd. + * Copyright (c) 2022-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/ext/es-7.15-ge/xcontent-alias.kt b/src/test/ext/es-8.10-ge/xcontent-alias.kt similarity index 92% rename from src/test/ext/es-7.15-ge/xcontent-alias.kt rename to src/test/ext/es-8.10-ge/xcontent-alias.kt index 4bc581a7..22043c14 100644 --- a/src/test/ext/es-7.15-ge/xcontent-alias.kt +++ b/src/test/ext/es-8.10-ge/xcontent-alias.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/ext/es-8.10-lt/SearchEngineEnv.kt b/src/test/ext/es-8.10-lt/SearchEngineEnv.kt deleted file mode 100644 index ec37e878..00000000 --- a/src/test/ext/es-8.10-lt/SearchEngineEnv.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2023-2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.worksap.nlp.elasticsearch.sudachi.index - -import com.worksap.nlp.search.aliases.* - -fun SearchEngineEnv.indexAnalyzers(settings: Settings): IndexAnalyzers { - val indexSettings = IndexSettingsModule.newIndexSettings(Index("test", "_na_"), settings) - return analysisRegistry.build(indexSettings) -} diff --git a/src/test/ext/es-8.10-lt/TestSudachiAnalyzer.kt b/src/test/ext/es-8.10-lt/TestSudachiAnalyzer.kt deleted file mode 100644 index 92bd2288..00000000 --- a/src/test/ext/es-8.10-lt/TestSudachiAnalyzer.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.worksap.nlp.lucene.sudachi.ja - -import org.apache.lucene.document.Document -import org.apache.lucene.search.IndexSearcher - -fun TestSudachiAnalyzer.getDocumentFromSearcher(searcher: IndexSearcher, docId: Int): Document { - return searcher.doc(docId) -} diff --git a/src/test/ext/es-8.16-ge/SearchEngineEnv.kt b/src/test/ext/es-8.16-ge/SearchEngineEnv.kt new file mode 100644 index 00000000..26baca06 --- /dev/null +++ b/src/test/ext/es-8.16-ge/SearchEngineEnv.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023-2025 Works Applications Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.worksap.nlp.elasticsearch.sudachi.index + +import com.worksap.nlp.elasticsearch.sudachi.aliases.MetadataConstants +import com.worksap.nlp.search.aliases.* +import org.elasticsearch.cluster.metadata.IndexMetadata +import org.elasticsearch.common.settings.IndexScopedSettings +import org.elasticsearch.common.settings.Settings +import org.elasticsearch.index.IndexSettings +import org.elasticsearch.index.IndexVersion + +fun SearchEngineEnv.indexAnalyzers(settings: Settings): IndexAnalyzers { + val indexSettings = newIndexSettings("test", settings) + val context = IndexCreationContext.RELOAD_ANALYZERS + return analysisRegistry.build(context, indexSettings) +} + +fun SearchEngineEnv.tokenizers(settings: Map): Map { + val builder = Settings.builder() + settings.forEach { (key: String?, value: String?) -> builder.put(key, value) } + builder.put(MetadataConstants.SETTING_VERSION_CREATED, Version.CURRENT) + val indexSettings = newIndexSettings("test", builder.build()) + return analysisRegistry.buildTokenizerFactories(indexSettings) +} + +fun SearchEngineEnv.newIndexSettings(name: String, settings: Settings): IndexSettings { + val build = + Settings.builder() + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .put(settings) + .build() + val metadata = + IndexMetadata.builder(name) + .system( + IndexSettings.INDEX_FAST_REFRESH_SETTING.get( + settings)) // using fast refresh requires a system index + .settings(build) + .build() + val settingSet = HashSet(IndexScopedSettings.BUILT_IN_INDEX_SETTINGS) + val scopedSettings = IndexScopedSettings(Settings.EMPTY, settingSet) + + val indexSettings = IndexSettings(metadata, Settings.EMPTY, scopedSettings) + return indexSettings +} diff --git a/src/test/ext/es-8.10-ge/SearchEngineEnv.kt b/src/test/ext/es-8.16-lt/SearchEngineEnv.kt similarity index 61% rename from src/test/ext/es-8.10-ge/SearchEngineEnv.kt rename to src/test/ext/es-8.16-lt/SearchEngineEnv.kt index 44966b33..e5b10979 100644 --- a/src/test/ext/es-8.10-ge/SearchEngineEnv.kt +++ b/src/test/ext/es-8.16-lt/SearchEngineEnv.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.worksap.nlp.elasticsearch.sudachi.index +import com.worksap.nlp.elasticsearch.sudachi.aliases.MetadataConstants import com.worksap.nlp.search.aliases.* fun SearchEngineEnv.indexAnalyzers(settings: Settings): IndexAnalyzers { @@ -23,3 +24,12 @@ fun SearchEngineEnv.indexAnalyzers(settings: Settings): IndexAnalyzers { val context = IndexCreationContext.RELOAD_ANALYZERS return analysisRegistry.build(context, indexSettings) } + +fun SearchEngineEnv.tokenizers(settings: Map): Map { + val builder = Settings.builder() + settings.forEach { (key: String?, value: String?) -> builder.put(key, value) } + builder.put(MetadataConstants.SETTING_VERSION_CREATED, Version.CURRENT) + val indexSettings = builder.build() + return analysisRegistry.buildTokenizerFactories( + IndexSettingsModule.newIndexSettings(Index("test", "_na_"), indexSettings)) +} diff --git a/src/test/ext/os-2.00-ge/BaseTokenStreamTestCase.kt b/src/test/ext/os-2.00-ge/BaseTokenStreamTestCase.kt deleted file mode 100644 index 2be44dd2..00000000 --- a/src/test/ext/os-2.00-ge/BaseTokenStreamTestCase.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2022-2023 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:Suppress("UNUSED_PARAMETER", "PackageDirectoryMismatch") - -package com.worksap.nlp.lucene.sudachi.aliases -abstract class BaseTokenStreamTestCase : org.apache.lucene.tests.analysis.BaseTokenStreamTestCase() diff --git a/src/test/ext/os-2.00-ge/SearchEngineEnv.kt b/src/test/ext/os-2.00-ge/SearchEngineEnv.kt index ec37e878..d0dac6ca 100644 --- a/src/test/ext/os-2.00-ge/SearchEngineEnv.kt +++ b/src/test/ext/os-2.00-ge/SearchEngineEnv.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,19 @@ package com.worksap.nlp.elasticsearch.sudachi.index +import com.worksap.nlp.elasticsearch.sudachi.aliases.MetadataConstants import com.worksap.nlp.search.aliases.* fun SearchEngineEnv.indexAnalyzers(settings: Settings): IndexAnalyzers { val indexSettings = IndexSettingsModule.newIndexSettings(Index("test", "_na_"), settings) return analysisRegistry.build(indexSettings) } + +fun SearchEngineEnv.tokenizers(settings: Map): Map { + val builder = Settings.builder() + settings.forEach { (key: String?, value: String?) -> builder.put(key, value) } + builder.put(MetadataConstants.SETTING_VERSION_CREATED, Version.CURRENT) + val indexSettings = builder.build() + return analysisRegistry.buildTokenizerFactories( + IndexSettingsModule.newIndexSettings(Index("test", "_na_"), indexSettings)) +} diff --git a/src/test/ext/os-2.00-ge/TestSudachiAnalyzer.kt b/src/test/ext/os-2.00-ge/TestSudachiAnalyzer.kt deleted file mode 100644 index 00ad3070..00000000 --- a/src/test/ext/os-2.00-ge/TestSudachiAnalyzer.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 Works Applications Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.worksap.nlp.lucene.sudachi.ja - -import org.apache.lucene.document.Document -import org.apache.lucene.search.IndexSearcher - -fun TestSudachiAnalyzer.getDocumentFromSearcher(searcher: IndexSearcher, docId: Int): Document { - return searcher.getIndexReader().storedFields().document(docId) -} diff --git a/src/test/java/com/worksap/nlp/elasticsearch/sudachi/index/SearchEngineEnv.kt b/src/test/java/com/worksap/nlp/elasticsearch/sudachi/index/SearchEngineEnv.kt index 2042bb21..4cfb37bf 100644 --- a/src/test/java/com/worksap/nlp/elasticsearch/sudachi/index/SearchEngineEnv.kt +++ b/src/test/java/com/worksap/nlp/elasticsearch/sudachi/index/SearchEngineEnv.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package com.worksap.nlp.elasticsearch.sudachi.index -import com.worksap.nlp.elasticsearch.sudachi.aliases.MetadataConstants import com.worksap.nlp.elasticsearch.sudachi.plugin.AnalysisSudachiPlugin import com.worksap.nlp.search.aliases.* import com.worksap.nlp.test.TestDictionary @@ -49,15 +48,6 @@ class SearchEngineEnv(vararg components: String = arrayOf("system")) : ExternalR val analysisRegistry get() = analysisModule.analysisRegistry - fun tokenizers(settings: Map): Map { - val builder = Settings.builder() - settings.forEach { (key: String?, value: String?) -> builder.put(key, value) } - builder.put(MetadataConstants.SETTING_VERSION_CREATED, Version.CURRENT) - val indexSettings = builder.build() - return analysisRegistry.buildTokenizerFactories( - IndexSettingsModule.newIndexSettings(Index("test", "_na_"), indexSettings)) - } - /** * Reflection hack for instantiating AnalysisModule * diff --git a/src/test/ext/es-8.00-ge/BaseTokenStreamTestCase.kt b/src/test/java/com/worksap/nlp/lucene/sudachi/aliases/BaseTokenStreamTestCase.kt similarity index 93% rename from src/test/ext/es-8.00-ge/BaseTokenStreamTestCase.kt rename to src/test/java/com/worksap/nlp/lucene/sudachi/aliases/BaseTokenStreamTestCase.kt index 2243ad36..4d1d90e3 100644 --- a/src/test/ext/es-8.00-ge/BaseTokenStreamTestCase.kt +++ b/src/test/java/com/worksap/nlp/lucene/sudachi/aliases/BaseTokenStreamTestCase.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Works Applications Co., Ltd. + * Copyright (c) 2022-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/com/worksap/nlp/lucene/sudachi/ja/TestSudachiAnalyzer.kt b/src/test/java/com/worksap/nlp/lucene/sudachi/ja/TestSudachiAnalyzer.kt index e906d2f9..a0472f17 100644 --- a/src/test/java/com/worksap/nlp/lucene/sudachi/ja/TestSudachiAnalyzer.kt +++ b/src/test/java/com/worksap/nlp/lucene/sudachi/ja/TestSudachiAnalyzer.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2024 Works Applications Co., Ltd. + * Copyright (c) 2017-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,10 @@ import org.junit.After import org.junit.Before import org.junit.Test +fun TestSudachiAnalyzer.getDocumentFromSearcher(searcher: IndexSearcher, docId: Int): Document { + return searcher.getIndexReader().storedFields().document(docId) +} + // Test of character segmentation using analyzer class TestSudachiAnalyzer { private var analyzer: SudachiAnalyzer? = null diff --git a/subplugin/build.gradle b/subplugin/build.gradle index 211d891b..58d2a971 100644 --- a/subplugin/build.gradle +++ b/subplugin/build.gradle @@ -38,6 +38,9 @@ def distZip = tasks.register('distZip', Zip) { dependsOn embedVersion, packageJars archiveBaseName.set("${esKind.engine.kind}-${esKind.version}-$archivesBaseName") from("build/package/${version}/${esKind.engine.kind}-${esKind.version}") + from('src/main/extras') { + include 'entitlement-policy.yaml' + } } spotless { diff --git a/subplugin/src/main/ext/es-7.04-ge/com/worksap/nlp/elasticsearch/sudachi/plugin/SudachiTestSubplugin.java b/subplugin/src/main/ext/es-8.10-ge/com/worksap/nlp/elasticsearch/sudachi/plugin/SudachiTestSubplugin.java similarity index 92% rename from subplugin/src/main/ext/es-7.04-ge/com/worksap/nlp/elasticsearch/sudachi/plugin/SudachiTestSubplugin.java rename to subplugin/src/main/ext/es-8.10-ge/com/worksap/nlp/elasticsearch/sudachi/plugin/SudachiTestSubplugin.java index 169be5d4..88b9f287 100644 --- a/subplugin/src/main/ext/es-7.04-ge/com/worksap/nlp/elasticsearch/sudachi/plugin/SudachiTestSubplugin.java +++ b/subplugin/src/main/ext/es-8.10-ge/com/worksap/nlp/elasticsearch/sudachi/plugin/SudachiTestSubplugin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Works Applications Co., Ltd. + * Copyright (c) 2023-2025 Works Applications Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/subplugin/src/main/extras/entitlement-policy.yaml b/subplugin/src/main/extras/entitlement-policy.yaml new file mode 100644 index 00000000..91a57566 --- /dev/null +++ b/subplugin/src/main/extras/entitlement-policy.yaml @@ -0,0 +1,6 @@ +ALL-UNNAMED: + - files: + - path: "<>/..." + mode: read + - path: "<>/sudachi/..." + mode: read diff --git a/test-scripts/00-install-elasticsearch.sh b/test-scripts/00-install-elasticsearch.sh index bcc1db43..392c03ec 100755 --- a/test-scripts/00-install-elasticsearch.sh +++ b/test-scripts/00-install-elasticsearch.sh @@ -69,7 +69,7 @@ if [[ -d "$ES_DIR/plugins/analysis-sudachi" ]]; then "$ES_DIR/bin/$ES_PLUGIN_BIN" remove analysis-sudachi fi -"$ES_DIR/bin/$ES_PLUGIN_BIN" install "$PLUGIN" +"$ES_DIR/bin/$ES_PLUGIN_BIN" install --batch "$PLUGIN" if [[ "$SHOULD_RUN_TEST01" == "true" ]]; then TEST_PLUGIN_PATH="$(readlink -f "$TEST_PLUGIN_PATH")" @@ -82,8 +82,8 @@ if [[ "$SHOULD_RUN_TEST01" == "true" ]]; then "$ES_DIR/bin/$ES_PLUGIN_BIN" remove analysis-sudachi-childtest fi - "$ES_DIR/bin/$ES_PLUGIN_BIN" install "analysis-icu" - "$ES_DIR/bin/$ES_PLUGIN_BIN" install "$TEST_PLUGIN" + "$ES_DIR/bin/$ES_PLUGIN_BIN" install --batch "analysis-icu" + "$ES_DIR/bin/$ES_PLUGIN_BIN" install --batch "$TEST_PLUGIN" fi diff --git a/testlib/build.gradle b/testlib/build.gradle index 0bc42215..70353ce8 100644 --- a/testlib/build.gradle +++ b/testlib/build.gradle @@ -12,11 +12,11 @@ plugins { version = properties["pluginVersion"] compileKotlin { - compilerOptions.jvmTarget.set(JvmTarget.JVM_11) + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } compileTestKotlin { - compilerOptions.jvmTarget.set(JvmTarget.JVM_11) + compilerOptions.jvmTarget.set(JvmTarget.JVM_17) } dependencies {