Skip to content

Commit

Permalink
support 7.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
microbun committed Sep 18, 2020
1 parent b90812c commit ddc29e6
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

Plugin 版本 | ES 版本 | THULAC 版本 | Link
-----------|-----------|----------|------------
master | 6.x -> master | lite |
master | 7.x -> master | lite |
7.9.1 | 7.9.1 | lite |[下载](https://github.com/microbun/elasticsearch-thulac-plugin/releases/download/7.9.1/elasticsearch-thulac-plugin-7.9.1.zip)
6.4.1-181027 | 6.4.1 | lite |[下载](https://github.com/microbun/elasticsearch-thulac-plugin/releases/download/6.4.1-181027/elasticsearch-thulac-plugin-6.4.1-181027.zip)
6.4.0-181027 | 6.4.0 | lite |[下载](https://github.com/microbun/elasticsearch-thulac-plugin/releases/download/6.4.0-181027/elasticsearch-thulac-plugin-6.4.0-181027.zip)
6.3.0-181027 | 6.3.0 | lite |[下载](https://github.com/microbun/elasticsearch-thulac-plugin/releases/download/6.3.0-181027/elasticsearch-thulac-plugin-6.3.0-181027.zip)
Expand All @@ -30,15 +31,15 @@ cd elasticsearch-thulac-plugin

2.安装到elasticsearch
```
cp build/distributions/elasticsearch-thulac-plugin-6.1.0.zip ${ES_HOME}/plugins
cp build/distributions/elasticsearch-thulac-plugin-7.9.1.zip ${ES_HOME}/plugins
cd ${ES_HOME}/plugins
unzip elasticsearch-thulac-plugin-6.1.0.zip
rm elasticsearch-thulac-plugin-6.1.0.zip
unzip elasticsearch-thulac-plugin-7.9.1.zip
rm elasticsearch-thulac-plugin-7.9.1.zip
```
解压后在plugins目录下会有一个thulac文件夹。
```
thulac
|-elasticsearch-thulac-plugin-6.1.0.jar
|-elasticsearch-thulac-plugin-7.9.1.jar
|-models #算法模型目录
|-plugin-descriptor.properties
|-plugin.xml
Expand All @@ -55,9 +56,7 @@ thulac
```bash
curl -H "Content-Type:application/json" -XPUT http://localhost:9200/index -d'
{
"settings": {
},
"mapping": {
"mappings": {
"properties": {
"text": {
"type": "text",
Expand Down Expand Up @@ -93,15 +92,15 @@ curl -H "Content-Type:application/json" -XPUT http://localhost:9200/index -d'
}
}
},
"mapping": {
"mappings": {
"properties": {
"text": {
"type": "text",
"analyzer": "custom_thulac_tokenizer"
"analyzer": "custom_thulac_analyzer"
}
}
}
}
}'
```

| 参数名称 | 含义 ||
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'org.elasticsearch.thulac'
version '6.4.1-181027'
version '7.9.1'

apply plugin: 'java'

Expand Down Expand Up @@ -35,7 +35,7 @@ sourceSets {

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
compile 'org.elasticsearch:elasticsearch:6.4.1'
compile 'org.elasticsearch:elasticsearch:7.9.1'
}

task release_full(type: Zip, dependsOn: [':jar']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ThulacAnalyzerProvider extends AbstractIndexAnalyzerProvider<Thulac
*/
public ThulacAnalyzerProvider(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
super(indexSettings, name, settings);
Configuration configuration = new Configuration(environment, indexSettings, settings);
Configuration configuration = new Configuration(environment,indexSettings, settings);
thulacAnalyzer = new ThulacAnalyzer(configuration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ThulacTokenizerFactory extends AbstractTokenizerFactory {
private Configuration configuration;

public ThulacTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
super(indexSettings, name, settings);
super(indexSettings, settings, name);
configuration = new Configuration(environment, indexSettings, settings);
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/elasticsearch/thulac/Configuration.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.elasticsearch.thulac;

import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
Expand All @@ -23,7 +22,7 @@ public class Configuration {
private Environment environment;
private IndexSettings indexSettings;
private Settings settings;
private Logger logger = ESLoggerFactory.getLogger(getClass());
private Logger logger = Loggers.getLogger(getClass(),"thulac");

public Configuration() {
}
Expand All @@ -38,7 +37,7 @@ public Configuration(Environment environment, IndexSettings indexSettings, Setti
filter = settings.getAsBoolean("filter", false);
modelPath = environment.pluginsFile().resolve("thulac/models");
// logger.info("thulac settings: path={}", modelPath.toAbsolutePath().toString());
// logger.info("thulac settings: user_dict={} use_t2s={} seg_only={} use_filter={} ", userDict, segOnly, useFilter);
// logger.info("thulac settings: user_dict={} use_t2s={} seg_only={} use_filter={} ", userDict, t2s, segOnly, useFilter);
}

public Environment getEnvironment() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ public class ThulacLiteSegment {
private static final Map<String, CBTaggingDecoder> decoder = new HashMap<>();

private static final Map<Configuration, ThulacLiteSegment> cache = new ConcurrentHashMap<>();
private Logger logger;
;
private CBTaggingDecoder taggingDecoder;
// preprocess passes
private List<IPreprocessPass> pre = new ArrayList<>();
// postprocess passes
private List<IPostprocessPass> post = new ArrayList<>();

private ThulacLiteSegment(Configuration configuration) throws IOException {
logger = Loggers.getLogger(getClass());
synchronized (decoder) {
init(configuration);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin-descriptor.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
description=A thulac analysis of plugins for Elasticsearch
#
# 'version': plugin's version
version=6.4.1-181027
version=7.9.1
#
# 'name': the plugin name
name=analysis-thulac-plugin
Expand Down Expand Up @@ -68,7 +68,7 @@ java.version=1.8
# elasticsearch release. This version is checked when the plugin
# is loaded so Elasticsearch will refuse to start in the presence of
# plugins with the incorrect elasticsearch.version.
elasticsearch.version=6.4.1
elasticsearch.version=7.9.1
#
### deprecated elements for jvm plugins :
#
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/TestThulac.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class TestThulac {

@Test
public void test2() throws IOException {
ThulacLiteTokenizerScanner tokenizer = new ThulacLiteTokenizerScanner(new Configuration(environment));
InputStreamReader isr =new InputStreamReader(getClass().getClassLoader().getResource("input").openStream());
ThulacLiteTokenizerScanner tokenizer = new ThulacLiteTokenizerScanner(new Configuration());
InputStreamReader isr = new InputStreamReader(getClass().getClassLoader().getResource("input").openStream());
tokenizer.reset(isr);
while (tokenizer.hasNext()) {
TaggedWord token = tokenizer.next();
Expand Down

0 comments on commit ddc29e6

Please sign in to comment.