├── .github └── workflows │ └── mavenpublish.yml ├── .gitignore ├── README.md ├── pom.xml └── src ├── main ├── assemblies │ └── plugin.xml ├── java │ └── red │ │ └── shiwen │ │ └── firestEsPlugin │ │ ├── ExpertScriptPlugin.java │ │ ├── MyFirstPlugin.java │ │ ├── MyNativeScriptPlugin.java │ │ └── fieldaddScriptPlugin.java └── resources │ └── plugin-descriptor.properties └── test └── java └── red └── shiwen └── firestEsPlugin └── AppTest.java /.github/workflows/mavenpublish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path 3 | 4 | name: Maven Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - uses: actions/checkout@v2 17 | - name: Set up JDK 1.8 18 | uses: actions/setup-java@v1 19 | with: 20 | java-version: 1.8 21 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml 22 | settings-path: ${{ github.workspace }} # location for the settings.xml file 23 | 24 | - name: Build with Maven 25 | run: mvn -B package --file pom.xml 26 | 27 | - name: Publish to GitHub Packages Apache Maven 28 | run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml 29 | env: 30 | GITHUB_TOKEN: ${{ github.token }} 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ 25 | 26 | .mvn 27 | mvnw 28 | mvnw.cmd 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # elasticsearchpluginsample 2 | 3 | ### elasticsearch 插件demo 4 | 5 | 本例包含三个脚本插件 6 | * MyFirstPlugin 7 | 该插件仅用于了解基本plugin结构,es加载时只输出一段log 8 | 9 | * MyNativeScriptPlugin 10 | 该插件通过NativeScriptFactory实现简单的功能,计算给定字段(String类型)的字符长度并加上"add"参数的值作为_score 11 | 12 | * fieldaddScriptPlugin 13 | 遵循elasticsearch5.6.X版本的插件规范,实现指定数组字段相加并添加并与给定参数相加功能 14 | 15 | * 三个插件在编译时需要指定pom.xml文件中的配置项 16 | ``` 17 | red.shiwen.firestEsPlugin.fieldaddScriptPlugin 18 | ``` 19 | 20 | ### 部署方法 21 | ``` 22 | mvn clean install 23 | cp target/releases/firestEsPlugin-5.6.4.zip elasticsearch-5.6.4/plugins 24 | cd elasticsearch-5.6.4/plugins 25 | unzip firestEsPlugin-5.6.4.zip 26 | mv elasticsearch firestEsPlugin 27 | rm -fr firestEsPlugin-5.6.4.zip 28 | ``` 29 | 30 | ### 启动es后输出 31 | ``` 32 | [2018-01-02T21:01:23,710][WARN ][r.s.f.MyFirstPlugin ] This is MyNativeScriptPlugin 33 | ``` 34 | 35 | ### 插件测试方法 36 | 37 | * 导入测试数据 38 | ``` 39 | PUT hockey/player/_bulk?refresh 40 | {"index":{"_id":1}} 41 | {"first":"johnny","last":"gaudreau","goals":[9,27,1],"assists":[17,46,0],"gp":[26,82,1],"born":"1993/08/13"} 42 | {"index":{"_id":2}} 43 | {"first":"sean","last":"monohan","goals":[7,54,26],"assists":[11,26,13],"gp":[26,82,82],"born":"1994/10/12"} 44 | {"index":{"_id":3}} 45 | {"first":"jiri","last":"hudler","goals":[5,34,36],"assists":[11,62,42],"gp":[24,80,79],"born":"1984/01/04"} 46 | {"index":{"_id":4}} 47 | {"first":"micheal","last":"frolik","goals":[4,6,15],"assists":[8,23,15],"gp":[26,82,82],"born":"1988/02/17"} 48 | {"index":{"_id":5}} 49 | {"first":"sam","last":"bennett","goals":[5,0,0],"assists":[8,1,0],"gp":[26,1,0],"born":"1996/06/20"} 50 | {"index":{"_id":6}} 51 | {"first":"dennis","last":"wideman","goals":[0,26,15],"assists":[11,30,24],"gp":[26,81,82],"born":"1983/03/20"} 52 | {"index":{"_id":7}} 53 | {"first":"david","last":"jones","goals":[7,19,5],"assists":[3,17,4],"gp":[26,45,34],"born":"1984/08/10"} 54 | {"index":{"_id":8}} 55 | {"first":"tj","last":"brodie","goals":[2,14,7],"assists":[8,42,30],"gp":[26,82,82],"born":"1990/06/07"} 56 | {"index":{"_id":39}} 57 | {"first":"mark","last":"giordano","goals":[6,30,15],"assists":[3,30,24],"gp":[26,60,63],"born":"1983/10/03"} 58 | {"index":{"_id":10}} 59 | {"first":"mikael","last":"backlund","goals":[3,15,13],"assists":[6,24,18],"gp":[26,82,82],"born":"1989/03/17"} 60 | {"index":{"_id":11}} 61 | {"first":"joe","last":"colborne","goals":[3,18,13],"assists":[6,20,24],"gp":[26,67,82],"born":"1990/01/30"} 62 | ``` 63 | 64 | * MyNativeScriptPlugin 查询语句 65 | ``` 66 | GET hockey/_search 67 | { 68 | "query": { 69 | 70 | "function_score": { 71 | 72 | "functions": [ 73 | { 74 | "script_score": { 75 | "script": { 76 | "source": "my_script", 77 | "lang" : "native", 78 | "params": { 79 | "add": 3 80 | } 81 | } 82 | } 83 | } 84 | ] 85 | } 86 | } 87 | } 88 | ``` 89 | 90 | 修改"params"中"add"的值,观察返回结果中"_score"的变化 91 | 92 | 93 | * fieldaddScriptPlugin 查询语句 94 | ``` 95 | GET hockey/_search 96 | { 97 | "query": { 98 | "function_score": { 99 | "query": { 100 | "match": { 101 | "first": "sam" 102 | } 103 | }, 104 | "functions": [ 105 | { 106 | "script_score": { 107 | "script": { 108 | "source": "example_add", 109 | "lang": "expert_scripts", 110 | "params": { 111 | "fieldname": "goals", 112 | "inc": 2 113 | } 114 | } 115 | } 116 | } 117 | ] 118 | } 119 | } 120 | } 121 | ``` 122 | 修改"params"中"inc"的值,观察返回结果中"_score"的变化 123 | 124 | 125 | #### 参考文档 126 | http://cwiki.apachecn.org/pages/viewpage.action?pageId=9405376 127 | https://programtalk.com/java-api-usage-examples/org.elasticsearch.script.ScriptEngineService/ 128 | 129 | 130 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | red.shiwen 6 | firestEsPlugin 7 | ${elasticsearch.version} 8 | jar 9 | 10 | firestEsPlugin 11 | http://maven.apache.org 12 | 13 | 14 | UTF-8 15 | 16 | 5.6.4 17 | 1.8 18 | ${project.basedir}/src/main/assemblies/plugin.xml 19 | firestesplugin 20 | red.shiwen.firestEsPlugin.fieldaddScriptPlugin 21 | true 22 | 23 | 24 | 6.4.1 25 | 26 | 27 | 28 | 29 | org.elasticsearch 30 | elasticsearch 31 | ${elasticsearch.version} 32 | provided 33 | 34 | 35 | 36 | junit 37 | junit 38 | 3.8.1 39 | test 40 | 41 | 42 | 43 | 44 | 45 | 46 | src/main/resources 47 | false 48 | 49 | *.properties 50 | 51 | 52 | 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-assembly-plugin 57 | 2.6 58 | 59 | false 60 | ${project.build.directory}/releases/ 61 | 62 | ${basedir}/src/main/assemblies/plugin.xml 63 | 64 | 65 | 66 | 67 | package 68 | 69 | single 70 | 71 | 72 | 73 | 74 | 75 | org.apache.maven.plugins 76 | maven-compiler-plugin 77 | 3.5.1 78 | 79 | ${maven.compiler.target} 80 | ${maven.compiler.target} 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/main/assemblies/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | plugin 4 | 5 | zip 6 | 7 | false 8 | 9 | 10 | ${project.basedir}/src/main/resources/plugin-descriptor.properties 11 | elasticsearch 12 | true 13 | 14 | 15 | 16 | 17 | elasticsearch 18 | true 19 | true 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/red/shiwen/firestEsPlugin/ExpertScriptPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package red.shiwen.firestEsPlugin; 21 | 22 | import java.io.IOException; 23 | import java.io.UncheckedIOException; 24 | import java.util.Map; 25 | import java.util.function.Function; 26 | 27 | import org.apache.lucene.index.LeafReaderContext; 28 | import org.apache.lucene.index.PostingsEnum; 29 | import org.apache.lucene.index.Term; 30 | import org.elasticsearch.common.Nullable; 31 | import org.elasticsearch.common.settings.Settings; 32 | import org.elasticsearch.plugins.Plugin; 33 | import org.elasticsearch.plugins.ScriptPlugin; 34 | import org.elasticsearch.script.CompiledScript; 35 | import org.elasticsearch.script.ExecutableScript; 36 | import org.elasticsearch.script.LeafSearchScript; 37 | import org.elasticsearch.script.ScriptEngineService; 38 | import org.elasticsearch.script.SearchScript; 39 | import org.elasticsearch.search.lookup.SearchLookup; 40 | 41 | /** 42 | * An example script plugin that adds a {@link ScriptEngineService} implementing expert scoring. 43 | */ 44 | public class ExpertScriptPlugin extends Plugin implements ScriptPlugin { 45 | 46 | @Override 47 | public ScriptEngineService getScriptEngineService(Settings settings) { 48 | return new MyExpertScriptEngine(); 49 | } 50 | 51 | /** An example {@link ScriptEngineService} that uses Lucene segment details to implement pure document frequency scoring. */ 52 | // tag::expert_engine 53 | private static class MyExpertScriptEngine implements ScriptEngineService { 54 | @Override 55 | public String getType() { 56 | return "expert_scripts"; 57 | } 58 | 59 | @Override 60 | public Function,SearchScript> compile(String scriptName, String scriptSource, Map params) { 61 | // we use the script "source" as the script identifier 62 | if ("pure_df".equals(scriptSource)) { 63 | return p -> new SearchScript() { 64 | final String field; 65 | final String term; 66 | { 67 | if (p.containsKey("field") == false) { 68 | throw new IllegalArgumentException("Missing parameter [field]"); 69 | } 70 | if (p.containsKey("term") == false) { 71 | throw new IllegalArgumentException("Missing parameter [term]"); 72 | } 73 | field = p.get("field").toString(); 74 | term = p.get("term").toString(); 75 | } 76 | 77 | @Override 78 | public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException { 79 | PostingsEnum postings = context.reader().postings(new Term(field, term)); 80 | if (postings == null) { 81 | // the field and/or term don't exist in this segment, so always return 0 82 | return () -> 0.0d; 83 | } 84 | return new LeafSearchScript() { 85 | int currentDocid = -1; 86 | @Override 87 | public void setDocument(int docid) { 88 | // advance has undefined behavior calling with a docid <= its current docid 89 | if (postings.docID() < docid) { 90 | try { 91 | postings.advance(docid); 92 | } catch (IOException e) { 93 | throw new UncheckedIOException(e); 94 | } 95 | } 96 | currentDocid = docid; 97 | } 98 | @Override 99 | public double runAsDouble() { 100 | if (postings.docID() != currentDocid) { 101 | // advance moved past the current doc, so this doc has no occurrences of the term 102 | return 0.0d; 103 | } 104 | try { 105 | return postings.freq(); 106 | } catch (IOException e) { 107 | throw new UncheckedIOException(e); 108 | } 109 | } 110 | }; 111 | } 112 | 113 | @Override 114 | public boolean needsScores() { 115 | return false; 116 | } 117 | }; 118 | } 119 | throw new IllegalArgumentException("Unknown script name " + scriptSource); 120 | } 121 | 122 | @Override 123 | @SuppressWarnings("unchecked") 124 | public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map params) { 125 | Function,SearchScript> scriptFactory = (Function,SearchScript>) compiledScript.compiled(); 126 | return scriptFactory.apply(params); 127 | } 128 | 129 | @Override 130 | public ExecutableScript executable(CompiledScript compiledScript, @Nullable Map params) { 131 | throw new UnsupportedOperationException(); 132 | } 133 | 134 | @Override 135 | public boolean isInlineScriptEnabled() { 136 | return true; 137 | } 138 | 139 | @Override 140 | public void close() {} 141 | } 142 | // end::expert_engine 143 | } 144 | -------------------------------------------------------------------------------- /src/main/java/red/shiwen/firestEsPlugin/MyFirstPlugin.java: -------------------------------------------------------------------------------- 1 | package red.shiwen.firestEsPlugin; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | import org.elasticsearch.plugins.Plugin; 6 | 7 | public class MyFirstPlugin extends Plugin{ 8 | private final static Logger LOGGER = LogManager.getLogger(MyFirstPlugin.class); 9 | public MyFirstPlugin() { 10 | super(); 11 | LOGGER.warn("This is my fisrt Plugin"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/red/shiwen/firestEsPlugin/MyNativeScriptPlugin.java: -------------------------------------------------------------------------------- 1 | package red.shiwen.firestEsPlugin; 2 | 3 | import java.util.Collections; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | import org.elasticsearch.common.Nullable; 10 | import org.elasticsearch.plugins.Plugin; 11 | import org.elasticsearch.plugins.ScriptPlugin; 12 | import org.elasticsearch.script.AbstractDoubleSearchScript; 13 | import org.elasticsearch.script.ExecutableScript; 14 | import org.elasticsearch.script.NativeScriptFactory; 15 | 16 | public class MyNativeScriptPlugin extends Plugin implements ScriptPlugin { 17 | private final static Logger LOGGER = LogManager.getLogger(MyFirstPlugin.class); 18 | 19 | public MyNativeScriptPlugin() { 20 | super(); 21 | LOGGER.warn("This is MyNativeScriptPlugin"); 22 | } 23 | 24 | @Override 25 | public List getNativeScripts() { 26 | return Collections.singletonList(new MyNativeScriptFactory()); 27 | } 28 | 29 | public static class MyNativeScriptFactory implements NativeScriptFactory { 30 | @Override 31 | public ExecutableScript newScript(@Nullable Map params) { 32 | 33 | // return new MyNativeScript(); 34 | return new AbstractDoubleSearchScript(){ 35 | 36 | @Override 37 | public double runAsDouble() { 38 | int b=0; 39 | if(params.get("add")!=null){ 40 | b= (int) params.get("add"); 41 | } 42 | 43 | String s = source().get("last").toString(); 44 | double a = s.length()+b; 45 | return a; } 46 | }; 47 | } 48 | 49 | @Override 50 | public boolean needsScores() { 51 | return false; 52 | } 53 | 54 | @Override 55 | public String getName() { 56 | return "my_script"; 57 | } 58 | } 59 | 60 | // public static class MyNativeScript extends AbstractDoubleSearchScript { 61 | // @Override 62 | // public double runAsDouble() { 63 | // 64 | // String s = source().get("last").toString(); 65 | // double a = s.length(); 66 | // return a; 67 | // } 68 | // } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/red/shiwen/firestEsPlugin/fieldaddScriptPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to Elasticsearch under one or more contributor 3 | * license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright 5 | * ownership. Elasticsearch licenses this file to you under 6 | * the Apache License, Version 2.0 (the "License"); you may 7 | * not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | package red.shiwen.firestEsPlugin; 21 | 22 | import java.io.IOException; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | import org.apache.lucene.index.LeafReaderContext; 27 | 28 | import org.elasticsearch.common.Nullable; 29 | import org.elasticsearch.common.settings.Settings; 30 | import org.elasticsearch.plugins.Plugin; 31 | import org.elasticsearch.plugins.ScriptPlugin; 32 | import org.elasticsearch.script.*; 33 | import org.elasticsearch.search.lookup.LeafSearchLookup; 34 | import org.elasticsearch.search.lookup.SearchLookup; 35 | 36 | 37 | /** 38 | * An example script plugin that adds a {@link ScriptEngineService} implementing expert scoring. 39 | */ 40 | public class fieldaddScriptPlugin extends Plugin implements ScriptPlugin { 41 | 42 | @Override 43 | public ScriptEngineService getScriptEngineService(Settings settings) { 44 | return new MyExpertScriptEngine(); 45 | } 46 | 47 | /** 48 | * An example {@link ScriptEngineService} that uses Lucene segment details to implement pure document frequency scoring. 49 | */ 50 | // tag::expert_engine 51 | private static class MyExpertScriptEngine implements ScriptEngineService { 52 | 53 | 54 | @Override 55 | public String getType() { 56 | return "expert_scripts"; 57 | } 58 | 59 | @Override 60 | public Object compile(String scriptName, String scriptSource, Map params) { 61 | if ("example_add".equals(scriptSource)) { 62 | return scriptSource; 63 | } 64 | throw new IllegalArgumentException("Unknown script name " + scriptSource); 65 | } 66 | 67 | @Override 68 | @SuppressWarnings("unchecked") 69 | public SearchScript search(CompiledScript compiledScript, SearchLookup lookup, @Nullable Map vars) { 70 | 71 | /** 72 | * 校验输入参数,DSL中params 参数列表 73 | */ 74 | final long inc; 75 | final String fieldname; 76 | if (vars == null || vars.containsKey("inc") == false) { 77 | inc = 0; 78 | } else { 79 | inc = ((Number) vars.get("inc")).longValue(); 80 | } 81 | 82 | if (vars == null || vars.containsKey("fieldname") == false) { 83 | throw new IllegalArgumentException("Missing parameter [fieldname]"); 84 | } else { 85 | fieldname = (String) vars.get("fieldname"); 86 | } 87 | 88 | return new SearchScript() { 89 | @Override 90 | public LeafSearchScript getLeafSearchScript(LeafReaderContext context) throws IOException { 91 | final LeafSearchLookup leafLookup = lookup.getLeafSearchLookup(context); 92 | 93 | return new LeafSearchScript() { 94 | @Override 95 | public void setDocument(int doc) { 96 | if (leafLookup != null) { 97 | leafLookup.setDocument(doc); 98 | } 99 | } 100 | 101 | @Override 102 | public double runAsDouble() { 103 | long values = 0; 104 | /** 105 | * 获取document中字段内容 106 | */ 107 | for (Object v : (List) leafLookup.doc().get(fieldname)) { 108 | values = ((Number) v).longValue() + values; 109 | } 110 | return values + inc; 111 | } 112 | }; 113 | } 114 | 115 | @Override 116 | public boolean needsScores() { 117 | return false; 118 | } 119 | }; 120 | } 121 | 122 | @Override 123 | public ExecutableScript executable(CompiledScript compiledScript, @Nullable Map params) { 124 | throw new UnsupportedOperationException(); 125 | } 126 | 127 | @Override 128 | public boolean isInlineScriptEnabled() { 129 | return true; 130 | } 131 | 132 | @Override 133 | public void close() { 134 | } 135 | } 136 | // end::expert_engine 137 | } 138 | -------------------------------------------------------------------------------- /src/main/resources/plugin-descriptor.properties: -------------------------------------------------------------------------------- 1 | # Elasticsearch plugin descriptor file 2 | # This file must exist as 'plugin-descriptor.properties' at 3 | # the root directory of all plugins. 4 | # 5 | # A plugin can be 'site', 'jvm', or both. 6 | # 7 | ### example site plugin for "foo": 8 | # 9 | # foo.zip <-- zip file for the plugin, with this structure: 10 | # _site/ <-- the contents that will be served 11 | # plugin-descriptor.properties <-- example contents below: 12 | # 13 | # site=true 14 | # description=My cool plugin 15 | # version=1.0 16 | # 17 | ### example jvm plugin for "foo" 18 | # 19 | # foo.zip <-- zip file for the plugin, with this structure: 20 | # .jar <-- classes, resources, dependencies 21 | # .jar <-- any number of jars 22 | # plugin-descriptor.properties <-- example contents below: 23 | # 24 | # jvm=true 25 | # classname=foo.bar.BazPlugin 26 | # description=My cool plugin 27 | # version=2.0.0-rc1 28 | # elasticsearch.version=2.0 29 | # java.version=1.7 30 | # 31 | ### mandatory elements for all plugins: 32 | # 33 | # 'description': simple summary of the plugin 34 | description=${project.description} 35 | # 36 | # 'version': plugin's version 37 | version=${project.version} 38 | # 39 | # 'name': the plugin name 40 | name=${elasticsearch.plugin.name} 41 | 42 | ### mandatory elements for site plugins: 43 | # 44 | # 'site': set to true to indicate contents of the _site/ 45 | # directory in the root of the plugin should be served. 46 | site=${elasticsearch.plugin.site} 47 | # 48 | ### mandatory elements for jvm plugins : 49 | # 50 | # 'jvm': true if the 'classname' class should be loaded 51 | # from jar files in the root directory of the plugin. 52 | # Note that only jar files in the root directory are 53 | # added to the classpath for the plugin! If you need 54 | # other resources, package them into a resources jar. 55 | jvm=${elasticsearch.plugin.jvm} 56 | # 57 | # 'classname': the name of the class to load, fully-qualified. 58 | classname=${elasticsearch.plugin.classname} 59 | # 60 | # 'java.version' version of java the code is built against 61 | # use the system property java.specification.version 62 | # version string must be a sequence of nonnegative decimal integers 63 | # separated by "."'s and may have leading zeros 64 | java.version=${maven.compiler.target} 65 | # 66 | # 'elasticsearch.version' version of elasticsearch compiled against 67 | # You will have to release a new version of the plugin for each new 68 | # elasticsearch release. This version is checked when the plugin 69 | # is loaded so Elasticsearch will refuse to start in the presence of 70 | # plugins with the incorrect elasticsearch.version. 71 | elasticsearch.version=${elasticsearch.version} 72 | # 73 | ### deprecated elements for jvm plugins : 74 | # 75 | # 'isolated': true if the plugin should have its own classloader. 76 | # passing false is deprecated, and only intended to support plugins 77 | # that have hard dependencies against each other. If this is 78 | # not specified, then the plugin is isolated by default. 79 | isolated=${elasticsearch.plugin.isolated} 80 | # -------------------------------------------------------------------------------- /src/test/java/red/shiwen/firestEsPlugin/AppTest.java: -------------------------------------------------------------------------------- 1 | package red.shiwen.firestEsPlugin; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | --------------------------------------------------------------------------------