From 7c70b05560ce2d6ab783c869d263dc207972dd68 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 21 Oct 2015 08:51:25 -0600 Subject: [PATCH 01/37] Add .dir-locals.el file for Intellij-style indentation --- .dir-locals.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 00000000000..c7461942041 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,65 @@ +((java-mode + . + ((eval + . + (progn + (defun my/point-in-defun-declaration-p () + (let ((bod (save-excursion (c-beginning-of-defun) + (point)))) + (<= bod + (point) + (save-excursion (goto-char bod) + (re-search-forward "{") + (point))))) + + (defun my/is-string-concatenation-p () + "Returns true if the previous line is a string concatenation" + (save-excursion + (let ((start (point))) + (forward-line -1) + (if (re-search-forward " \\\+$" start t) t nil)))) + + (defun my/inside-java-lambda-p () + "Returns true if point is the first statement inside of a lambda" + (save-excursion + (c-beginning-of-statement-1) + (let ((start (point))) + (forward-line -1) + (if (search-forward " -> {" start t) t nil)))) + + (defun my/arglist-cont-nonempty-indentation (arg) + (if (my/inside-java-lambda-p) + '+ + (if (my/is-string-concatenation-p) + 16 + (unless (my/point-in-defun-declaration-p) '++)))) + + (defun my/statement-block-intro (arg) + (if (and (c-at-statement-start-p) (my/inside-java-lambda-p)) 0 '+)) + + (defun my/block-close (arg) + (if (my/inside-java-lambda-p) '- 0)) + + (c-set-offset 'inline-open 0) + (c-set-offset 'topmost-intro-cont '+) + (c-set-offset 'statement-block-intro 'my/statement-block-intro) + (c-set-offset 'block-close 'my/block-close) + (c-set-offset 'knr-argdecl-intro '+) + (c-set-offset 'substatement-open '+) + (c-set-offset 'substatement-label '+) + (c-set-offset 'case-label '+) + (c-set-offset 'label '+) + (c-set-offset 'statement-case-open '+) + (c-set-offset 'statement-cont '++) + (c-set-offset 'arglist-intro 0) + (c-set-offset 'arglist-cont-nonempty '(my/arglist-cont-nonempty-indentation c-lineup-arglist)) + (c-set-offset 'arglist-close '--) + (c-set-offset 'inexpr-class 0) + (c-set-offset 'access-label 0) + (c-set-offset 'inher-intro '++) + (c-set-offset 'inher-cont '++) + (c-set-offset 'brace-list-intro '+) + (c-set-offset 'func-decl-cont '++) + )) + (c-basic-offset . 4) + (c-comment-only-line-offset . (0 . 0))))) From 182fda73c673f5505214f7b695749310f23815b8 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 21 Oct 2015 20:25:45 -0600 Subject: [PATCH 02/37] Add .projectile project file --- .projectile | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .projectile diff --git a/.projectile b/.projectile new file mode 100644 index 00000000000..d2a5e762a88 --- /dev/null +++ b/.projectile @@ -0,0 +1,32 @@ +-/target +-/core/target +-/qa/target +-/rest-api-spec/target +-/test-framework/target +-/plugins/target +-/plugins/analysis-icu/target +-/plugins/analysis-kuromoji/target +-/plugins/analysis-phonetic/target +-/plugins/analysis-smartcn/target +-/plugins/analysis-stempel/target +-/plugins/cloud-aws/target +-/plugins/cloud-azure/target +-/plugins/cloud-gce/target +-/plugins/delete-by-query/target +-/plugins/discovery-azure/target +-/plugins/discovery-ec2/target +-/plugins/discovery-gce/target +-/plugins/discovery-multicast/target +-/plugins/jvm-example/target +-/plugins/lang-expression/target +-/plugins/lang-groovy/target +-/plugins/lang-javascript/target +-/plugins/lang-python/target +-/plugins/mapper-murmur3/target +-/plugins/mapper-size/target +-/plugins/repository-azure/target +-/plugins/repository-s3/target +-/plugins/site-example/target +-/plugins/store-smb/target +-/plugins/target +-*.class From 490cdfac5c441effaa2148a7325404f24d56d3d1 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 22 Oct 2015 10:54:01 -0600 Subject: [PATCH 03/37] Fix indentation for trailing parentheses (people shouldn't write trailing parentheses anyway!) --- .dir-locals.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index c7461942041..9b0d487fb62 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -27,6 +27,14 @@ (forward-line -1) (if (search-forward " -> {" start t) t nil)))) + (defun my/trailing-paren-p () + "Returns true if point is a training paren and semicolon" + (save-excursion + (end-of-line) + (let ((endpoint (point))) + (beginning-of-line) + (if (re-search-forward "[ ]*);$" endpoint t) t nil)))) + (defun my/arglist-cont-nonempty-indentation (arg) (if (my/inside-java-lambda-p) '+ @@ -40,6 +48,8 @@ (defun my/block-close (arg) (if (my/inside-java-lambda-p) '- 0)) + (defun my/arglist-close (arg) (if (my/trailing-paren-p) 0 '--)) + (c-set-offset 'inline-open 0) (c-set-offset 'topmost-intro-cont '+) (c-set-offset 'statement-block-intro 'my/statement-block-intro) @@ -53,7 +63,7 @@ (c-set-offset 'statement-cont '++) (c-set-offset 'arglist-intro 0) (c-set-offset 'arglist-cont-nonempty '(my/arglist-cont-nonempty-indentation c-lineup-arglist)) - (c-set-offset 'arglist-close '--) + (c-set-offset 'arglist-close 'my/arglist-close) (c-set-offset 'inexpr-class 0) (c-set-offset 'access-label 0) (c-set-offset 'inher-intro '++) From 2c16adb78430c544dedf02cc8c8306e3dba1e127 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 28 Oct 2015 15:46:13 -0600 Subject: [PATCH 04/37] Special case when an argument is called with no args in the line --- .dir-locals.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.dir-locals.el b/.dir-locals.el index 9b0d487fb62..68db3a9248b 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -35,6 +35,13 @@ (beginning-of-line) (if (re-search-forward "[ ]*);$" endpoint t) t nil)))) + (defun my/prev-line-call-with-no-args-p () + "Return true if the previous line is a function call with no arguments" + (save-excursion + (let ((start (point))) + (forward-line -1) + (if (re-search-forward ".($" start t) t nil)))) + (defun my/arglist-cont-nonempty-indentation (arg) (if (my/inside-java-lambda-p) '+ @@ -50,6 +57,9 @@ (defun my/arglist-close (arg) (if (my/trailing-paren-p) 0 '--)) + (defun my/arglist-intro (arg) + (if (my/prev-line-call-with-no-args-p) '++ 0)) + (c-set-offset 'inline-open 0) (c-set-offset 'topmost-intro-cont '+) (c-set-offset 'statement-block-intro 'my/statement-block-intro) @@ -61,7 +71,7 @@ (c-set-offset 'label '+) (c-set-offset 'statement-case-open '+) (c-set-offset 'statement-cont '++) - (c-set-offset 'arglist-intro 0) + (c-set-offset 'arglist-intro 'my/arglist-intro) (c-set-offset 'arglist-cont-nonempty '(my/arglist-cont-nonempty-indentation c-lineup-arglist)) (c-set-offset 'arglist-close 'my/arglist-close) (c-set-offset 'inexpr-class 0) From 8880474f11c1706464fd98f100550b1b626c80ee Mon Sep 17 00:00:00 2001 From: jmferrer Date: Thu, 29 Oct 2015 11:00:21 +0100 Subject: [PATCH 05/37] typo error: adress -> address --- distribution/src/main/resources/config/elasticsearch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/src/main/resources/config/elasticsearch.yml b/distribution/src/main/resources/config/elasticsearch.yml index b1b11223f0f..51630fe0804 100644 --- a/distribution/src/main/resources/config/elasticsearch.yml +++ b/distribution/src/main/resources/config/elasticsearch.yml @@ -49,7 +49,7 @@ # # ---------------------------------- Network ----------------------------------- # -# Set the bind adress to a specific IP (IPv4 or IPv6): +# Set the bind address to a specific IP (IPv4 or IPv6): # # network.host: 192.168.0.1 # From 33341600037bc72464ef56d6be5650ca99ac2069 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Fri, 16 Oct 2015 12:21:46 +0200 Subject: [PATCH 06/37] improved building of disco nodes * improved retry policy of ec2 client * cache results for 10s --- docs/plugins/discovery-ec2.asciidoc | 6 ++- .../cloud/aws/AwsEc2Service.java | 1 + .../cloud/aws/AwsEc2ServiceImpl.java | 22 ++++++++++ .../ec2/AwsEc2UnicastHostsProvider.java | 33 ++++++++++++++ .../discovery/ec2/Ec2DiscoveryTests.java | 44 +++++++++++++++++++ 5 files changed, 105 insertions(+), 1 deletion(-) diff --git a/docs/plugins/discovery-ec2.asciidoc b/docs/plugins/discovery-ec2.asciidoc index 5ac208576df..a2b80495003 100644 --- a/docs/plugins/discovery-ec2.asciidoc +++ b/docs/plugins/discovery-ec2.asciidoc @@ -165,6 +165,11 @@ The following are a list of settings (prefixed with `discovery.ec2`) that can fu Defaults to `3s`. If no unit like `ms`, `s` or `m` is specified, milliseconds are used. +`node_cache_time`:: + + How long the list of hosts is cached to prevent further requests to the AWS API. + Defaults to `10s`. + [IMPORTANT] .Binding the network host @@ -195,7 +200,6 @@ as valid network host settings: |`_ec2_` |equivalent to _ec2:privateIpv4_. |================================================================== - [[discovery-ec2-permissions]] ===== Recommended EC2 Permissions diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java index ab2b54633f4..a427b4af4ab 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java @@ -49,6 +49,7 @@ public interface AwsEc2Service extends LifecycleComponent { public static final String GROUPS = "discovery.ec2.groups"; public static final String TAG_PREFIX = "discovery.ec2.tag."; public static final String AVAILABILITY_ZONES = "discovery.ec2.availability_zones"; + public static final String NODE_CACHE_TIME = "discovery.ec2.node_cache_time"; } AmazonEC2 client(); diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java index 26e001c2666..39ece106df8 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java @@ -19,10 +19,13 @@ package org.elasticsearch.cloud.aws; +import com.amazonaws.AmazonClientException; +import com.amazonaws.AmazonWebServiceRequest; import com.amazonaws.ClientConfiguration; import com.amazonaws.Protocol; import com.amazonaws.auth.*; import com.amazonaws.internal.StaticCredentialsProvider; +import com.amazonaws.retry.RetryPolicy; import com.amazonaws.services.ec2.AmazonEC2; import com.amazonaws.services.ec2.AmazonEC2Client; import org.elasticsearch.ElasticsearchException; @@ -36,6 +39,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; import java.util.Locale; +import java.util.Random; /** * @@ -103,6 +107,24 @@ public class AwsEc2ServiceImpl extends AbstractLifecycleComponent } } + // Increase the number of retries in case of 5xx API responses + final Random rand = new Random(); + RetryPolicy retryPolicy = new RetryPolicy( + RetryPolicy.RetryCondition.NO_RETRY_CONDITION, + new RetryPolicy.BackoffStrategy() { + @Override + public long delayBeforeNextRetry(AmazonWebServiceRequest originalRequest, + AmazonClientException exception, + int retriesAttempted) { + // with 10 retries the max delay time is 320s/320000ms (10 * 2^5 * 1 * 1000) + logger.warn("EC2 API request failed, retry again. Reason was:", exception); + return 1000L * (long) (10d * Math.pow(2, ((double) retriesAttempted) / 2.0d) * (1.0d + rand.nextDouble())); + } + }, + 10, + false); + clientConfiguration.setRetryPolicy(retryPolicy); + AWSCredentialsProvider credentials; if (account == null && key == null) { diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java index 94c65047847..f7e70281a3d 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java @@ -31,6 +31,8 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.util.SingleObjectCache; import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider; import org.elasticsearch.transport.TransportService; @@ -64,6 +66,8 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni private final HostType hostType; + private final DiscoNodesCache discoNodes; + @Inject public AwsEc2UnicastHostsProvider(Settings settings, TransportService transportService, AwsEc2Service awsEc2Service, Version version) { super(settings); @@ -74,6 +78,9 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni this.hostType = HostType.valueOf(settings.get(DISCOVERY_EC2.HOST_TYPE, "private_ip") .toUpperCase(Locale.ROOT)); + this.discoNodes = new DiscoNodesCache(this.settings.getAsTime(DISCOVERY_EC2.NODE_CACHE_TIME, + TimeValue.timeValueMillis(10_000L))); + this.bindAnyGroup = settings.getAsBoolean(DISCOVERY_EC2.ANY_GROUP, true); this.groups = new HashSet<>(); groups.addAll(Arrays.asList(settings.getAsArray(DISCOVERY_EC2.GROUPS))); @@ -94,6 +101,11 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni @Override public List buildDynamicNodes() { + return discoNodes.getOrRefresh(); + } + + protected List fetchDynamicNodes() { + List discoNodes = new ArrayList<>(); DescribeInstancesResult descInstances; @@ -199,4 +211,25 @@ public class AwsEc2UnicastHostsProvider extends AbstractComponent implements Uni return describeInstancesRequest; } + + private final class DiscoNodesCache extends SingleObjectCache> { + + private boolean empty = true; + + protected DiscoNodesCache(TimeValue refreshInterval) { + super(refreshInterval, new ArrayList<>()); + } + + @Override + protected boolean needsRefresh() { + return (empty || super.needsRefresh()); + } + + @Override + protected List refresh() { + List nodes = fetchDynamicNodes(); + empty = nodes.isEmpty(); + return nodes; + } + } } diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java index ca9493bc4c9..4fc3faef316 100644 --- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java +++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.local.LocalTransport; import org.junit.AfterClass; import org.junit.Before; @@ -231,4 +232,47 @@ public class Ec2DiscoveryTests extends ESTestCase { assertThat(discoveryNodes, hasSize(prodInstances)); } + abstract class DummyEc2HostProvider extends AwsEc2UnicastHostsProvider { + public int fetchCount = 0; + public DummyEc2HostProvider(Settings settings, TransportService transportService, AwsEc2Service service, Version version) { + super(settings, transportService, service, version); + } + } + + public void testGetNodeListEmptyCache() throws Exception { + AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(Settings.EMPTY, 1, null); + DummyEc2HostProvider provider = new DummyEc2HostProvider(Settings.EMPTY, transportService, awsEc2Service, Version.CURRENT) { + @Override + protected List fetchDynamicNodes() { + fetchCount++; + return new ArrayList<>(); + } + }; + for (int i=0; i<3; i++) { + provider.buildDynamicNodes(); + } + assertEquals(provider.fetchCount, is(3)); + } + + public void testGetNodeListCached() throws Exception { + Settings.Builder builder = Settings.settingsBuilder() + .put(DISCOVERY_EC2.NODE_CACHE_TIME, "500ms"); + AwsEc2Service awsEc2Service = new AwsEc2ServiceMock(Settings.EMPTY, 1, null); + DummyEc2HostProvider provider = new DummyEc2HostProvider(builder.build(), transportService, awsEc2Service, Version.CURRENT) { + @Override + protected List fetchDynamicNodes() { + fetchCount++; + return Ec2DiscoveryTests.this.buildDynamicNodes(Settings.EMPTY, 1); + } + }; + for (int i=0; i<3; i++) { + provider.buildDynamicNodes(); + } + assertEquals(provider.fetchCount, is(1)); + Thread.sleep(1_000L); // wait for cache to expire + for (int i=0; i<3; i++) { + provider.buildDynamicNodes(); + } + assertEquals(provider.fetchCount, is(2)); + } } From a8268ba37dbe50e85bb7ef4d886a2faedc6f2f1e Mon Sep 17 00:00:00 2001 From: Jeff Destine Date: Thu, 29 Oct 2015 13:09:11 -0400 Subject: [PATCH 07/37] Adding US-Gov-West --- .../java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java index 26e001c2666..7a26a4ff142 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/cloud/aws/AwsEc2ServiceImpl.java @@ -134,6 +134,8 @@ public class AwsEc2ServiceImpl extends AbstractLifecycleComponent endpoint = "ec2.us-west-2.amazonaws.com"; } else if (region.equals("ap-southeast") || region.equals("ap-southeast-1")) { endpoint = "ec2.ap-southeast-1.amazonaws.com"; + } else if (region.equals("us-gov-west") || region.equals("us-gov-west-1")) { + endpoint = "ec2.us-gov-west-1.amazonaws.com"; } else if (region.equals("ap-southeast-2")) { endpoint = "ec2.ap-southeast-2.amazonaws.com"; } else if (region.equals("ap-northeast") || region.equals("ap-northeast-1")) { From 15bd182668d40cc15708797c3769e42f848d3be4 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 29 Oct 2015 18:56:43 +0100 Subject: [PATCH 08/37] Properly set indices and indicesOptions on subrequest made by /_cat/indices --- .../org/elasticsearch/rest/action/cat/RestIndicesAction.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java b/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java index d6743b76b30..fa2af91875b 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java @@ -79,7 +79,8 @@ public class RestIndicesAction extends AbstractCatAction { @Override public void processResponse(final ClusterStateResponse clusterStateResponse) { ClusterState state = clusterStateResponse.getState(); - final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, IndicesOptions.fromOptions(false, true, true, true), indices); + final IndicesOptions concreteIndicesOptions = IndicesOptions.fromOptions(false, true, true, true); + final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, concreteIndicesOptions, indices); final String[] openIndices = indexNameExpressionResolver.concreteIndices(state, IndicesOptions.lenientExpandOpen(), indices); ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest(openIndices); clusterHealthRequest.local(request.paramAsBoolean("local", clusterHealthRequest.local())); @@ -87,6 +88,8 @@ public class RestIndicesAction extends AbstractCatAction { @Override public void processResponse(final ClusterHealthResponse clusterHealthResponse) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); + indicesStatsRequest.indices(concreteIndices); + indicesStatsRequest.indicesOptions(concreteIndicesOptions); indicesStatsRequest.all(); client.admin().indices().stats(indicesStatsRequest, new RestResponseListener(channel) { @Override From 0a593109d37d3d5ff149f31abe02544a18cc6723 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 29 Oct 2015 17:12:45 -0700 Subject: [PATCH 09/37] Build: Add gradle version check and some build info that is always output --- buildSrc/build.gradle | 10 ++++----- .../elasticsearch/gradle/BuildPlugin.groovy | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index e987a173bae..eadf1f63784 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -46,11 +46,11 @@ props.load(project.file('../gradle.properties').newDataInputStream()) version = props.getProperty('version') processResources { - inputs.file('../gradle.properties') - filter ReplaceTokens, tokens: [ - 'version': props.getProperty('version'), - 'luceneVersion': props.getProperty('luceneVersion') - ] + inputs.file('../gradle.properties') + filter ReplaceTokens, tokens: [ + 'version': props.getProperty('version'), + 'luceneVersion': props.getProperty('luceneVersion') + ] } extraArchive { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 4b550acc9e4..ee666771319 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -19,12 +19,14 @@ package org.elasticsearch.gradle import org.elasticsearch.gradle.precommit.PrecommitTasks +import org.gradle.api.GradleException import org.gradle.api.JavaVersion import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.util.VersionNumber /** * Encapsulates build configuration for elasticsearch projects. @@ -33,6 +35,7 @@ class BuildPlugin implements Plugin { @Override void apply(Project project) { + globalBuildInfo(project) project.pluginManager.apply('java') project.pluginManager.apply('carrotsearch.randomizedtesting') // these plugins add lots of info to our jars @@ -48,6 +51,25 @@ class BuildPlugin implements Plugin { PrecommitTasks.configure(project) } + static void globalBuildInfo(Project project) { + if (project.rootProject.ext.has('buildChecksDone') == false) { + // enforce gradle version + VersionNumber gradleVersion = VersionNumber.parse(project.gradle.gradleVersion) + if (gradleVersion.major < 2 || gradleVersion.major == 2 && gradleVersion.minor < 6) { + throw new GradleException('Gradle 2.6 or above is required to build elasticsearch') + } + + // Build debugging info + println '=======================================' + println 'Elasticsearch Build Hamster says Hello!' + println '=======================================' + println " Gradle Version : ${project.gradle.gradleVersion}" + println " JDK Version : ${System.getProperty('java.runtime.version')} (${System.getProperty('java.vendor')})" + println " OS Info : ${System.getProperty('os.name')} ${System.getProperty('os.version')} (${System.getProperty('os.arch')})" + project.rootProject.ext.buildChecksDone = true + } + } + /** Adds compiler settings to the project */ static void configureCompile(Project project) { project.afterEvaluate { From c7897a7524e0bee94b5bdc54f8eb72bc2e3b4f77 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Thu, 29 Oct 2015 21:53:33 -0400 Subject: [PATCH 10/37] Make throw statement consistent with others in same class --- core/src/main/java/org/elasticsearch/common/cache/Cache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/common/cache/Cache.java b/core/src/main/java/org/elasticsearch/common/cache/Cache.java index 595ac088140..a6c3bc81afd 100644 --- a/core/src/main/java/org/elasticsearch/common/cache/Cache.java +++ b/core/src/main/java/org/elasticsearch/common/cache/Cache.java @@ -237,7 +237,7 @@ public class Cache { }).get(); } } catch (ExecutionException | InterruptedException e) { - throw new IllegalStateException("future should be a completedFuture for which get should not throw", e); + throw new IllegalStateException(e); } } return Tuple.tuple(entry, existing); From 63f6c6db8596adc71b12e6ec1961b1dc30e000ff Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 29 Oct 2015 23:25:24 -0700 Subject: [PATCH 11/37] Build: Move test framework files to their new location The test jar was previously built in maven by copying class files. With gradle we now have a proper test framework artifact. This change moves the classes used by the test framework into the test-framework module. See #13930 --- core/build.gradle | 17 +--- test-framework/build.gradle | 81 +++++++------------ .../bootstrap/BootstrapForTesting.java | 0 .../cache/recycler/MockPageCacheRecycler.java | 0 .../MockInternalClusterInfoService.java | 0 .../cluster/routing/TestShardRouting.java | 0 .../common/cli/CliToolTestCase.java | 0 .../common/io/PathUtilsForTesting.java | 0 .../common/util/MockBigArrays.java | 0 .../index/MockEngineFactoryPlugin.java | 0 .../java/org/elasticsearch/node/MockNode.java | 0 .../elasticsearch/node/NodeMocksPlugin.java | 0 .../percolator/PercolatorTestUtil.java | 0 .../search/MockSearchService.java | 0 .../bucket/AbstractTermsTestCase.java | 0 ...NativeSignificanceScoreScriptNoParams.java | 0 ...tiveSignificanceScoreScriptWithParams.java | 0 .../bucket/script/TestScript.java | 0 .../metrics/AbstractNumericTestCase.java | 0 .../elasticsearch/test/BackgroundIndexer.java | 0 .../test/CompositeTestCluster.java | 0 .../elasticsearch/test/CorruptionUtils.java | 0 .../elasticsearch/test/DummyShardLock.java | 0 .../test/ESAllocationTestCase.java | 0 .../test/ESBackcompatTestCase.java | 0 .../elasticsearch/test/ESIntegTestCase.java | 0 .../test/ESSingleNodeTestCase.java | 0 .../org/elasticsearch/test/ESTestCase.java | 0 .../test/ESTokenStreamTestCase.java | 0 .../org/elasticsearch/test/ExternalNode.java | 0 .../test/ExternalTestCluster.java | 0 .../test/IndexSettingsModule.java | 0 .../test/InternalTestCluster.java | 0 .../test/MockIndexEventListener.java | 0 .../test/NodeConfigurationSource.java | 0 .../org/elasticsearch/test/StreamsUtils.java | 0 .../org/elasticsearch/test/TestCluster.java | 0 .../elasticsearch/test/TestSearchContext.java | 0 .../org/elasticsearch/test/VersionUtils.java | 0 .../elasticsearch/test/XContentTestUtils.java | 0 .../test/client/RandomizingClient.java | 0 .../test/cluster/NoopClusterService.java | 0 .../test/cluster/TestClusterService.java | 0 .../ClusterDiscoveryConfiguration.java | 0 .../BlockClusterStateProcessing.java | 0 .../IntermittentLongGCDisruption.java | 0 .../test/disruption/LongGCDisruption.java | 0 .../disruption/NetworkDelaysPartition.java | 0 .../NetworkDisconnectPartition.java | 0 .../test/disruption/NetworkPartition.java | 0 .../test/disruption/NetworkPartitionIT.java | 0 .../NetworkUnresponsivePartition.java | 0 .../test/disruption/NoOpDisruptionScheme.java | 0 .../disruption/ServiceDisruptionScheme.java | 0 .../test/disruption/SingleNodeDisruption.java | 0 .../SlowClusterStateProcessing.java | 0 .../test/engine/AssertingSearcher.java | 0 .../test/engine/MockEngineFactory.java | 0 .../test/engine/MockEngineSupport.java | 0 .../test/engine/MockEngineSupportModule.java | 0 .../test/engine/MockInternalEngine.java | 0 .../test/engine/MockShadowEngine.java | 0 .../engine/ThrowingLeafReaderWrapper.java | 0 .../test/gateway/NoopGatewayAllocator.java | 0 .../test/hamcrest/CollectionAssertions.java | 0 .../test/hamcrest/CollectionMatchers.java | 0 .../hamcrest/ElasticsearchAssertions.java | 0 .../test/hamcrest/ElasticsearchMatchers.java | 0 .../test/hamcrest/RegexMatcher.java | 0 .../test/junit/annotations/Network.java | 0 .../test/junit/annotations/TestLogging.java | 0 .../test/junit/listeners/LoggingListener.java | 0 .../junit/listeners/ReproduceInfoPrinter.java | 0 .../junit/rule/RepeatOnExceptionRule.java | 0 .../test/rest/ESRestTestCase.java | 0 .../test/rest/FakeRestRequest.java | 0 .../org/elasticsearch/test/rest/Rest0IT.java | 0 .../org/elasticsearch/test/rest/Rest1IT.java | 0 .../org/elasticsearch/test/rest/Rest2IT.java | 0 .../org/elasticsearch/test/rest/Rest3IT.java | 0 .../org/elasticsearch/test/rest/Rest4IT.java | 0 .../org/elasticsearch/test/rest/Rest5IT.java | 0 .../org/elasticsearch/test/rest/Rest6IT.java | 0 .../org/elasticsearch/test/rest/Rest7IT.java | 0 .../test/rest/RestTestCandidate.java | 0 .../test/rest/RestTestExecutionContext.java | 0 .../org/elasticsearch/test/rest/Stash.java | 0 .../test/rest/client/RestClient.java | 0 .../test/rest/client/RestException.java | 0 .../test/rest/client/RestPath.java | 0 .../test/rest/client/RestResponse.java | 0 .../client/http/HttpDeleteWithEntity.java | 0 .../rest/client/http/HttpGetWithEntity.java | 0 .../rest/client/http/HttpRequestBuilder.java | 0 .../test/rest/client/http/HttpResponse.java | 0 .../test/rest/json/JsonPath.java | 0 .../test/rest/parser/DoSectionParser.java | 0 .../rest/parser/GreaterThanEqualToParser.java | 0 .../test/rest/parser/GreaterThanParser.java | 0 .../test/rest/parser/IsFalseParser.java | 0 .../test/rest/parser/IsTrueParser.java | 0 .../test/rest/parser/LengthParser.java | 0 .../rest/parser/LessThanOrEqualToParser.java | 0 .../test/rest/parser/LessThanParser.java | 0 .../test/rest/parser/MatchParser.java | 0 .../rest/parser/RestTestFragmentParser.java | 0 .../rest/parser/RestTestParseException.java | 0 .../rest/parser/RestTestSectionParser.java | 0 .../parser/RestTestSuiteParseContext.java | 0 .../test/rest/parser/RestTestSuiteParser.java | 0 .../test/rest/parser/SetSectionParser.java | 0 .../test/rest/parser/SetupSectionParser.java | 0 .../test/rest/parser/SkipSectionParser.java | 0 .../test/rest/section/ApiCallSection.java | 0 .../test/rest/section/Assertion.java | 0 .../test/rest/section/DoSection.java | 0 .../test/rest/section/ExecutableSection.java | 0 .../rest/section/GreaterThanAssertion.java | 0 .../section/GreaterThanEqualToAssertion.java | 0 .../test/rest/section/IsFalseAssertion.java | 0 .../test/rest/section/IsTrueAssertion.java | 0 .../test/rest/section/LengthAssertion.java | 0 .../test/rest/section/LessThanAssertion.java | 0 .../section/LessThanOrEqualToAssertion.java | 0 .../test/rest/section/MatchAssertion.java | 0 .../test/rest/section/RestTestSuite.java | 0 .../test/rest/section/SetSection.java | 0 .../test/rest/section/SetupSection.java | 0 .../test/rest/section/SkipSection.java | 0 .../test/rest/section/TestSection.java | 0 .../elasticsearch/test/rest/spec/RestApi.java | 0 .../test/rest/spec/RestApiParser.java | 0 .../test/rest/spec/RestSpec.java | 0 .../test/rest/support/Features.java | 0 .../test/rest/support/FileUtils.java | 0 .../test/store/MockFSDirectoryService.java | 0 .../test/store/MockFSIndexStore.java | 0 .../transport/AssertingLocalTransport.java | 0 .../test/transport/CapturingTransport.java | 0 .../test/transport/MockTransportService.java | 0 .../src/main}/resources/log4j.properties | 0 .../rest/test/AbstractParserTestCase.java | 0 .../test/rest/test/AssertionParsersTests.java | 0 .../test/rest/test/DoSectionParserTests.java | 0 .../test/rest/test/FileUtilsTests.java | 40 ++++----- .../test/rest/test/JsonPathTests.java | 0 .../rest/test/RestApiParserFailingTests.java | 0 .../test/rest/test/RestApiParserTests.java | 0 .../test/rest/test/RestTestParserTests.java | 0 .../test/rest/test/SetSectionParserTests.java | 0 .../rest/test/SetupSectionParserTests.java | 0 .../rest/test/SkipSectionParserTests.java | 0 .../rest/test/TestSectionParserTests.java | 0 .../test/test/InternalTestClusterTests.java | 0 .../test/test/LoggingListenerTests.java | 0 .../test/test/SuiteScopeClusterIT.java | 0 .../test/test/TestScopeClusterIT.java | 0 .../test/test/VersionUtilsTests.java | 0 .../rest-api-spec/test/suite1/10_basic.yaml | 31 +++++++ .../test/suite1/20_another_test.yaml | 21 +++++ .../rest-api-spec/test/suite2/10_basic.yaml | 26 ++++++ .../rest-api-spec/test/suite2/15_test2.yaml | 26 ++++++ 162 files changed, 157 insertions(+), 85 deletions(-) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/bootstrap/BootstrapForTesting.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/cluster/routing/TestShardRouting.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/common/cli/CliToolTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/common/io/PathUtilsForTesting.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/common/util/MockBigArrays.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/index/MockEngineFactoryPlugin.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/node/MockNode.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/node/NodeMocksPlugin.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/percolator/PercolatorTestUtil.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/search/MockSearchService.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/search/aggregations/bucket/script/TestScript.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/BackgroundIndexer.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/CompositeTestCluster.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/CorruptionUtils.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/DummyShardLock.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ESAllocationTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ESBackcompatTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ESIntegTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ESSingleNodeTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ESTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ESTokenStreamTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ExternalNode.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/ExternalTestCluster.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/IndexSettingsModule.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/InternalTestCluster.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/MockIndexEventListener.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/NodeConfigurationSource.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/StreamsUtils.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/TestCluster.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/TestSearchContext.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/VersionUtils.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/XContentTestUtils.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/client/RandomizingClient.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/cluster/NoopClusterService.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/cluster/TestClusterService.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/BlockClusterStateProcessing.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/IntermittentLongGCDisruption.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/LongGCDisruption.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/NetworkDelaysPartition.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/NetworkDisconnectPartition.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/NetworkPartition.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/NetworkUnresponsivePartition.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/NoOpDisruptionScheme.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/ServiceDisruptionScheme.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/disruption/SlowClusterStateProcessing.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/AssertingSearcher.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/MockEngineFactory.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/MockEngineSupport.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/MockEngineSupportModule.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/MockInternalEngine.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/MockShadowEngine.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/engine/ThrowingLeafReaderWrapper.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/gateway/NoopGatewayAllocator.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/hamcrest/CollectionAssertions.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/hamcrest/CollectionMatchers.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/hamcrest/RegexMatcher.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/junit/annotations/Network.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/junit/annotations/TestLogging.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/junit/listeners/LoggingListener.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/junit/rule/RepeatOnExceptionRule.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/ESRestTestCase.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/FakeRestRequest.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest0IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest1IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest2IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest3IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest4IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest5IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest6IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Rest7IT.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/RestTestCandidate.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/RestTestExecutionContext.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/Stash.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/RestClient.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/RestException.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/RestPath.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/RestResponse.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/http/HttpDeleteWithEntity.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/http/HttpGetWithEntity.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/http/HttpRequestBuilder.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/client/http/HttpResponse.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/json/JsonPath.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/DoSectionParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/GreaterThanEqualToParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/GreaterThanParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/IsFalseParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/IsTrueParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/LengthParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/LessThanOrEqualToParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/LessThanParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/MatchParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/RestTestFragmentParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/RestTestParseException.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/RestTestSectionParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/RestTestSuiteParseContext.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/RestTestSuiteParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/SetSectionParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/SetupSectionParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/ApiCallSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/Assertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/DoSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/ExecutableSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/GreaterThanAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/GreaterThanEqualToAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/IsFalseAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/IsTrueAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/LengthAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/LessThanAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/LessThanOrEqualToAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/MatchAssertion.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/RestTestSuite.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/SetSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/SetupSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/SkipSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/section/TestSection.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/spec/RestApi.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/spec/RestApiParser.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/spec/RestSpec.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/support/Features.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/rest/support/FileUtils.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/store/MockFSDirectoryService.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/store/MockFSIndexStore.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/transport/AssertingLocalTransport.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/transport/CapturingTransport.java (100%) rename {core/src/test => test-framework/src/main}/java/org/elasticsearch/test/transport/MockTransportService.java (100%) rename {core/src/test => test-framework/src/main}/resources/log4j.properties (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/AbstractParserTestCase.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java (77%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/test/SuiteScopeClusterIT.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java (100%) rename {core => test-framework}/src/test/java/org/elasticsearch/test/test/VersionUtilsTests.java (100%) create mode 100644 test-framework/src/test/resources/rest-api-spec/test/suite1/10_basic.yaml create mode 100644 test-framework/src/test/resources/rest-api-spec/test/suite1/20_another_test.yaml create mode 100644 test-framework/src/test/resources/rest-api-spec/test/suite2/10_basic.yaml create mode 100644 test-framework/src/test/resources/rest-api-spec/test/suite2/15_test2.yaml diff --git a/core/build.gradle b/core/build.gradle index 733f4286086..3bc0168e077 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -89,20 +89,10 @@ dependencies { compile 'net.java.dev.jna:jna:4.1.0', optional - // TODO: remove these test deps and just depend on test-framework - testCompile(group: 'junit', name: 'junit', version: '4.11') { - transitive = false + testCompile("org.elasticsearch:test-framework:${version}") { + // tests use the locally compiled version of core + exclude group: 'org.elasticsearch', module: 'elasticsearch' } - testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" - - testCompile("org.apache.lucene:lucene-test-framework:${versions.lucene}") { - exclude group: 'com.carrotsearch.randomizedtesting', module: 'junit4-ant' - } - testCompile(group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3') { - exclude group: 'org.hamcrest', module: 'hamcrest-core' - } - testCompile 'com.google.jimfs:jimfs:1.0' - testCompile "org.apache.httpcomponents:httpclient:${versions.httpclient}" } compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-fallthrough,-overrides,-rawtypes,-serial,-try,-unchecked" @@ -129,5 +119,4 @@ integTest.mustRunAfter test RestSpecHack.configureDependencies(project) Task copyRestSpec = RestSpecHack.configureTask(project, true) integTest.dependsOn copyRestSpec -test.dependsOn copyRestSpec diff --git a/test-framework/build.gradle b/test-framework/build.gradle index 2174e934c1a..b4f4411d27b 100644 --- a/test-framework/build.gradle +++ b/test-framework/build.gradle @@ -1,69 +1,48 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you 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. + */ +import org.elasticsearch.gradle.precommit.PrecommitTasks -apply plugin: 'java' +apply plugin: 'elasticsearch.build' apply plugin: 'com.bmuschko.nexus' dependencies { - // TODO: change to elasticsearch core jar dep, and use dependnecy subs to point at core project compile "org.elasticsearch:elasticsearch:${version}" - + compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" compile(group: 'junit', name: 'junit', version: '4.11') { exclude group: 'org.hamcrest', module: 'hamcrest-core' } - compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" - compile("org.apache.lucene:lucene-test-framework:${versions.lucene}") { exclude group: 'com.carrotsearch.randomizedtesting', module: 'junit4-ant' } - compile(group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3') { + compile('org.hamcrest:hamcrest-all:1.3') { exclude group: 'org.hamcrest', module: 'hamcrest-core' } - compile "com.google.jimfs:jimfs:1.0" + compile 'com.google.jimfs:jimfs:1.0' compile "org.apache.httpcomponents:httpclient:${versions.httpclient}" } -// HACK: this is temporary until we have moved to gradle, at which -// point we can physically move the test framework files to this project -project.ext { - srcDir = new File(project.buildDir, 'src') - coreDir = new File(project("${projectsPrefix}:core").projectDir, 'src' + File.separator + 'test') -} -sourceSets.main.java.srcDir(new File(srcDir, "java")) -sourceSets.main.resources.srcDir(new File(srcDir, "resources")) -task copySourceFiles(type: Sync) { - from(coreDir) { - include 'resources/log4j.properties' - include 'java/org/elasticsearch/test/**' - include 'java/org/elasticsearch/bootstrap/BootstrapForTesting.java' - include 'java/org/elasticsearch/bootstrap/MockPluginPolicy.java' - include 'java/org/elasticsearch/common/cli/CliToolTestCase.java' - include 'java/org/elasticsearch/cluster/MockInternalClusterInfoService.java' - include 'java/org/elasticsearch/cluster/routing/TestShardRouting.java' - include 'java/org/elasticsearch/index/MockEngineFactoryPlugin.java' - include 'java/org/elasticsearch/search/MockSearchService.java' - include 'java/org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.java' - include 'java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.java' - include 'java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.java' - include 'java/org/elasticsearch/search/aggregations/bucket/script/TestScript.java' - include 'java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java' - include 'java/org/elasticsearch/percolator/PercolatorTestUtil.java' - include 'java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java' - include 'java/org/elasticsearch/common/util/MockBigArrays.java' - include 'java/org/elasticsearch/node/NodeMocksPlugin.java' - include 'java/org/elasticsearch/node/MockNode.java' - include 'java/org/elasticsearch/common/io/PathUtilsForTesting.java' - // unit tests for yaml suite parser & rest spec parser need to be excluded - exclude 'java/org/elasticsearch/test/rest/test/**' - // unit tests for test framework classes - exclude 'java/org/elasticsearch/test/test/**' +compileJava.options.compilerArgs << '-Xlint:-cast,-deprecation,-fallthrough,-overrides,-rawtypes,-serial,-try,-unchecked' +compileTestJava.options.compilerArgs << '-Xlint:-rawtypes' - // no geo (requires optional deps) - exclude 'java/org/elasticsearch/test/hamcrest/ElasticsearchGeoAssertions.java' - exclude 'java/org/elasticsearch/test/geo/RandomShapeGenerator.java' - // this mock is just for a single logging test - exclude 'java/org/elasticsearch/test/MockLogAppender.java' - } - into srcDir +// the main files are actually test files, so use the appopriate forbidden api sigs +forbiddenApisMain { + bundledSignatures = ['jdk-unsafe', 'jdk-deprecated'] + signaturesURLs = [PrecommitTasks.getResource('/forbidden/all-signatures.txt'), + PrecommitTasks.getResource('/forbidden/test-signatures.txt')] } -compileJava.dependsOn copySourceFiles - -compileJava.options.compilerArgs << "-Xlint:-cast,-deprecation,-fallthrough,-overrides,-rawtypes,-serial,-try,-unchecked" diff --git a/core/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/test-framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java similarity index 100% rename from core/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java rename to test-framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java diff --git a/core/src/test/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java b/test-framework/src/main/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java similarity index 100% rename from core/src/test/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java rename to test-framework/src/main/java/org/elasticsearch/cache/recycler/MockPageCacheRecycler.java diff --git a/core/src/test/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java b/test-framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java similarity index 100% rename from core/src/test/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java rename to test-framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/TestShardRouting.java b/test-framework/src/main/java/org/elasticsearch/cluster/routing/TestShardRouting.java similarity index 100% rename from core/src/test/java/org/elasticsearch/cluster/routing/TestShardRouting.java rename to test-framework/src/main/java/org/elasticsearch/cluster/routing/TestShardRouting.java diff --git a/core/src/test/java/org/elasticsearch/common/cli/CliToolTestCase.java b/test-framework/src/main/java/org/elasticsearch/common/cli/CliToolTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/common/cli/CliToolTestCase.java rename to test-framework/src/main/java/org/elasticsearch/common/cli/CliToolTestCase.java diff --git a/core/src/test/java/org/elasticsearch/common/io/PathUtilsForTesting.java b/test-framework/src/main/java/org/elasticsearch/common/io/PathUtilsForTesting.java similarity index 100% rename from core/src/test/java/org/elasticsearch/common/io/PathUtilsForTesting.java rename to test-framework/src/main/java/org/elasticsearch/common/io/PathUtilsForTesting.java diff --git a/core/src/test/java/org/elasticsearch/common/util/MockBigArrays.java b/test-framework/src/main/java/org/elasticsearch/common/util/MockBigArrays.java similarity index 100% rename from core/src/test/java/org/elasticsearch/common/util/MockBigArrays.java rename to test-framework/src/main/java/org/elasticsearch/common/util/MockBigArrays.java diff --git a/core/src/test/java/org/elasticsearch/index/MockEngineFactoryPlugin.java b/test-framework/src/main/java/org/elasticsearch/index/MockEngineFactoryPlugin.java similarity index 100% rename from core/src/test/java/org/elasticsearch/index/MockEngineFactoryPlugin.java rename to test-framework/src/main/java/org/elasticsearch/index/MockEngineFactoryPlugin.java diff --git a/core/src/test/java/org/elasticsearch/node/MockNode.java b/test-framework/src/main/java/org/elasticsearch/node/MockNode.java similarity index 100% rename from core/src/test/java/org/elasticsearch/node/MockNode.java rename to test-framework/src/main/java/org/elasticsearch/node/MockNode.java diff --git a/core/src/test/java/org/elasticsearch/node/NodeMocksPlugin.java b/test-framework/src/main/java/org/elasticsearch/node/NodeMocksPlugin.java similarity index 100% rename from core/src/test/java/org/elasticsearch/node/NodeMocksPlugin.java rename to test-framework/src/main/java/org/elasticsearch/node/NodeMocksPlugin.java diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorTestUtil.java b/test-framework/src/main/java/org/elasticsearch/percolator/PercolatorTestUtil.java similarity index 100% rename from core/src/test/java/org/elasticsearch/percolator/PercolatorTestUtil.java rename to test-framework/src/main/java/org/elasticsearch/percolator/PercolatorTestUtil.java diff --git a/core/src/test/java/org/elasticsearch/search/MockSearchService.java b/test-framework/src/main/java/org/elasticsearch/search/MockSearchService.java similarity index 100% rename from core/src/test/java/org/elasticsearch/search/MockSearchService.java rename to test-framework/src/main/java/org/elasticsearch/search/MockSearchService.java diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.java b/test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.java rename to test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.java diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.java b/test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.java similarity index 100% rename from core/src/test/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.java rename to test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.java diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.java b/test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.java similarity index 100% rename from core/src/test/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.java rename to test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.java diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/script/TestScript.java b/test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/script/TestScript.java similarity index 100% rename from core/src/test/java/org/elasticsearch/search/aggregations/bucket/script/TestScript.java rename to test-framework/src/main/java/org/elasticsearch/search/aggregations/bucket/script/TestScript.java diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java b/test-framework/src/main/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java rename to test-framework/src/main/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/BackgroundIndexer.java b/test-framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/BackgroundIndexer.java rename to test-framework/src/main/java/org/elasticsearch/test/BackgroundIndexer.java diff --git a/core/src/test/java/org/elasticsearch/test/CompositeTestCluster.java b/test-framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/CompositeTestCluster.java rename to test-framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java diff --git a/core/src/test/java/org/elasticsearch/test/CorruptionUtils.java b/test-framework/src/main/java/org/elasticsearch/test/CorruptionUtils.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/CorruptionUtils.java rename to test-framework/src/main/java/org/elasticsearch/test/CorruptionUtils.java diff --git a/core/src/test/java/org/elasticsearch/test/DummyShardLock.java b/test-framework/src/main/java/org/elasticsearch/test/DummyShardLock.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/DummyShardLock.java rename to test-framework/src/main/java/org/elasticsearch/test/DummyShardLock.java diff --git a/core/src/test/java/org/elasticsearch/test/ESAllocationTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESAllocationTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ESAllocationTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/ESAllocationTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/ESBackcompatTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ESBackcompatTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/ESBackcompatTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ESIntegTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ESSingleNodeTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/ESTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ESTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/ESTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/ESTokenStreamTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/ESTokenStreamTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ESTokenStreamTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/ESTokenStreamTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/ExternalNode.java b/test-framework/src/main/java/org/elasticsearch/test/ExternalNode.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ExternalNode.java rename to test-framework/src/main/java/org/elasticsearch/test/ExternalNode.java diff --git a/core/src/test/java/org/elasticsearch/test/ExternalTestCluster.java b/test-framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/ExternalTestCluster.java rename to test-framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java diff --git a/core/src/test/java/org/elasticsearch/test/IndexSettingsModule.java b/test-framework/src/main/java/org/elasticsearch/test/IndexSettingsModule.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/IndexSettingsModule.java rename to test-framework/src/main/java/org/elasticsearch/test/IndexSettingsModule.java diff --git a/core/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/test-framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/InternalTestCluster.java rename to test-framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java diff --git a/core/src/test/java/org/elasticsearch/test/MockIndexEventListener.java b/test-framework/src/main/java/org/elasticsearch/test/MockIndexEventListener.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/MockIndexEventListener.java rename to test-framework/src/main/java/org/elasticsearch/test/MockIndexEventListener.java diff --git a/core/src/test/java/org/elasticsearch/test/NodeConfigurationSource.java b/test-framework/src/main/java/org/elasticsearch/test/NodeConfigurationSource.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/NodeConfigurationSource.java rename to test-framework/src/main/java/org/elasticsearch/test/NodeConfigurationSource.java diff --git a/core/src/test/java/org/elasticsearch/test/StreamsUtils.java b/test-framework/src/main/java/org/elasticsearch/test/StreamsUtils.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/StreamsUtils.java rename to test-framework/src/main/java/org/elasticsearch/test/StreamsUtils.java diff --git a/core/src/test/java/org/elasticsearch/test/TestCluster.java b/test-framework/src/main/java/org/elasticsearch/test/TestCluster.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/TestCluster.java rename to test-framework/src/main/java/org/elasticsearch/test/TestCluster.java diff --git a/core/src/test/java/org/elasticsearch/test/TestSearchContext.java b/test-framework/src/main/java/org/elasticsearch/test/TestSearchContext.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/TestSearchContext.java rename to test-framework/src/main/java/org/elasticsearch/test/TestSearchContext.java diff --git a/core/src/test/java/org/elasticsearch/test/VersionUtils.java b/test-framework/src/main/java/org/elasticsearch/test/VersionUtils.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/VersionUtils.java rename to test-framework/src/main/java/org/elasticsearch/test/VersionUtils.java diff --git a/core/src/test/java/org/elasticsearch/test/XContentTestUtils.java b/test-framework/src/main/java/org/elasticsearch/test/XContentTestUtils.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/XContentTestUtils.java rename to test-framework/src/main/java/org/elasticsearch/test/XContentTestUtils.java diff --git a/core/src/test/java/org/elasticsearch/test/client/RandomizingClient.java b/test-framework/src/main/java/org/elasticsearch/test/client/RandomizingClient.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/client/RandomizingClient.java rename to test-framework/src/main/java/org/elasticsearch/test/client/RandomizingClient.java diff --git a/core/src/test/java/org/elasticsearch/test/cluster/NoopClusterService.java b/test-framework/src/main/java/org/elasticsearch/test/cluster/NoopClusterService.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/cluster/NoopClusterService.java rename to test-framework/src/main/java/org/elasticsearch/test/cluster/NoopClusterService.java diff --git a/core/src/test/java/org/elasticsearch/test/cluster/TestClusterService.java b/test-framework/src/main/java/org/elasticsearch/test/cluster/TestClusterService.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/cluster/TestClusterService.java rename to test-framework/src/main/java/org/elasticsearch/test/cluster/TestClusterService.java diff --git a/core/src/test/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java b/test-framework/src/main/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java rename to test-framework/src/main/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/BlockClusterStateProcessing.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/BlockClusterStateProcessing.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/BlockClusterStateProcessing.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/BlockClusterStateProcessing.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/IntermittentLongGCDisruption.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/IntermittentLongGCDisruption.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/IntermittentLongGCDisruption.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/IntermittentLongGCDisruption.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/LongGCDisruption.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/LongGCDisruption.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/LongGCDisruption.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/LongGCDisruption.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NetworkDelaysPartition.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkDelaysPartition.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/NetworkDelaysPartition.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkDelaysPartition.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NetworkDisconnectPartition.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisconnectPartition.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/NetworkDisconnectPartition.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkDisconnectPartition.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NetworkPartition.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartition.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/NetworkPartition.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartition.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkPartitionIT.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NetworkUnresponsivePartition.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkUnresponsivePartition.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/NetworkUnresponsivePartition.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/NetworkUnresponsivePartition.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/NoOpDisruptionScheme.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/NoOpDisruptionScheme.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/NoOpDisruptionScheme.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/NoOpDisruptionScheme.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/ServiceDisruptionScheme.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/ServiceDisruptionScheme.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/ServiceDisruptionScheme.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/ServiceDisruptionScheme.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/SingleNodeDisruption.java diff --git a/core/src/test/java/org/elasticsearch/test/disruption/SlowClusterStateProcessing.java b/test-framework/src/main/java/org/elasticsearch/test/disruption/SlowClusterStateProcessing.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/disruption/SlowClusterStateProcessing.java rename to test-framework/src/main/java/org/elasticsearch/test/disruption/SlowClusterStateProcessing.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/AssertingSearcher.java b/test-framework/src/main/java/org/elasticsearch/test/engine/AssertingSearcher.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/AssertingSearcher.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/AssertingSearcher.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/MockEngineFactory.java b/test-framework/src/main/java/org/elasticsearch/test/engine/MockEngineFactory.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/MockEngineFactory.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/MockEngineFactory.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/MockEngineSupport.java b/test-framework/src/main/java/org/elasticsearch/test/engine/MockEngineSupport.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/MockEngineSupport.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/MockEngineSupport.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/MockEngineSupportModule.java b/test-framework/src/main/java/org/elasticsearch/test/engine/MockEngineSupportModule.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/MockEngineSupportModule.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/MockEngineSupportModule.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/MockInternalEngine.java b/test-framework/src/main/java/org/elasticsearch/test/engine/MockInternalEngine.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/MockInternalEngine.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/MockInternalEngine.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/MockShadowEngine.java b/test-framework/src/main/java/org/elasticsearch/test/engine/MockShadowEngine.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/MockShadowEngine.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/MockShadowEngine.java diff --git a/core/src/test/java/org/elasticsearch/test/engine/ThrowingLeafReaderWrapper.java b/test-framework/src/main/java/org/elasticsearch/test/engine/ThrowingLeafReaderWrapper.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/engine/ThrowingLeafReaderWrapper.java rename to test-framework/src/main/java/org/elasticsearch/test/engine/ThrowingLeafReaderWrapper.java diff --git a/core/src/test/java/org/elasticsearch/test/gateway/NoopGatewayAllocator.java b/test-framework/src/main/java/org/elasticsearch/test/gateway/NoopGatewayAllocator.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/gateway/NoopGatewayAllocator.java rename to test-framework/src/main/java/org/elasticsearch/test/gateway/NoopGatewayAllocator.java diff --git a/core/src/test/java/org/elasticsearch/test/hamcrest/CollectionAssertions.java b/test-framework/src/main/java/org/elasticsearch/test/hamcrest/CollectionAssertions.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/hamcrest/CollectionAssertions.java rename to test-framework/src/main/java/org/elasticsearch/test/hamcrest/CollectionAssertions.java diff --git a/core/src/test/java/org/elasticsearch/test/hamcrest/CollectionMatchers.java b/test-framework/src/main/java/org/elasticsearch/test/hamcrest/CollectionMatchers.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/hamcrest/CollectionMatchers.java rename to test-framework/src/main/java/org/elasticsearch/test/hamcrest/CollectionMatchers.java diff --git a/core/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/test-framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java rename to test-framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java diff --git a/core/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java b/test-framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java rename to test-framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchMatchers.java diff --git a/core/src/test/java/org/elasticsearch/test/hamcrest/RegexMatcher.java b/test-framework/src/main/java/org/elasticsearch/test/hamcrest/RegexMatcher.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/hamcrest/RegexMatcher.java rename to test-framework/src/main/java/org/elasticsearch/test/hamcrest/RegexMatcher.java diff --git a/core/src/test/java/org/elasticsearch/test/junit/annotations/Network.java b/test-framework/src/main/java/org/elasticsearch/test/junit/annotations/Network.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/junit/annotations/Network.java rename to test-framework/src/main/java/org/elasticsearch/test/junit/annotations/Network.java diff --git a/core/src/test/java/org/elasticsearch/test/junit/annotations/TestLogging.java b/test-framework/src/main/java/org/elasticsearch/test/junit/annotations/TestLogging.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/junit/annotations/TestLogging.java rename to test-framework/src/main/java/org/elasticsearch/test/junit/annotations/TestLogging.java diff --git a/core/src/test/java/org/elasticsearch/test/junit/listeners/LoggingListener.java b/test-framework/src/main/java/org/elasticsearch/test/junit/listeners/LoggingListener.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/junit/listeners/LoggingListener.java rename to test-framework/src/main/java/org/elasticsearch/test/junit/listeners/LoggingListener.java diff --git a/core/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/test-framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java rename to test-framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java diff --git a/core/src/test/java/org/elasticsearch/test/junit/rule/RepeatOnExceptionRule.java b/test-framework/src/main/java/org/elasticsearch/test/junit/rule/RepeatOnExceptionRule.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/junit/rule/RepeatOnExceptionRule.java rename to test-framework/src/main/java/org/elasticsearch/test/junit/rule/RepeatOnExceptionRule.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test-framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/ESRestTestCase.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/FakeRestRequest.java b/test-framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/FakeRestRequest.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/FakeRestRequest.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest0IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest0IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest0IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest0IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest1IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest1IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest1IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest1IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest2IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest2IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest2IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest2IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest3IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest3IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest3IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest3IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest4IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest4IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest4IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest4IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest5IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest5IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest5IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest5IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest6IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest6IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest6IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest6IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Rest7IT.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Rest7IT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Rest7IT.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Rest7IT.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/RestTestCandidate.java b/test-framework/src/main/java/org/elasticsearch/test/rest/RestTestCandidate.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/RestTestCandidate.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/RestTestCandidate.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/RestTestExecutionContext.java b/test-framework/src/main/java/org/elasticsearch/test/rest/RestTestExecutionContext.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/RestTestExecutionContext.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/RestTestExecutionContext.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/Stash.java b/test-framework/src/main/java/org/elasticsearch/test/rest/Stash.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/Stash.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/Stash.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/RestClient.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/RestClient.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/RestClient.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/RestClient.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/RestException.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/RestException.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/RestException.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/RestException.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/RestPath.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/RestPath.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/RestPath.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/RestPath.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/RestResponse.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/RestResponse.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/RestResponse.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/RestResponse.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/http/HttpDeleteWithEntity.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpDeleteWithEntity.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/http/HttpDeleteWithEntity.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpDeleteWithEntity.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/http/HttpGetWithEntity.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpGetWithEntity.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/http/HttpGetWithEntity.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpGetWithEntity.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/http/HttpRequestBuilder.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpRequestBuilder.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/http/HttpRequestBuilder.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpRequestBuilder.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/client/http/HttpResponse.java b/test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpResponse.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/client/http/HttpResponse.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/client/http/HttpResponse.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/json/JsonPath.java b/test-framework/src/main/java/org/elasticsearch/test/rest/json/JsonPath.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/json/JsonPath.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/json/JsonPath.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/DoSectionParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/DoSectionParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/DoSectionParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/DoSectionParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/GreaterThanEqualToParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/GreaterThanEqualToParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/GreaterThanEqualToParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/GreaterThanEqualToParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/GreaterThanParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/GreaterThanParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/GreaterThanParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/GreaterThanParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/IsFalseParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/IsFalseParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/IsFalseParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/IsFalseParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/IsTrueParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/IsTrueParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/IsTrueParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/IsTrueParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/LengthParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/LengthParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/LengthParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/LengthParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/LessThanOrEqualToParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/LessThanOrEqualToParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/LessThanOrEqualToParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/LessThanOrEqualToParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/LessThanParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/LessThanParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/LessThanParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/LessThanParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/MatchParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/MatchParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/MatchParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/MatchParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/RestTestFragmentParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestFragmentParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/RestTestFragmentParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestFragmentParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/RestTestParseException.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestParseException.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/RestTestParseException.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestParseException.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/RestTestSectionParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestSectionParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/RestTestSectionParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestSectionParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/RestTestSuiteParseContext.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestSuiteParseContext.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/RestTestSuiteParseContext.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestSuiteParseContext.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/RestTestSuiteParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestSuiteParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/RestTestSuiteParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/RestTestSuiteParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/SetSectionParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/SetSectionParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/SetSectionParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/SetSectionParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/SetupSectionParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/SetupSectionParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/SetupSectionParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/SetupSectionParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/parser/SkipSectionParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/ApiCallSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/ApiCallSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/ApiCallSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/ApiCallSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/Assertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/Assertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/Assertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/Assertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/DoSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/DoSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/DoSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/DoSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/ExecutableSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/ExecutableSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/ExecutableSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/ExecutableSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/GreaterThanAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/GreaterThanAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/GreaterThanAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/GreaterThanAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/GreaterThanEqualToAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/GreaterThanEqualToAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/GreaterThanEqualToAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/GreaterThanEqualToAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/IsFalseAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/IsFalseAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/IsFalseAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/IsFalseAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/IsTrueAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/IsTrueAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/IsTrueAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/IsTrueAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/LengthAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/LengthAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/LengthAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/LengthAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/LessThanAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/LessThanAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/LessThanAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/LessThanAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/LessThanOrEqualToAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/LessThanOrEqualToAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/LessThanOrEqualToAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/LessThanOrEqualToAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/MatchAssertion.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/MatchAssertion.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/MatchAssertion.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/MatchAssertion.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/RestTestSuite.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/RestTestSuite.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/RestTestSuite.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/RestTestSuite.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/SetSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/SetSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/SetSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/SetSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/SetupSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/SetupSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/SetupSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/SetupSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/SkipSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/SkipSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/SkipSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/section/TestSection.java b/test-framework/src/main/java/org/elasticsearch/test/rest/section/TestSection.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/section/TestSection.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/section/TestSection.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/spec/RestApi.java b/test-framework/src/main/java/org/elasticsearch/test/rest/spec/RestApi.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/spec/RestApi.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/spec/RestApi.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/spec/RestApiParser.java b/test-framework/src/main/java/org/elasticsearch/test/rest/spec/RestApiParser.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/spec/RestApiParser.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/spec/RestApiParser.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/spec/RestSpec.java b/test-framework/src/main/java/org/elasticsearch/test/rest/spec/RestSpec.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/spec/RestSpec.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/spec/RestSpec.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/support/Features.java b/test-framework/src/main/java/org/elasticsearch/test/rest/support/Features.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/support/Features.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/support/Features.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/support/FileUtils.java b/test-framework/src/main/java/org/elasticsearch/test/rest/support/FileUtils.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/support/FileUtils.java rename to test-framework/src/main/java/org/elasticsearch/test/rest/support/FileUtils.java diff --git a/core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java b/test-framework/src/main/java/org/elasticsearch/test/store/MockFSDirectoryService.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java rename to test-framework/src/main/java/org/elasticsearch/test/store/MockFSDirectoryService.java diff --git a/core/src/test/java/org/elasticsearch/test/store/MockFSIndexStore.java b/test-framework/src/main/java/org/elasticsearch/test/store/MockFSIndexStore.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/store/MockFSIndexStore.java rename to test-framework/src/main/java/org/elasticsearch/test/store/MockFSIndexStore.java diff --git a/core/src/test/java/org/elasticsearch/test/transport/AssertingLocalTransport.java b/test-framework/src/main/java/org/elasticsearch/test/transport/AssertingLocalTransport.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/transport/AssertingLocalTransport.java rename to test-framework/src/main/java/org/elasticsearch/test/transport/AssertingLocalTransport.java diff --git a/core/src/test/java/org/elasticsearch/test/transport/CapturingTransport.java b/test-framework/src/main/java/org/elasticsearch/test/transport/CapturingTransport.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/transport/CapturingTransport.java rename to test-framework/src/main/java/org/elasticsearch/test/transport/CapturingTransport.java diff --git a/core/src/test/java/org/elasticsearch/test/transport/MockTransportService.java b/test-framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/transport/MockTransportService.java rename to test-framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java diff --git a/core/src/test/resources/log4j.properties b/test-framework/src/main/resources/log4j.properties similarity index 100% rename from core/src/test/resources/log4j.properties rename to test-framework/src/main/resources/log4j.properties diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/AbstractParserTestCase.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/AbstractParserTestCase.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/AbstractParserTestCase.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/AbstractParserTestCase.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/AssertionParsersTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/DoSectionParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java similarity index 77% rename from core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java index b0df110f0a8..128cb862e57 100644 --- a/core/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java +++ b/test-framework/src/test/java/org/elasticsearch/test/rest/test/FileUtilsTests.java @@ -32,44 +32,44 @@ import static org.hamcrest.Matchers.greaterThan; public class FileUtilsTests extends ESTestCase { public void testLoadSingleYamlSuite() throws Exception { - Map> yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "/rest-api-spec/test/get/10_basic"); - assertSingleFile(yamlSuites, "get", "10_basic.yaml"); + Map> yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "/rest-api-spec/test/suite1/10_basic"); + assertSingleFile(yamlSuites, "suite1", "10_basic.yaml"); //the path prefix is optional - yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "get/10_basic.yaml"); - assertSingleFile(yamlSuites, "get", "10_basic.yaml"); + yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "suite1/10_basic.yaml"); + assertSingleFile(yamlSuites, "suite1", "10_basic.yaml"); //extension .yaml is optional - yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "get/10_basic"); - assertSingleFile(yamlSuites, "get", "10_basic.yaml"); + yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "suite1/10_basic"); + assertSingleFile(yamlSuites, "suite1", "10_basic.yaml"); } public void testLoadMultipleYamlSuites() throws Exception { //single directory - Map> yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "get"); + Map> yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "suite1"); assertThat(yamlSuites, notNullValue()); assertThat(yamlSuites.size(), equalTo(1)); - assertThat(yamlSuites.containsKey("get"), equalTo(true)); - assertThat(yamlSuites.get("get").size(), greaterThan(1)); + assertThat(yamlSuites.containsKey("suite1"), equalTo(true)); + assertThat(yamlSuites.get("suite1").size(), greaterThan(1)); //multiple directories - yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "get", "index"); + yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "suite1", "suite2"); assertThat(yamlSuites, notNullValue()); assertThat(yamlSuites.size(), equalTo(2)); - assertThat(yamlSuites.containsKey("get"), equalTo(true)); - assertThat(yamlSuites.get("get").size(), greaterThan(1)); - assertThat(yamlSuites.containsKey("index"), equalTo(true)); - assertThat(yamlSuites.get("index").size(), greaterThan(1)); + assertThat(yamlSuites.containsKey("suite1"), equalTo(true)); + assertEquals(2, yamlSuites.get("suite1").size()); + assertThat(yamlSuites.containsKey("suite2"), equalTo(true)); + assertEquals(2, yamlSuites.get("suite2").size()); //multiple paths, which can be both directories or yaml test suites (with optional file extension) - yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "indices.forcemerge/10_basic", "index"); + yamlSuites = FileUtils.findYamlSuites(null, "/rest-api-spec/test", "suite2/10_basic", "suite1"); assertThat(yamlSuites, notNullValue()); assertThat(yamlSuites.size(), equalTo(2)); - assertThat(yamlSuites.containsKey("indices.forcemerge"), equalTo(true)); - assertThat(yamlSuites.get("indices.forcemerge").size(), equalTo(1)); - assertSingleFile(yamlSuites.get("indices.forcemerge"), "indices.forcemerge", "10_basic.yaml"); - assertThat(yamlSuites.containsKey("index"), equalTo(true)); - assertThat(yamlSuites.get("index").size(), greaterThan(1)); + assertThat(yamlSuites.containsKey("suite2"), equalTo(true)); + assertThat(yamlSuites.get("suite2").size(), equalTo(1)); + assertSingleFile(yamlSuites.get("suite2"), "suite2", "10_basic.yaml"); + assertThat(yamlSuites.containsKey("suite1"), equalTo(true)); + assertThat(yamlSuites.get("suite1").size(), greaterThan(1)); //files can be loaded from classpath and from file system too Path dir = createTempDir(); diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/JsonPathTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/RestApiParserFailingTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/RestApiParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/RestTestParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/SetSectionParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/SetupSectionParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/SkipSectionParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java b/test-framework/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java rename to test-framework/src/test/java/org/elasticsearch/test/rest/test/TestSectionParserTests.java diff --git a/core/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test-framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java rename to test-framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java diff --git a/core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java b/test-framework/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java rename to test-framework/src/test/java/org/elasticsearch/test/test/LoggingListenerTests.java diff --git a/core/src/test/java/org/elasticsearch/test/test/SuiteScopeClusterIT.java b/test-framework/src/test/java/org/elasticsearch/test/test/SuiteScopeClusterIT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/test/SuiteScopeClusterIT.java rename to test-framework/src/test/java/org/elasticsearch/test/test/SuiteScopeClusterIT.java diff --git a/core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java b/test-framework/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java rename to test-framework/src/test/java/org/elasticsearch/test/test/TestScopeClusterIT.java diff --git a/core/src/test/java/org/elasticsearch/test/test/VersionUtilsTests.java b/test-framework/src/test/java/org/elasticsearch/test/test/VersionUtilsTests.java similarity index 100% rename from core/src/test/java/org/elasticsearch/test/test/VersionUtilsTests.java rename to test-framework/src/test/java/org/elasticsearch/test/test/VersionUtilsTests.java diff --git a/test-framework/src/test/resources/rest-api-spec/test/suite1/10_basic.yaml b/test-framework/src/test/resources/rest-api-spec/test/suite1/10_basic.yaml new file mode 100644 index 00000000000..0689f714d64 --- /dev/null +++ b/test-framework/src/test/resources/rest-api-spec/test/suite1/10_basic.yaml @@ -0,0 +1,31 @@ +--- +"Basic": + + - do: + index: + index: test_1 + type: test + id: 中文 + body: { "foo": "Hello: 中文" } + + - do: + get: + index: test_1 + type: test + id: 中文 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: 中文 } + - match: { _source: { foo: "Hello: 中文" } } + + - do: + get: + index: test_1 + type: _all + id: 中文 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: 中文 } + - match: { _source: { foo: "Hello: 中文" } } diff --git a/test-framework/src/test/resources/rest-api-spec/test/suite1/20_another_test.yaml b/test-framework/src/test/resources/rest-api-spec/test/suite1/20_another_test.yaml new file mode 100644 index 00000000000..5e08112253e --- /dev/null +++ b/test-framework/src/test/resources/rest-api-spec/test/suite1/20_another_test.yaml @@ -0,0 +1,21 @@ +--- +"Default values": + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "foo": "bar" } + + - do: + get: + index: test_1 + type: _all + id: 1 + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: '1' } + - match: { _source: { foo: "bar" } } + diff --git a/test-framework/src/test/resources/rest-api-spec/test/suite2/10_basic.yaml b/test-framework/src/test/resources/rest-api-spec/test/suite2/10_basic.yaml new file mode 100644 index 00000000000..745e1117402 --- /dev/null +++ b/test-framework/src/test/resources/rest-api-spec/test/suite2/10_basic.yaml @@ -0,0 +1,26 @@ +--- +"Index with ID": + + - do: + index: + index: test-weird-index-中文 + type: weird.type + id: 1 + body: { foo: bar } + + - match: { _index: test-weird-index-中文 } + - match: { _type: weird.type } + - match: { _id: "1"} + - match: { _version: 1} + + - do: + get: + index: test-weird-index-中文 + type: weird.type + id: 1 + + - match: { _index: test-weird-index-中文 } + - match: { _type: weird.type } + - match: { _id: "1"} + - match: { _version: 1} + - match: { _source: { foo: bar }} diff --git a/test-framework/src/test/resources/rest-api-spec/test/suite2/15_test2.yaml b/test-framework/src/test/resources/rest-api-spec/test/suite2/15_test2.yaml new file mode 100644 index 00000000000..3fff0512b96 --- /dev/null +++ b/test-framework/src/test/resources/rest-api-spec/test/suite2/15_test2.yaml @@ -0,0 +1,26 @@ +--- +"Index without ID": + + - do: + index: + index: test_1 + type: test + body: { foo: bar } + + - is_true: _id + - match: { _index: test_1 } + - match: { _type: test } + - match: { _version: 1 } + - set: { _id: id } + + - do: + get: + index: test_1 + type: test + id: '$id' + + - match: { _index: test_1 } + - match: { _type: test } + - match: { _id: $id } + - match: { _version: 1 } + - match: { _source: { foo: bar }} From 542522531a7bd34d6a7e91df0162bbb8afd9e233 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Thu, 29 Oct 2015 23:52:27 -0700 Subject: [PATCH 12/37] Build: Remove maven pom files and supporting ant files This change removes the leftover pom files. A couple files were left for reference, namely in qa tests that have not yet been migrated (vagrant and multinode). The deb and rpm assemblies also still exist for reference when finishing their setup in gradle. See #13930 --- core/pom.xml | 368 ---- dev-tools/pom.xml | 68 - .../main/resources/ant/integration-tests.xml | 406 ----- .../plugin-metadata/plugin-assembly.xml | 33 - distribution/deb/pom.xml | 332 ---- distribution/pom.xml | 255 --- distribution/rpm/pom.xml | 402 ----- .../src/main/assemblies/common-bin.xml | 71 - distribution/tar/pom.xml | 86 - distribution/zip/pom.xml | 103 -- plugins/analysis-icu/pom.xml | 57 - plugins/analysis-kuromoji/pom.xml | 39 - plugins/analysis-phonetic/pom.xml | 40 - plugins/analysis-smartcn/pom.xml | 39 - plugins/analysis-stempel/pom.xml | 39 - plugins/delete-by-query/pom.xml | 44 - plugins/discovery-azure/pom.xml | 73 - plugins/discovery-ec2/pom.xml | 50 - plugins/discovery-gce/pom.xml | 67 - plugins/discovery-multicast/pom.xml | 34 - plugins/jvm-example/pom.xml | 41 - .../src/main/assemblies/plugin.xml | 33 - plugins/lang-expression/pom.xml | 41 - plugins/lang-groovy/pom.xml | 42 - plugins/lang-javascript/pom.xml | 41 - plugins/lang-python/pom.xml | 42 - plugins/mapper-murmur3/pom.xml | 44 - plugins/mapper-size/pom.xml | 43 - plugins/pom.xml | 437 ----- plugins/repository-azure/pom.xml | 54 - plugins/repository-s3/pom.xml | 50 - plugins/site-example/pom.xml | 48 - .../src/main/assemblies/plugin-assembly.xml | 23 - plugins/store-smb/pom.xml | 47 - pom.xml | 1505 ----------------- qa/pom.xml | 131 -- qa/smoke-test-client/pom.xml | 129 -- qa/smoke-test-plugins/integration-tests.xml | 27 - qa/smoke-test-plugins/pom.xml | 478 ------ rest-api-spec/pom.xml | 68 - 40 files changed, 5930 deletions(-) delete mode 100644 core/pom.xml delete mode 100644 dev-tools/pom.xml delete mode 100644 dev-tools/src/main/resources/ant/integration-tests.xml delete mode 100644 dev-tools/src/main/resources/plugin-metadata/plugin-assembly.xml delete mode 100644 distribution/deb/pom.xml delete mode 100644 distribution/pom.xml delete mode 100644 distribution/rpm/pom.xml delete mode 100644 distribution/src/main/assemblies/common-bin.xml delete mode 100644 distribution/tar/pom.xml delete mode 100644 distribution/zip/pom.xml delete mode 100644 plugins/analysis-icu/pom.xml delete mode 100644 plugins/analysis-kuromoji/pom.xml delete mode 100644 plugins/analysis-phonetic/pom.xml delete mode 100644 plugins/analysis-smartcn/pom.xml delete mode 100644 plugins/analysis-stempel/pom.xml delete mode 100644 plugins/delete-by-query/pom.xml delete mode 100644 plugins/discovery-azure/pom.xml delete mode 100644 plugins/discovery-ec2/pom.xml delete mode 100644 plugins/discovery-gce/pom.xml delete mode 100644 plugins/discovery-multicast/pom.xml delete mode 100644 plugins/jvm-example/pom.xml delete mode 100644 plugins/jvm-example/src/main/assemblies/plugin.xml delete mode 100644 plugins/lang-expression/pom.xml delete mode 100644 plugins/lang-groovy/pom.xml delete mode 100644 plugins/lang-javascript/pom.xml delete mode 100644 plugins/lang-python/pom.xml delete mode 100644 plugins/mapper-murmur3/pom.xml delete mode 100644 plugins/mapper-size/pom.xml delete mode 100644 plugins/pom.xml delete mode 100644 plugins/repository-azure/pom.xml delete mode 100644 plugins/repository-s3/pom.xml delete mode 100644 plugins/site-example/pom.xml delete mode 100644 plugins/site-example/src/main/assemblies/plugin-assembly.xml delete mode 100644 plugins/store-smb/pom.xml delete mode 100644 pom.xml delete mode 100644 qa/pom.xml delete mode 100644 qa/smoke-test-client/pom.xml delete mode 100644 qa/smoke-test-plugins/integration-tests.xml delete mode 100644 qa/smoke-test-plugins/pom.xml delete mode 100644 rest-api-spec/pom.xml diff --git a/core/pom.xml b/core/pom.xml deleted file mode 100644 index 26a37db5a34..00000000000 --- a/core/pom.xml +++ /dev/null @@ -1,368 +0,0 @@ - - - 4.0.0 - - org.elasticsearch - parent - 3.0.0-SNAPSHOT - - - org.elasticsearch - elasticsearch - - Elasticsearch: Core - Elasticsearch - Open Source, Distributed, RESTful Search Engine - - - -Xlint:-cast,-deprecation,-fallthrough,-overrides,-rawtypes,-serial,-try,-unchecked - - - - - org.hamcrest - hamcrest-all - test - - - com.carrotsearch.randomizedtesting - randomizedtesting-runner - test - - - org.apache.lucene - lucene-test-framework - test - - - org.apache.httpcomponents - httpclient - test - - - com.google.jimfs - jimfs - test - - - - org.apache.lucene - lucene-core - - - org.apache.lucene - lucene-backward-codecs - - - org.apache.lucene - lucene-analyzers-common - - - org.apache.lucene - lucene-queries - - - org.apache.lucene - lucene-memory - - - org.apache.lucene - lucene-highlighter - - - org.apache.lucene - lucene-queryparser - - - org.apache.lucene - lucene-suggest - - - org.apache.lucene - lucene-join - - - org.apache.lucene - lucene-spatial - - - com.spatial4j - spatial4j - true - - - com.vividsolutions - jts - true - - - - com.github.spullara.mustache.java - compiler - true - - - - - org.elasticsearch - securesm - - - com.carrotsearch - hppc - - - joda-time - joda-time - - - org.joda - joda-convert - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - - com.fasterxml.jackson.core - jackson-databind - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-cbor - - - io.netty - netty - - - com.ning - compress-lzf - - - com.tdunning - t-digest - - - org.hdrhistogram - HdrHistogram - - - commons-cli - commons-cli - - - - log4j - log4j - true - - - log4j - apache-log4j-extras - true - - - org.slf4j - slf4j-api - true - - - net.java.dev.jna - jna - true - - - - - - - - - ${project.basedir}/src/main/resources - - es-build.properties - - true - - - ${project.basedir}/src/main/resources - - **/*.* - - - - - - - ${project.basedir}/src/test/resources - - **/*.* - - - - ${elasticsearch.tools.directory}/rest-api-spec - rest-api-spec - - api/*.json - test/**/*.yaml - - - - - ${elasticsearch.tools.directory}/shared-test-resources - false - - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-test-sources - - test-jar - - - - org/elasticsearch/test/**/* - org/elasticsearch/bootstrap/BootstrapForTesting.class - org/elasticsearch/bootstrap/BootstrapForTesting$*.class - org/elasticsearch/common/cli/CliToolTestCase.class - org/elasticsearch/common/cli/CliToolTestCase$*.class - - - - org/elasticsearch/test/rest/test/**/* - - org/elasticsearch/test/test/**/* - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - prepare-package - - test-jar - - - - rest-api-spec/**/* - org/elasticsearch/test/**/* - org/elasticsearch/bootstrap/BootstrapForTesting.class - org/elasticsearch/bootstrap/BootstrapForTesting$*.class - org/elasticsearch/common/cli/CliToolTestCase.class - org/elasticsearch/common/cli/CliToolTestCase$*.class - org/elasticsearch/cluster/MockInternalClusterInfoService.class - org/elasticsearch/cluster/MockInternalClusterInfoService$*.class - org/elasticsearch/cluster/routing/TestShardRouting.class - org/elasticsearch/cluster/routing/TestShardRouting$*.class - org/elasticsearch/index/MockEngineFactoryPlugin.class - org/elasticsearch/search/MockSearchService.class - org/elasticsearch/search/MockSearchService$*.class - org/elasticsearch/search/aggregations/bucket/AbstractTermsTestCase.class - org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams.class - org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptNoParams$*.class - org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams.class - org/elasticsearch/search/aggregations/bucket/script/NativeSignificanceScoreScriptWithParams$*.class - org/elasticsearch/search/aggregations/bucket/script/TestScript.class - org/elasticsearch/search/aggregations/metrics/AbstractNumericTestCase.class - org/elasticsearch/percolator/PercolatorTestUtil.class - org/elasticsearch/cache/recycler/MockPageCacheRecycler.class - org/elasticsearch/cache/recycler/MockPageCacheRecycler$*.class - org/elasticsearch/common/util/MockBigArrays.class - org/elasticsearch/common/util/MockBigArrays$*.class - org/elasticsearch/node/NodeMocksPlugin.class - org/elasticsearch/node/MockNode.class - org/elasticsearch/common/io/PathUtilsForTesting.class - - - - org/elasticsearch/test/rest/test/**/* - - org/elasticsearch/test/test/**/* - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - check-license - none - - - - - - - - org.jacoco - jacoco-maven-plugin - - - org/apache/lucene/** - - - - - com.mycila - license-maven-plugin - - - - src/main/java/org/elasticsearch/common/inject/** - - src/main/java/org/apache/lucene/**/X*.java - - src/main/java/org/elasticsearch/http/netty/pipelining/** - - src/main/java/org/elasticsearch/common/network/InetAddresses.java - src/test/java/org/elasticsearch/common/network/InetAddressesTests.java - src/test/java/org/elasticsearch/common/collect/EvictingQueueTests.java - - src/main/java/org/joda/time/base/BaseDateTime.java - src/main/java/org/joda/time/format/StrictISODateTimeFormat.java - - - - - - - - - - license - - - license.generation - true - - - - - - diff --git a/dev-tools/pom.xml b/dev-tools/pom.xml deleted file mode 100644 index f02d6a8762a..00000000000 --- a/dev-tools/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - 4.0.0 - org.elasticsearch - dev-tools - 3.0.0-SNAPSHOT - Build Tools and Resources - Tools to assist in building and developing in the Elasticsearch project - - org.sonatype.oss - oss-parent - 7 - - - - UTF-8 - s3://download.elasticsearch.org/elasticsearch/staging/ - - - - - org.apache.maven.plugins - maven-remote-resources-plugin - 1.5 - - - - bundle - - - - - - **/* - - - - - - - - release - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - ${gpg.keyname} - ${gpg.passphrase} - ${gpg.keyring} - - - - - - - - - diff --git a/dev-tools/src/main/resources/ant/integration-tests.xml b/dev-tools/src/main/resources/ant/integration-tests.xml deleted file mode 100644 index f64f4403157..00000000000 --- a/dev-tools/src/main/resources/ant/integration-tests.xml +++ /dev/null @@ -1,406 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Installing plugin @{name}... - - - - - - - - - - - - - - - - - - - - - - - - - Waiting for elasticsearch to become available on port @{port}... - - - - - - - - - - - - Waiting for elasticsearch to form a cluster of two... - - - - - - - - - - - - - - - - - - - - - - - - - - - Starting up external cluster... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - External node started PID ${integ.pid} - - - - - - - - - - - - - - - - - - - - - - - - - Shutting down external node PID ${integ.pid} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev-tools/src/main/resources/plugin-metadata/plugin-assembly.xml b/dev-tools/src/main/resources/plugin-metadata/plugin-assembly.xml deleted file mode 100644 index 88471f022cd..00000000000 --- a/dev-tools/src/main/resources/plugin-metadata/plugin-assembly.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - plugin - - zip - - false - - - ${project.basedir}/src/main/plugin-metadata - - plugin-security.policy - - - false - - - - - ${elasticsearch.tools.directory}/plugin-metadata/plugin-descriptor.properties - - true - - - - - / - true - true - true - - - diff --git a/distribution/deb/pom.xml b/distribution/deb/pom.xml deleted file mode 100644 index c43e32be4f7..00000000000 --- a/distribution/deb/pom.xml +++ /dev/null @@ -1,332 +0,0 @@ - - - 4.0.0 - - org.elasticsearch.distribution - distributions - 3.0.0-SNAPSHOT - - - org.elasticsearch.distribution.deb - elasticsearch - Distribution: Deb - - - The Debian distribution of Elasticsearch - - - false - dpkg-sig - - - - - - ${project.basedir}/src/main/packaging/packaging.properties - - - - - org.apache.maven.plugins - maven-resources-plugin - - - - copy-resources-deb - prepare-package - - copy-resources - - - ${project.build.directory}/generated-packaging/deb/ - - ${project.basedir}/../src/main/packaging/packaging.properties - ${project.basedir}/src/main/packaging/packaging.properties - - - - ${project.basedir}/../src/main/packaging/ - true - - **/* - - - packaging.properties - - - - ${project.basedir}/src/main/packaging/ - true - - **/* - - - packaging.properties - - - - ${project.basedir}/../src/main/resources - true - - bin/elasticsearch - bin/elasticsearch.in.sh - bin/plugin - bin/elasticsearch-systemd-pre-exec - - - - - - - - - - - jdeb - org.vafer - - - ${project.build.directory}/releases/elasticsearch-${project.version}.deb - ${project.build.directory}/generated-packaging/deb/scripts - - - - package - - jdeb - - - ${deb.sign} - ${gpg.keyring} - ${gpg.key} - ${gpg.passphrase} - ${deb.sign.method} - - - - ${project.build.directory}/generated-packaging/deb/bin - directory - elasticsearch,elasticsearch.in.sh,plugin,elasticsearch-systemd-pre-exec - - perm - ${packaging.elasticsearch.bin.dir} - 755 - root - root - - - - - template - - ${packaging.elasticsearch.conf.dir} - - - perm - 750 - root - elasticsearch - - - - - ${project.basedir}/../src/main/resources/config - directory - .DS_Store - - perm - ${packaging.elasticsearch.conf.dir} - 750 - root - elasticsearch - - - - template - - ${packaging.elasticsearch.conf.dir}/scripts - - - perm - 750 - root - elasticsearch - - - - - ${project.build.directory}/generated-packaging/deb/env/elasticsearch - file - - perm - /etc/default - 644 - root - root - - - - - ${project.build.directory}/ - elasticsearch-${project.version}.jar - directory - - perm - ${packaging.elasticsearch.home.dir}/lib - root - root - - - - ${project.build.directory}/../target/lib - ${project.build.finalName}-sources.jar,${project.build.finalName}-tests.jar,${project.build.finalName}-test-sources.jar,slf4j-api-*.jar - directory - - perm - ${packaging.elasticsearch.home.dir}/lib - root - root - - - - - ${project.build.directory}/generated-packaging/deb/init.d/ - directory - .DS_Store - - perm - /etc/init.d - 755 - root - root - - - - - ${project.build.directory}/generated-packaging/deb/systemd/elasticsearch.service - ${packaging.elasticsearch.systemd.dir}/elasticsearch.service - file - - - - ${project.build.directory}/generated-packaging/deb/systemd/sysctl/elasticsearch.conf - ${packaging.elasticsearch.systemd.sysctl.dir}/elasticsearch.conf - file - - - - ${project.build.directory}/generated-packaging/deb/systemd/elasticsearch.conf - ${packaging.elasticsearch.tmpfilesd.dir}/elasticsearch.conf - file - - - - ${project.build.directory}/generated-packaging/deb/lintian - directory - .DS_Store - - perm - /usr/share/lintian/overrides - root - root - - - - - ${project.basedir}/../src/main/resources/ - *.txt, *.textile - LICENSE.txt, .DS_Store - directory - - perm - ${packaging.elasticsearch.home.dir} - root - root - - - - - ${project.build.directory}/generated-packaging/deb/copyright - /usr/share/doc/elasticsearch/copyright - file - - - - template - - ${packaging.elasticsearch.data.dir} - ${packaging.elasticsearch.log.dir} - ${packaging.elasticsearch.plugins.dir} - ${packaging.elasticsearch.pid.dir} - - - perm - 755 - ${packaging.elasticsearch.user} - ${packaging.elasticsearch.group} - - - - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - integ-setup - pre-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - integ-teardown - post-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - - - - - has_dpkg - - /usr/bin/dpkg-deb - - - true - - - - diff --git a/distribution/pom.xml b/distribution/pom.xml deleted file mode 100644 index 71575db9eef..00000000000 --- a/distribution/pom.xml +++ /dev/null @@ -1,255 +0,0 @@ - - - 4.0.0 - - org.elasticsearch - parent - 3.0.0-SNAPSHOT - - - org.elasticsearch.distribution - distributions - pom - Distribution: Parent POM - - - - /usr/share/elasticsearch - /usr/share/elasticsearch/bin - /etc/elasticsearch - /var/lib/elasticsearch - elasticsearch - elasticsearch - /var/log/elasticsearch - ${packaging.elasticsearch.home.dir}/plugins - /var/run/elasticsearch - /usr/lib/systemd/system - /usr/lib/sysctl.d - /usr/lib/tmpfiles.d - - - ${project.basedir}/../licenses - ${integ.scratch} - - - true - - - - - - com.carrotsearch.randomizedtesting - randomizedtesting-runner - test - - - - org.hamcrest - hamcrest-all - test - - - - org.apache.lucene - lucene-test-framework - test - - - - org.elasticsearch - elasticsearch - test - test-jar - - - - org.apache.httpcomponents - httpclient - test - - - - - org.elasticsearch - elasticsearch - - - - com.spatial4j - spatial4j - - - - com.vividsolutions - jts - - - - - com.github.spullara.mustache.java - compiler - - - - log4j - log4j - - - - log4j - apache-log4j-extras - - - - - - net.java.dev.jna - jna - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - prepare-package - - copy-dependencies - - - ${project.build.directory}/lib - runtime - - - - - - org.apache.maven.plugins - maven-eclipse-plugin - - - [groupId].[artifactId] - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - org.apache.maven.plugins - maven-resources-plugin - - - copy-resources - prepare-package - - copy-resources - - - ${project.build.directory}/bin - - - ${project.basedir}/../src/main/resources/bin - true - - *.exe - - - - ${project.basedir}/../src/main/resources/bin - false - - *.exe - - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - true - - - - com.carrotsearch.randomizedtesting - junit4-maven-plugin - - - integ-tests - - - 1 - - - localhost:${integ.transport.port} - - - - - - - - - - - tar - zip - deb - - - - - - macos_brew - - - - /usr/local/bin/rpmbuild - - - - rpm - - - - - rpm - - - - /usr/bin/rpmbuild - - - - rpm - - - - - diff --git a/distribution/rpm/pom.xml b/distribution/rpm/pom.xml deleted file mode 100644 index 218e19e57b7..00000000000 --- a/distribution/rpm/pom.xml +++ /dev/null @@ -1,402 +0,0 @@ - - - 4.0.0 - - org.elasticsearch.distribution - distributions - 3.0.0-SNAPSHOT - - - org.elasticsearch.distribution.rpm - elasticsearch - Distribution: RPM - rpm - The RPM distribution of Elasticsearch - - - true - ${project.build.directory}/releases/ - - - - - - ${project.basedir}/src/main/packaging/packaging.properties - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.4 - true - - - org.apache.maven.plugins - maven-resources-plugin - - - - copy-resources-rpm - prepare-package - - copy-resources - - - ${project.build.directory}/generated-packaging/rpm/ - - ${project.basedir}/../src/main/packaging/packaging.properties - ${project.basedir}/src/main/packaging/packaging.properties - - - - ${project.basedir}/../src/main/packaging/ - true - - **/* - - - packaging.properties - - - - ${project.basedir}/src/main/packaging/ - true - - **/* - - - packaging.properties - - - - ${project.basedir}/../src/main/resources - true - - bin/elasticsearch - bin/elasticsearch.in.sh - bin/plugin - bin/elasticsearch-systemd-pre-exec - - - - - - - - - - org.codehaus.mojo - rpm-maven-plugin - - false - elasticsearch - Elasticsearch - Application/Internet - Elasticsearch - /usr - - noarch - linux - src/changelog - - _unpackaged_files_terminate_build 0 - _binaries_in_noarch_packages_terminate_build 0 - - 644 - 755 - root - root - ${project.basedir}/src/main/resources/logo/elastic.gif - Elasticsearch is a distributed RESTful search engine built for the cloud. Reference documentation can be found at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html and the 'Elasticsearch: The Definitive Guide' book can be found at https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html - - - - ${packaging.elasticsearch.bin.dir}/ - 755 - - - ${project.build.directory}/generated-packaging/rpm/bin - - elasticsearch - elasticsearch.in.sh - plugin - elasticsearch-systemd-pre-exec - - - - - - - - ${packaging.elasticsearch.conf.dir} - noreplace - elasticsearch - 750 - - - ${packaging.elasticsearch.conf.dir}/ - noreplace - elasticsearch - 750 - - - ${project.basedir}/../src/main/resources/config/ - - *.yml - - - - - - ${packaging.elasticsearch.conf.dir}/scripts - noreplace - elasticsearch - 750 - - - - /etc/sysconfig/ - false - noreplace - - - ${project.build.directory}/generated-packaging/rpm/env/ - - elasticsearch - - - - - - - ${packaging.elasticsearch.home.dir}/lib - - - target/lib/ - - ${project.build.finalName}-sources.jar - ${project.build.finalName}-tests.jar - ${project.build.finalName}-test-sources.jar - slf4j-api-*.jar - - - - - - - /etc/init.d - false - 755 - true - - - ${project.build.directory}/generated-packaging/rpm/init.d - - elasticsearch - - - - - - - ${packaging.elasticsearch.systemd.dir} - false - true - - - ${project.build.directory}/generated-packaging/rpm/systemd - - elasticsearch.service - - - - - - - ${packaging.elasticsearch.systemd.sysctl.dir} - true - - - ${project.build.directory}/generated-packaging/rpm/systemd/sysctl - - elasticsearch.conf - - - - - - - ${packaging.elasticsearch.tmpfilesd.dir} - true - - - ${project.build.directory}/generated-packaging/rpm/systemd/ - - elasticsearch.conf - - - - - - - ${packaging.elasticsearch.home.dir} - - - ${project.basedir}/../src/main/resources/ - - LICENSE.txt - NOTICE.txt - README.textile - - - - - - - ${packaging.elasticsearch.data.dir} - 755 - ${packaging.elasticsearch.user} - ${packaging.elasticsearch.group} - - - ${packaging.elasticsearch.log.dir} - 755 - ${packaging.elasticsearch.user} - ${packaging.elasticsearch.group} - - - ${packaging.elasticsearch.plugins.dir} - 755 - ${packaging.elasticsearch.user} - ${packaging.elasticsearch.group} - - - ${packaging.elasticsearch.pid.dir} - 755 - ${packaging.elasticsearch.user} - ${packaging.elasticsearch.group} - - - - ${project.build.directory}/generated-packaging/rpm/scripts/preinst - utf-8 - - - ${project.build.directory}/generated-packaging/rpm/scripts/postinst - utf-8 - - - ${project.build.directory}/generated-packaging/rpm/scripts/prerm - utf-8 - - - ${project.build.directory}/generated-packaging/rpm/scripts/postrm - utf-8 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-rpm - package - - copy - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - ${project.packaging} - true - ${rpm.outputDirectory} - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - integ-setup - pre-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - integ-teardown - post-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - - - - sign-rpm - - - rpm.sign - true - - - - - - org.codehaus.mojo - rpm-maven-plugin - - Application/Internet - ${gpg.key} - ${gpg.keyring} - - ${gpg.passphrase} - - - - - - - - diff --git a/distribution/src/main/assemblies/common-bin.xml b/distribution/src/main/assemblies/common-bin.xml deleted file mode 100644 index f95368d3572..00000000000 --- a/distribution/src/main/assemblies/common-bin.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - /lib - true - false - false - - - - *:pom - - - - - - ../src/main/resources/config - config - - * - - - - true - ../src/main/resources/bin - bin - dos - - elasticsearch.in.bat - elasticsearch.bat - plugin.bat - service.bat - - - - false - ../src/main/resources/bin - bin - - *.exe - - - - true - ../src/main/resources/bin - bin - 0755 - 0755 - unix - - elasticsearch.in.sh - elasticsearch - plugin - - - - - - ../src/main/resources/README.textile - - - - ../src/main/resources/LICENSE.txt - - - - ../src/main/resources/NOTICE.txt - - - - diff --git a/distribution/tar/pom.xml b/distribution/tar/pom.xml deleted file mode 100644 index f1ce8271c0c..00000000000 --- a/distribution/tar/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - 4.0.0 - - org.elasticsearch.distribution - distributions - 3.0.0-SNAPSHOT - - - org.elasticsearch.distribution.tar - elasticsearch - Distribution: TAR - - - The TAR distribution of Elasticsearch - - - - ${project.basedir}/../src/main/packaging/packaging.properties - - - - - org.apache.maven.plugins - maven-assembly-plugin - - false - ${project.build.directory}/releases/ - - ${project.basedir}/src/main/assemblies/targz-bin.xml - - - - - package - - single - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - - integ-setup - pre-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - integ-teardown - post-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - diff --git a/distribution/zip/pom.xml b/distribution/zip/pom.xml deleted file mode 100644 index a24c4492d70..00000000000 --- a/distribution/zip/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - 4.0.0 - - org.elasticsearch.distribution - distributions - 3.0.0-SNAPSHOT - - - org.elasticsearch.distribution.zip - elasticsearch - Distribution: ZIP - - - The ZIP distribution of Elasticsearch - - - - ${project.basedir}/../src/main/packaging/packaging.properties - - - - - org.apache.maven.plugins - maven-assembly-plugin - - false - ${project.build.directory}/releases/ - - ${project.basedir}/src/main/assemblies/zip-bin.xml - - - - - package - - single - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - - execute - package - - run - - - - - - - - - - - - - - integ-setup - pre-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - integ-teardown - post-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - diff --git a/plugins/analysis-icu/pom.xml b/plugins/analysis-icu/pom.xml deleted file mode 100644 index 6f204d6dd91..00000000000 --- a/plugins/analysis-icu/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - analysis-icu - Plugin: Analysis: ICU - The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. - - - org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin - analysis_icu - false - -Xlint:-deprecation - - - - - org.apache.lucene - lucene-analyzers-icu - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - - - com.mycila - license-maven-plugin - - - - **/IndexableBinaryStringTools.java - **/ICUCollationKeyFilter.java - **/TestIndexableBinaryStringTools.java - - - - - - - - diff --git a/plugins/analysis-kuromoji/pom.xml b/plugins/analysis-kuromoji/pom.xml deleted file mode 100644 index 9b28307ac0f..00000000000 --- a/plugins/analysis-kuromoji/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - analysis-kuromoji - Plugin: Analysis: Japanese (kuromoji) - The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. - - - org.elasticsearch.plugin.analysis.kuromoji.AnalysisKuromojiPlugin - analysis_kuromoji - false - - - - - org.apache.lucene - lucene-analyzers-kuromoji - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/analysis-phonetic/pom.xml b/plugins/analysis-phonetic/pom.xml deleted file mode 100644 index dfd6c166c14..00000000000 --- a/plugins/analysis-phonetic/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - analysis-phonetic - Plugin: Analysis: Phonetic - The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. - - - org.elasticsearch.plugin.analysis.AnalysisPhoneticPlugin - analysis_phonetic - false - -Xlint:-rawtypes,-unchecked - - - - - org.apache.lucene - lucene-analyzers-phonetic - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/analysis-smartcn/pom.xml b/plugins/analysis-smartcn/pom.xml deleted file mode 100644 index 64e7b79f5cd..00000000000 --- a/plugins/analysis-smartcn/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - analysis-smartcn - Plugin: Analysis: Smart Chinese (smartcn) - Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. - - - org.elasticsearch.plugin.analysis.smartcn.AnalysisSmartChinesePlugin - analysis_smartcn - false - - - - - org.apache.lucene - lucene-analyzers-smartcn - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/analysis-stempel/pom.xml b/plugins/analysis-stempel/pom.xml deleted file mode 100644 index 4b9b7c33985..00000000000 --- a/plugins/analysis-stempel/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - analysis-stempel - Plugin: Analysis: Polish (stempel) - The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. - - - org.elasticsearch.plugin.analysis.stempel.AnalysisStempelPlugin - analysis_stempel - false - - - - - org.apache.lucene - lucene-analyzers-stempel - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/delete-by-query/pom.xml b/plugins/delete-by-query/pom.xml deleted file mode 100644 index 105c9f9ab4a..00000000000 --- a/plugins/delete-by-query/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - delete-by-query - Plugin: Delete By Query - The Delete By Query plugin allows to delete documents in Elasticsearch with a single query. - - - org.elasticsearch.plugin.deletebyquery.DeleteByQueryPlugin - warn - delete_by_query - false - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/discovery-azure/pom.xml b/plugins/discovery-azure/pom.xml deleted file mode 100644 index 1ce0dc482a1..00000000000 --- a/plugins/discovery-azure/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - discovery-azure - Plugin: Discovery: Azure - The Azure Discovery plugin allows to use Azure API for the unicast discovery mechanism. - - - org.elasticsearch.plugin.discovery.azure.AzureDiscoveryPlugin - 1 - discovery_azure - false - - -Xlint:-path,-serial,-static,-unchecked - - - - - - com.microsoft.azure - azure-management-compute - 0.7.0 - - - stax - stax-api - - - - - com.microsoft.azure - azure-management - 0.7.0 - - - - - org.apache.httpcomponents - httpclient - compile - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/discovery-ec2/pom.xml b/plugins/discovery-ec2/pom.xml deleted file mode 100644 index 3a4f674db31..00000000000 --- a/plugins/discovery-ec2/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - discovery-ec2 - Plugin: Discovery: EC2 - The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. - - - org.elasticsearch.plugin.discovery.ec2.Ec2DiscoveryPlugin - 1 - discovery_ec2 - false - -Xlint:-rawtypes - - - - - - com.amazonaws - aws-java-sdk-ec2 - ${amazonaws.version} - - - - - org.apache.httpcomponents - httpclient - compile - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/discovery-gce/pom.xml b/plugins/discovery-gce/pom.xml deleted file mode 100644 index 2baf3dffa08..00000000000 --- a/plugins/discovery-gce/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - discovery-gce - Plugin: Discovery: Google Compute Engine - The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. - - - org.elasticsearch.plugin.discovery.gce.GceDiscoveryPlugin - v1-rev71-1.20.0 - discovery_gce - false - -Xlint:-rawtypes,-unchecked - - - - - - com.google.apis - google-api-services-compute - ${google.gce.version} - - - com.google.guava - guava-jdk5 - - - - - - - org.apache.httpcomponents - httpclient - compile - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/discovery-multicast/pom.xml b/plugins/discovery-multicast/pom.xml deleted file mode 100644 index 5ffa5d0c5d6..00000000000 --- a/plugins/discovery-multicast/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - discovery-multicast - Plugin: Discovery: Multicast - The Multicast Discovery plugin allows discovery other nodes using multicast requests - - - org.elasticsearch.plugin.discovery.multicast.MulticastDiscoveryPlugin - 1 - discovery_multicast - false - -Xlint:-deprecation - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/jvm-example/pom.xml b/plugins/jvm-example/pom.xml deleted file mode 100644 index 96c9a0316c1..00000000000 --- a/plugins/jvm-example/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - jvm-example - Plugin: JVM example - Demonstrates all the pluggable Java entry points in Elasticsearch - - - org.elasticsearch.plugin.example.JvmExamplePlugin - jvm_example - false - true - -Xlint:-rawtypes - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - src/main/assemblies/plugin.xml - - - - - - - diff --git a/plugins/jvm-example/src/main/assemblies/plugin.xml b/plugins/jvm-example/src/main/assemblies/plugin.xml deleted file mode 100644 index 999ae36f4ca..00000000000 --- a/plugins/jvm-example/src/main/assemblies/plugin.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - plugin - - zip - - false - - - ${elasticsearch.tools.directory}/plugin-metadata/plugin-descriptor.properties - - true - - - - - src/main/config - config - - - src/main/bin - bin - - - - - / - true - true - true - - - diff --git a/plugins/lang-expression/pom.xml b/plugins/lang-expression/pom.xml deleted file mode 100644 index cf503d4fb01..00000000000 --- a/plugins/lang-expression/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - lang-expression - Plugin: Language: Expression - Lucene expressions integration for Elasticsearch - - - org.elasticsearch.script.expression.ExpressionPlugin - lang_expression - false - -Xlint:-rawtypes - - - - - org.apache.lucene - lucene-expressions - ${lucene.maven.version} - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/lang-groovy/pom.xml b/plugins/lang-groovy/pom.xml deleted file mode 100644 index eeb5244b9a0..00000000000 --- a/plugins/lang-groovy/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - lang-groovy - Plugin: Language: Groovy - Groovy scripting integration for Elasticsearch - - - org.elasticsearch.script.groovy.GroovyPlugin - lang_groovy - false - -Xlint:-rawtypes,-unchecked,-cast,-deprecation - - - - - org.codehaus.groovy - groovy-all - indy - 2.4.4 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/lang-javascript/pom.xml b/plugins/lang-javascript/pom.xml deleted file mode 100644 index 69da06ec4d2..00000000000 --- a/plugins/lang-javascript/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - lang-javascript - Plugin: Language: JavaScript - The JavaScript language plugin allows to have javascript as the language of scripts to execute. - - - org.elasticsearch.plugin.javascript.JavaScriptPlugin - lang_javascript - false - -Xlint:-rawtypes,-unchecked - - - - - org.mozilla - rhino - 1.7R4 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/lang-python/pom.xml b/plugins/lang-python/pom.xml deleted file mode 100644 index 73742e2b5e3..00000000000 --- a/plugins/lang-python/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - lang-python - Plugin: Language: Python - The Python language plugin allows to have python as the language of scripts to execute. - - - org.elasticsearch.plugin.python.PythonPlugin - lang_python - false - -Xlint:-unchecked - - - - - - org.python - jython-standalone - 2.7.0 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/mapper-murmur3/pom.xml b/plugins/mapper-murmur3/pom.xml deleted file mode 100644 index 2e78be25c09..00000000000 --- a/plugins/mapper-murmur3/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - mapper-murmur3 - Plugin: Mapper: Murmur3 - The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. - - - org.elasticsearch.plugin.mapper.MapperMurmur3Plugin - mapper_murmur3 - false - -Xlint:-rawtypes - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/mapper-size/pom.xml b/plugins/mapper-size/pom.xml deleted file mode 100644 index 3e148cdfc28..00000000000 --- a/plugins/mapper-size/pom.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - mapper-size - Plugin: Mapper: Size - The Mapper Size plugin allows document to record their uncompressed size at index time. - - - org.elasticsearch.plugin.mapper.MapperSizePlugin - mapper_size - false - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/pom.xml b/plugins/pom.xml deleted file mode 100644 index 7109ba31a4d..00000000000 --- a/plugins/pom.xml +++ /dev/null @@ -1,437 +0,0 @@ - - - - 4.0.0 - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - pom - Plugin: Parent POM - 2009 - A parent project for Elasticsearch plugins - - - org.elasticsearch - parent - 3.0.0-SNAPSHOT - - - - ${elasticsearch.tools.directory}/plugin-metadata/plugin-assembly.xml - false - ${project.artifactId} - true - true - false - 1.10.19 - - - - - - org.hamcrest - hamcrest-all - test - - - org.apache.lucene - lucene-test-framework - test - - - org.elasticsearch - elasticsearch - test-jar - test - - - - - org.elasticsearch - elasticsearch - provided - - - org.apache.lucene - lucene-core - provided - - - org.apache.lucene - lucene-backward-codecs - provided - - - org.apache.lucene - lucene-analyzers-common - provided - - - org.apache.lucene - lucene-queries - provided - - - org.apache.lucene - lucene-memory - provided - - - org.apache.lucene - lucene-highlighter - provided - - - org.apache.lucene - lucene-queryparser - provided - - - org.apache.lucene - lucene-suggest - provided - - - org.apache.lucene - lucene-join - provided - - - org.apache.lucene - lucene-spatial - provided - - - com.spatial4j - spatial4j - provided - - - com.vividsolutions - jts - provided - - - com.github.spullara.mustache.java - compiler - provided - - - com.carrotsearch - hppc - provided - - - joda-time - joda-time - provided - - - org.joda - joda-convert - provided - - - com.fasterxml.jackson.core - jackson-core - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-cbor - provided - - - io.netty - netty - provided - - - com.ning - compress-lzf - provided - - - com.tdunning - t-digest - provided - - - commons-cli - commons-cli - provided - - - log4j - log4j - provided - - - log4j - apache-log4j-extras - provided - - - org.slf4j - slf4j-api - provided - - - net.java.dev.jna - jna - provided - - - - - - org.apache.httpcomponents - httpclient - test - - - - - - - - src/test/resources - - **/* - - - - - ${elasticsearch.tools.directory}/rest-api-spec - rest-api-spec - - - api/info.json - api/cluster.health.json - api/cluster.state.json - - api/index.json - api/get.json - api/get_script.json - api/put_script.json - api/delete_script.json - api/update.json - api/search.json - api/indices.analyze.json - api/indices.create.json - api/indices.refresh.json - api/nodes.info.json - api/count.json - - api/snapshot.create_repository.json - api/snapshot.get_repository.json - - - - - ${elasticsearch.tools.directory}/shared-test-resources - false - - - - ${basedir}/target/metadata-test-resources - false - - - - - - - maven-resources-plugin - - - copy-resources - - generate-resources - - copy-resources - - - ${basedir}/target/metadata-test-resources - - - src/main/plugin-metadata - false - - - ${elasticsearch.tools.directory}/plugin-metadata - true - - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - integ-setup - pre-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - integ-teardown - post-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - ${elasticsearch.assembly.appendId} - ${project.build.directory}/releases/ - - ${elasticsearch.assembly.descriptor} - - - - - package - - single - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-plugin-classname - - enforce - - - - - elasticsearch.plugin.classname - elasticsearch.plugin.name - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - integ-setup-dependencies - pre-integration-test - - copy - - - ${skip.integ.tests} - - - org.elasticsearch.distribution.zip - elasticsearch - ${elasticsearch.version} - zip - true - - - true - ${integ.deps} - - - - - - com.carrotsearch.randomizedtesting - junit4-maven-plugin - - - integ-tests - - - 1 - - - localhost:${integ.transport.port} - - - - - - - - - - - analysis-icu - analysis-kuromoji - analysis-phonetic - analysis-smartcn - analysis-stempel - delete-by-query - discovery-azure - discovery-ec2 - discovery-gce - discovery-multicast - lang-expression - lang-groovy - lang-javascript - lang-python - mapper-murmur3 - mapper-size - repository-azure - repository-s3 - store-smb - - - jvm-example - site-example - - diff --git a/plugins/repository-azure/pom.xml b/plugins/repository-azure/pom.xml deleted file mode 100644 index a6aff7f9cf7..00000000000 --- a/plugins/repository-azure/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - repository-azure - Plugin: Repository: Azure - The Azure Repository plugin adds support for Azure storage repositories. - - - org.elasticsearch.plugin.repository.azure.AzureRepositoryPlugin - 1 - repository_azure - false - -Xlint:-deprecation,-serial - - - - - - com.microsoft.azure - azure-storage - 2.0.0 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/repository-s3/pom.xml b/plugins/repository-s3/pom.xml deleted file mode 100644 index cd68af71da0..00000000000 --- a/plugins/repository-s3/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - repository-s3 - Plugin: Repository: S3 - The S3 repository plugin adds S3 repositories. - - - org.elasticsearch.plugin.repository.s3.S3RepositoryPlugin - 1 - repository_s3 - false - -Xlint:-rawtypes,-deprecation - - - - - - com.amazonaws - aws-java-sdk-s3 - ${amazonaws.version} - - - - - org.apache.httpcomponents - httpclient - compile - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/plugins/site-example/pom.xml b/plugins/site-example/pom.xml deleted file mode 100644 index 38b1b0d4ca5..00000000000 --- a/plugins/site-example/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - site-example - Plugin: Example site - Demonstrates how to serve resources via elasticsearch. - - - ${project.basedir}/src/main/assemblies/plugin-assembly.xml - true - NA - false - - example - false - true - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - org.apache.maven.plugins - maven-jar-plugin - - - default-jar - none - - - - - - - diff --git a/plugins/site-example/src/main/assemblies/plugin-assembly.xml b/plugins/site-example/src/main/assemblies/plugin-assembly.xml deleted file mode 100644 index 48a0286bf43..00000000000 --- a/plugins/site-example/src/main/assemblies/plugin-assembly.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - plugin - - zip - - false - - - - ${project.basedir}/src/site - - - - - - - ${elasticsearch.tools.directory}/plugin-metadata/plugin-descriptor.properties - - true - - - diff --git a/plugins/store-smb/pom.xml b/plugins/store-smb/pom.xml deleted file mode 100644 index 9ce7f4aa33d..00000000000 --- a/plugins/store-smb/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - 4.0.0 - - - org.elasticsearch.plugin - plugins - 3.0.0-SNAPSHOT - - - store-smb - Plugin: Store: SMB - The Store SMB plugin adds support for SMB stores. - - - org.elasticsearch.plugin.store.smb.SMBStorePlugin - 1 - store_smb - false - - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - - - diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 9cb61ca1a88..00000000000 --- a/pom.xml +++ /dev/null @@ -1,1505 +0,0 @@ - - - 4.0.0 - - org.elasticsearch - parent - 3.0.0-SNAPSHOT - pom - Elasticsearch: Parent POM - Parent POM - 2009 - - - org.sonatype.oss - oss-parent - 7 - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - scm:git:git@github.com:elastic/elasticsearch.git - scm:git:git@github.com:elastic/elasticsearch.git - http://github.com/elastic/elasticsearch - - - - UTF-8 - - ${project.version} - ${java.home}${file.separator}bin${file.separator}java - 1.8 - 1.8 - - -Xlint:-path - -Xdoclint:-missing - - - - - - 5.4.0 - 1710880 - 5.4.0-snapshot-${lucene.snapshot.revision} - 2.2.0 - 1.1 - 1.0 - - 2.6.2 - 1.6.2 - 1.2.17 - 0.7.5.201505241946 - s3://download.elasticsearch.org/elasticsearch/staging/ - - - ${project.build.directory}/dev-tools - ${elasticsearch.tools.directory}/license-check/elasticsearch_license_header.txt - ${elasticsearch.tools.directory}/license-check/license_header_definition.xml - ${elasticsearch.tools.directory}/ant/integration-tests.xml - ${elasticsearch.integ.antfile.default} - - - ${project.basedir}/licenses - ${basedir}/target/releases/${project.build.finalName}.zip - - - auto - true - onerror - - ${project.basedir}/backwards - random - random - ERROR - 512m - ${project.build.directory}/heapdump/ - 5 - .local-${elasticsearch.version}-execution-hints.log - .local-${elasticsearch.version}-integ-execution-hints.log - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - fail - ${skipTests} - ${skipTests} - ${project.build.directory}/integ tests - ${project.build.directory}/integ deps - ${integ.scratch}/temp - 9400 - 9500 - 9600 - 9700 - \bno(n|)commit\b - - - - - elasticsearch-releases - http://maven.elasticsearch.org/releases - - true - - - false - - - - oss-snapshots - Sonatype OSS Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - Lucene snapshots - https://download.elasticsearch.org/lucenesnapshots/${lucene.snapshot.revision} - - - - - - - org.elasticsearch - dev-tools - ${elasticsearch.version} - - - - com.carrotsearch.randomizedtesting - randomizedtesting-runner - ${testframework.version} - - - - org.hamcrest - hamcrest-all - 1.3 - - - - junit - junit - 4.11 - - - - com.google.jimfs - jimfs - 1.0 - - - - org.apache.lucene - lucene-test-framework - ${lucene.maven.version} - - - - com.carrotsearch.randomizedtesting - junit4-ant - - - - - - org.elasticsearch - securesm - ${securesm.version} - - - - org.elasticsearch - elasticsearch - ${elasticsearch.version} - - - - org.elasticsearch - elasticsearch - ${elasticsearch.version} - test-jar - - - - org.elasticsearch - elasticsearch - ${elasticsearch.version} - zip - - - - org.apache.httpcomponents - httpclient - 4.3.6 - - - - org.apache.lucene - lucene-core - ${lucene.maven.version} - - - org.apache.lucene - lucene-backward-codecs - ${lucene.maven.version} - - - org.apache.lucene - lucene-analyzers-common - ${lucene.maven.version} - - - org.apache.lucene - lucene-queries - ${lucene.maven.version} - - - jakarta-regexp - jakarta-regexp - - - - - org.apache.lucene - lucene-memory - ${lucene.maven.version} - - - org.apache.lucene - lucene-highlighter - ${lucene.maven.version} - - - org.apache.lucene - lucene-queryparser - ${lucene.maven.version} - - - jakarta-regexp - jakarta-regexp - - - - - org.apache.lucene - lucene-suggest - ${lucene.maven.version} - - - org.apache.lucene - lucene-join - ${lucene.maven.version} - - - - org.apache.lucene - lucene-spatial - ${lucene.maven.version} - - - com.spatial4j - spatial4j - 0.5 - - - com.vividsolutions - jts - 1.13 - - - xerces - xercesImpl - - - - - - com.github.spullara.mustache.java - compiler - 0.9.1 - - - - - org.apache.lucene - lucene-analyzers-phonetic - ${lucene.maven.version} - - - org.apache.lucene - lucene-analyzers-kuromoji - ${lucene.maven.version} - - - org.apache.lucene - lucene-analyzers-stempel - ${lucene.maven.version} - - - org.apache.lucene - lucene-analyzers-icu - ${lucene.maven.version} - - - org.apache.lucene - lucene-analyzers-smartcn - ${lucene.maven.version} - - - - com.carrotsearch - hppc - 0.7.1 - - - - joda-time - joda-time - - - 2.8.2 - - - org.joda - joda-convert - 1.2 - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - ${jackson.version} - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-cbor - ${jackson.version} - - - - io.netty - netty - 3.10.5.Final - - - - com.ning - compress-lzf - 1.0.2 - - - - com.tdunning - t-digest - 3.0 - - - - org.hdrhistogram - HdrHistogram - 2.1.6 - - - - commons-cli - commons-cli - 1.3.1 - - - - log4j - log4j - ${log4j.version} - - - - log4j - apache-log4j-extras - ${log4j.version} - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - - org.slf4j - slf4j-log4j12 - ${slf4j.version} - - - - net.java.dev.jna - jna - 4.1.0 - true - - - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.4.1 - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.codehaus.mojo - buildnumber-maven-plugin - - - com.carrotsearch.randomizedtesting - junit4-maven-plugin - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - org.apache.maven.plugins - maven-source-plugin - - - org.apache.maven.plugins - maven-remote-resources-plugin - - - de.thetaphi - forbiddenapis - - - org.apache.maven.plugins - maven-antrun-plugin - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.6 - - - org.apache.maven.plugins - maven-clean-plugin - 2.6.1 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-versions - - enforce - - - - - [${maven.compiler.source},) - - - - - - enforce-maven-version - - enforce - - - - - [3.1.0,) - - - - - - print-versions - validate - - display-info - - - - enforce-java-home-is-set - - enforce - - - - - JAVA_HOME - "JAVA_HOME must be set and point to the jdk to run the tests" - - - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - true - 512m - - false - true - - -XDignore.symbol.file - -Xlint:all - ${xlint.options} - -Xdoclint:all/private - ${doclint.options} - ${javac.werror} - - - - - com.carrotsearch.randomizedtesting - junit4-maven-plugin - ${testframework.version} - - - ${jvm.executable} - ${tests.jvm.argline} - 10 - warn - true - ${tests.jvms} - - - - - - - - -Xmx${tests.heap.size} - -Xms${tests.heap.size} - -XX:MaxDirectMemorySize=512m - -Des.logger.prefix= - -XX:+HeapDumpOnOutOfMemoryError - -XX:HeapDumpPath=${tests.heapdump.path} - - ${tests.shuffle} - ${tests.verbose} - ${tests.seed} - - true - - - ./temp - - ${tests.bwc} - ${tests.bwc.path} - ${tests.bwc.version} - ${tests.jvm.argline} - ${tests.appendseed} - ${tests.cluster} - ${tests.iters} - ${project.groupId}:${project.artifactId} - - ${project.artifactId} - ${tests.maxfailures} - ${tests.failfast} - ${tests.class} - ${tests.method} - ${tests.nightly} - ${tests.verbose} - ${tests.badapples} - ${tests.weekly} - ${tests.failfast} - ${tests.awaitsfix} - ${tests.timeoutSuite} - ${tests.showSuccess} - ${tests.thirdparty} - ${tests.config} - ${tests.coverage} - ${project.build.directory} - ${tests.client.ratio} - ${tests.enable_mock_modules} - ${tests.assertion.disabled} - ${tests.rest} - ${tests.rest.suite} - ${tests.rest.blacklist} - ${tests.rest.spec} - ${tests.network} - ${tests.heap.size} - ${tests.filter} - ${elasticsearch.version} - ${tests.locale} - ${tests.rest.load_packaged} - ${tests.timezone} - ${env.ES_TEST_LOCAL} - ${es.node.mode} - ${es.logger.level} - ${tests.security.manager} - ${tests.compatibility} - true - - true - - - - - - - - - - - - - - - - - - - - tests - test - - junit4 - - - ${tests.ifNoTests} - ${skip.unit.tests} - - - - - - - - - - - **/*Tests.class - - - **/*$*.class - - - - - integ-tests - integration-test - - junit4 - - - warn - false - ${skip.integ.tests} - - - - - - - - - - - **/*IT.class - - - - true - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18.1 - - true - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.18.1 - - ${skip.integ.tests} - true - - - - verify - - verify - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.4 - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-remote-resources-plugin - 1.5 - - - org.elasticsearch:dev-tools:${elasticsearch.version} - org.elasticsearch:rest-api-spec:${elasticsearch.version} - - ${elasticsearch.tools.directory} - - false - false - - - - - process - - - - - - de.thetaphi - forbiddenapis - 2.0 - - - - check-forbidden-apis - - ${maven.compiler.target} - - true - - false - - - jdk-unsafe - jdk-deprecated - jdk-system-out - - - ${elasticsearch.tools.directory}/forbidden/core-signatures.txt - ${elasticsearch.tools.directory}/forbidden/all-signatures.txt - ${elasticsearch.tools.directory}/forbidden/third-party-signatures.txt - - ${forbidden.signatures} - **.SuppressForbidden - - compile - - check - - - - check-forbidden-test-apis - - ${maven.compiler.target} - - true - - false - - - jdk-unsafe - jdk-deprecated - - - ${elasticsearch.tools.directory}/forbidden/test-signatures.txt - ${elasticsearch.tools.directory}/forbidden/all-signatures.txt - - ${forbidden.test.signatures} - **.SuppressForbidden - - test-compile - - testCheck - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 2.4.1 - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - - ico - - - - - org.apache.maven.plugins - maven-site-plugin - 3.4 - - ${elasticsearch.tools.directory}/site - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.3 - - - validate - - create - - - - - false - false - - - - - - org.vafer - jdeb - 1.4 - true - - - - org.codehaus.mojo - rpm-maven-plugin - 2.1.3 - true - - - org.apache.maven.plugins - maven-jar-plugin - 2.5 - - - - true - - - ${scmBranch} - ${buildNumber} - ${timestamp} - ${elasticsearch.version} - ${lucene.version} - ${maven.compiler.source} - ${maven.compiler.target} - - - - - - - org.codehaus.mojo - license-maven-plugin - 1.8 - - - - com.mycila - license-maven-plugin - 2.5 - -
${elasticsearch.license.header}
- - ${elasticsearch.license.headerDefinition} - - - src/**/*.java - -
- - - check-license-headers - compile - - check - - - -
- - - org.apache.maven.plugins - maven-eclipse-plugin - 2.10 - - eclipse-build - true - - - .settings/org.eclipse.core.resources.prefs - - =UTF-8 -]]> - - - - .settings/org.eclipse.jdt.core.prefs - - - - - - .settings/org.eclipse.jdt.ui.prefs - - -]]> - - - - - - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.5 - - - org.apache.maven.plugins - maven-pmd-plugin - 3.5 - - - ${elasticsearch.tools.directory}/pmd/custom.xml - - ${maven.compiler.target} - - - - org.codehaus.mojo - findbugs-maven-plugin - 3.0.0 - - true - target/site - true - 2048 - 1800000 - org.elasticsearch.- - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.7 - - - org.jacoco - jacoco-maven-plugin - ${jacoco.version} - - - default-prepare-agent - - prepare-agent - - - - default-report - prepare-package - - report - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - - set-werror - validate - - run - - - - - - - - - true - - - - check-invalid-patterns - validate - - run - - - - - - - - - - - - - - - - - - - - - - - - The following files contain tabs or - nocommits:${line.separator}${validate.patternsFound} - - - - - - generate-test-resources - create-heapdump-directory - - - - - - - - run - - - - tests-top-hints - test - - ${skip.unit.tests} - - - - - - - - - run - - - - integ-tests-top-hints - integration-test - - ${skip.integ.tests} - - - - - - - - - run - - - - check-license - verify - - run - - - ${skip.integ.tests} - - Running license check - - - - - - - - - - - - - - - com.carrotsearch.randomizedtesting - junit4-ant - ${testframework.version} - - - - - - org.apache.maven.plugins - maven-invoker-plugin - 2.0.0 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.3 - - - -Xdoclint:none - - - - - org.apache.maven.plugins - maven-verifier-plugin - 1.1 - - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.15 - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - true - - -
-
-
- - - default - - true - - - - - com.mycila - license-maven-plugin - - - - - - release - - true - \bno(n|)(release|commit)\b - org.apache.lucene.util.LuceneTestCase$AwaitsFix @ Please fix all bugs before release or mark them as ignored - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - ${gpg.keyname} - ${gpg.passphrase} - ${gpg.keyring} - - - - - - - - - - license - - - license.generation - true - - - - - - - pom - - false - - ${basedir}/src/test/java - - - - true - true - true - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - create-heapdump-directory - none - - - tests-top-hints - none - - - - - - - - - dev - - - - de.thetaphi - forbiddenapis - - - check-forbidden-apis - none - - - check-forbidden-test-apis - none - - - - - com.mycila - license-maven-plugin - - - check-license-headers - none - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - check-invalid-patterns - none - - - - - - - - - coverage - - - tests.coverage - true - - - - - true - - - - - org.jacoco - jacoco-maven-plugin - - - - - - - static - - - tests.static - true - - - - false - - - - - org.codehaus.mojo - findbugs-maven-plugin - - - - - - - org.apache.maven.plugins - maven-jxr-plugin - - - org.apache.maven.plugins - maven-pmd-plugin - - - org.codehaus.mojo - findbugs-maven-plugin - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.7 - - - - index - - - - - - - - - - dev-tools - rest-api-spec - core - distribution - plugins - qa - -
diff --git a/qa/pom.xml b/qa/pom.xml deleted file mode 100644 index 7cc28fe622e..00000000000 --- a/qa/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - 4.0.0 - - org.elasticsearch.qa - elasticsearch-qa - 3.0.0-SNAPSHOT - pom - QA: Parent POM - 2015 - - - org.elasticsearch - parent - 3.0.0-SNAPSHOT - - - - - - - - - org.hamcrest - hamcrest-all - test - - - org.apache.lucene - lucene-test-framework - test - - - - - - - - - src/test/resources - true - - rest-api-spec/** - - - - - ${elasticsearch.tools.directory}/rest-api-spec - rest-api-spec - - - api/info.json - api/cluster.health.json - api/cluster.state.json - - api/index.json - api/get.json - api/update.json - api/search.json - api/indices.analyze.json - api/indices.create.json - api/indices.refresh.json - api/nodes.info.json - api/count.json - - - - - ${elasticsearch.tools.directory}/shared-test-resources - false - - - - - - - com.carrotsearch.randomizedtesting - junit4-maven-plugin - - - integ-tests - - - 1 - - - 127.0.0.1:${integ.transport.port} - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - check-license - none - - - - - - - - - smoke-test-plugins - smoke-test-multinode - smoke-test-client - - - - - vagrant - - - tests.vagrant - - - - vagrant - - - - diff --git a/qa/smoke-test-client/pom.xml b/qa/smoke-test-client/pom.xml deleted file mode 100644 index 82495c1c023..00000000000 --- a/qa/smoke-test-client/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - elasticsearch-qa - org.elasticsearch.qa - 3.0.0-SNAPSHOT - - 4.0.0 - - - - smoke-test-client - QA: Smoke Test Client - Test the Java Client against a running cluster - - - true - - - - - org.elasticsearch - elasticsearch - test - - - log4j - log4j - test - - - - - - - src/test/resources - - - - ${elasticsearch.tools.directory}/shared-test-resources - false - - - - - - org.apache.maven.plugins - maven-remote-resources-plugin - - - org.apache.maven.plugins - maven-dependency-plugin - - - integ-setup-dependencies - pre-integration-test - - copy - - - ${skip.integ.tests} - true - ${integ.deps}/plugins - - - - - org.elasticsearch.distribution.zip - elasticsearch - ${elasticsearch.version} - zip - true - ${integ.deps} - - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - integ-setup - pre-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - integ-teardown - post-integration-test - - run - - - ${skip.integ.tests} - - - - - - - - - - - diff --git a/qa/smoke-test-plugins/integration-tests.xml b/qa/smoke-test-plugins/integration-tests.xml deleted file mode 100644 index 4f7c6194e55..00000000000 --- a/qa/smoke-test-plugins/integration-tests.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/qa/smoke-test-plugins/pom.xml b/qa/smoke-test-plugins/pom.xml deleted file mode 100644 index 3e5563139ed..00000000000 --- a/qa/smoke-test-plugins/pom.xml +++ /dev/null @@ -1,478 +0,0 @@ - - - - 4.0.0 - - - org.elasticsearch.qa - elasticsearch-qa - 3.0.0-SNAPSHOT - - - - - smoke-test-plugins - QA: Smoke Test Plugins - Loads up all of our plugins - - - true - ${project.basedir}/integration-tests.xml - smoke_test_plugins - false - - - - org.elasticsearch - elasticsearch - test-jar - test - - - - - org.elasticsearch - elasticsearch - provided - - - org.apache.lucene - lucene-core - provided - - - org.apache.lucene - lucene-backward-codecs - provided - - - org.apache.lucene - lucene-analyzers-common - provided - - - org.apache.lucene - lucene-queries - provided - - - org.apache.lucene - lucene-memory - provided - - - org.apache.lucene - lucene-highlighter - provided - - - org.apache.lucene - lucene-queryparser - provided - - - org.apache.lucene - lucene-suggest - provided - - - org.apache.lucene - lucene-join - provided - - - org.apache.lucene - lucene-spatial - provided - - - com.spatial4j - spatial4j - provided - - - com.vividsolutions - jts - provided - - - com.github.spullara.mustache.java - compiler - provided - - - com.carrotsearch - hppc - provided - - - joda-time - joda-time - provided - - - org.joda - joda-convert - provided - - - com.fasterxml.jackson.core - jackson-core - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-smile - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-cbor - provided - - - io.netty - netty - provided - - - com.ning - compress-lzf - provided - - - com.tdunning - t-digest - provided - - - commons-cli - commons-cli - provided - - - log4j - log4j - provided - - - log4j - apache-log4j-extras - provided - - - org.slf4j - slf4j-api - provided - - - net.java.dev.jna - jna - provided - - - - - - org.apache.httpcomponents - httpclient - test - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - integ-setup-dependencies - pre-integration-test - - copy - - - ${skip.integ.tests} - true - ${integ.deps}/plugins - - - - - org.elasticsearch.distribution.zip - elasticsearch - ${elasticsearch.version} - zip - true - ${integ.deps} - - - - - org.elasticsearch.plugin - analysis-icu - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - analysis-kuromoji - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - analysis-phonetic - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - analysis-smartcn - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - analysis-stempel - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - discovery-gce - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - delete-by-query - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - discovery-azure - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - discovery-ec2 - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - discovery-multicast - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - lang-expression - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - lang-groovy - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - lang-javascript - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - lang-python - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - mapper-murmur3 - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - mapper-size - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - repository-azure - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - repository-s3 - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - store-smb - ${elasticsearch.version} - zip - true - - - - - org.elasticsearch.plugin - jvm-example - ${elasticsearch.version} - zip - true - - - - org.elasticsearch.plugin - site-example - ${elasticsearch.version} - zip - true - - - - - - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - count-expected-plugins - validate - - run - - - - - - - - Found ${expected.plugin.count} plugins in ${plugins.dir} - - true - - - - - integ-setup - pre-integration-test - - run - - - - - - - - - - ${skip.integ.tests} - - - - - integ-teardown - post-integration-test - - run - - - - - - ${skip.integ.tests} - - - - - - ant-contrib - ant-contrib - 1.0b3 - - - ant - ant - - - - - org.apache.ant - ant-nodeps - 1.8.1 - - - - - - - diff --git a/rest-api-spec/pom.xml b/rest-api-spec/pom.xml deleted file mode 100644 index e21e55fe89a..00000000000 --- a/rest-api-spec/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - 4.0.0 - org.elasticsearch - rest-api-spec - 3.0.0-SNAPSHOT - Rest API Specification - REST API Specification and tests for use with the Elasticsearch REST Test framework - - org.sonatype.oss - oss-parent - 7 - - - - UTF-8 - s3://download.elasticsearch.org/elasticsearch/staging/ - - - - - org.apache.maven.plugins - maven-remote-resources-plugin - 1.5 - - - - bundle - - - - - - **/* - - - - - - - - release - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.6 - - - sign-artifacts - verify - - sign - - - ${gpg.keyname} - ${gpg.passphrase} - ${gpg.keyring} - - - - - - - - - From 10ad6ae10f1d300c13bf74017176131f8e692508 Mon Sep 17 00:00:00 2001 From: Mark Walkom Date: Fri, 30 Oct 2015 18:46:31 +1100 Subject: [PATCH 13/37] Mention changes to repos. Fixes 14376 --- .../migration/migrate_2_0/packaging.asciidoc | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/reference/migration/migrate_2_0/packaging.asciidoc b/docs/reference/migration/migrate_2_0/packaging.asciidoc index 2d2e4365fbb..b50e10912a0 100644 --- a/docs/reference/migration/migrate_2_0/packaging.asciidoc +++ b/docs/reference/migration/migrate_2_0/packaging.asciidoc @@ -56,3 +56,24 @@ sudo bin/plugin install analysis-icu Community-provided plugins can be installed as before. +==== Repository naming structure changes + +Elasticsearch 2.0 changes the way the repository URLs are referenced. Instead +of specific repositories for both major and minor versions, the repositories will +use a major version reference only. + +The URL for apt packages now uses the following structure; + +[source,sh] +--------------- +deb http://packages.elastic.co/elasticsearch/2.x/debian stable main +--------------- + +And for yum packages it is; + +[source,sh] +--------------- +baseurl=http://packages.elastic.co/elasticsearch/2.x/centos +--------------- + +The <> page details this change. From 7f179cdab00cdffd1e50cb7bcbfd1ba2b78724e7 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Fri, 30 Oct 2015 10:31:40 +0100 Subject: [PATCH 14/37] Docs: Added redirect for mapping-nested-type --- docs/reference/redirects.asciidoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/reference/redirects.asciidoc b/docs/reference/redirects.asciidoc index 4cb43069086..6de6699984e 100644 --- a/docs/reference/redirects.asciidoc +++ b/docs/reference/redirects.asciidoc @@ -446,3 +446,9 @@ parameter of search requests. === Not query The `not` query has been replaced by using a `mustNot` clause in a Boolean query. + +[role="exclude",id="mapping-nested-type"] +=== Nested type + +The docs for the `nested` field datatype have moved to <>. + From aa38d053d75c4cc8134ecff0c23d8c4c9640c704 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 28 Oct 2015 22:19:44 +0100 Subject: [PATCH 15/37] Simplify Analysis registration and configuration This change moves all the analysis component registration to the node level and removes the significant API overhead to register tokenfilter, tokenizer, charfilter and analyzer. All registration is done without guice interaction such that real factories via functional interfaces are passed instead of class objects that are instantiated at runtime. This change also hides the internal analyzer caching that was done previously in the IndicesAnalysisService entirely and decouples all analysis registration and creation from dependency injection. --- .../analyze/TransportAnalyzeAction.java | 132 ++--- .../metadata/MetaDataIndexUpgradeService.java | 2 +- .../org/elasticsearch/index/IndexModule.java | 13 +- .../ASCIIFoldingTokenFilterFactory.java | 6 +- .../index/analysis/AnalysisModule.java | 507 ------------------ .../index/analysis/AnalysisRegistry.java | 461 ++++++++++++++++ .../index/analysis/AnalysisService.java | 173 +----- .../analysis/AnalysisSettingsRequired.java | 32 -- .../analysis/AnalyzerProviderFactory.java | 30 -- .../analysis/ApostropheFilterFactory.java | 6 +- .../analysis/ArabicAnalyzerProvider.java | 5 +- .../ArabicNormalizationFilterFactory.java | 6 +- .../ArabicStemTokenFilterFactory.java | 6 +- .../analysis/ArmenianAnalyzerProvider.java | 5 +- .../analysis/BasqueAnalyzerProvider.java | 5 +- .../analysis/BrazilianAnalyzerProvider.java | 5 +- .../BrazilianStemTokenFilterFactory.java | 6 +- .../analysis/BulgarianAnalyzerProvider.java | 5 +- .../analysis/CJKBigramFilterFactory.java | 6 +- .../index/analysis/CJKWidthFilterFactory.java | 5 +- .../analysis/CatalanAnalyzerProvider.java | 5 +- .../analysis/CharFilterFactoryFactory.java | 30 -- .../analysis/ChineseAnalyzerProvider.java | 6 +- .../index/analysis/CjkAnalyzerProvider.java | 5 +- .../index/analysis/ClassicFilterFactory.java | 6 +- .../analysis/ClassicTokenizerFactory.java | 6 +- .../CommonGramsTokenFilterFactory.java | 6 +- .../analysis/CustomAnalyzerProvider.java | 5 +- .../index/analysis/CzechAnalyzerProvider.java | 5 +- .../analysis/CzechStemTokenFilterFactory.java | 6 +- .../analysis/DanishAnalyzerProvider.java | 5 +- .../analysis/DecimalDigitFilterFactory.java | 5 +- .../DelimitedPayloadTokenFilterFactory.java | 7 +- .../index/analysis/DutchAnalyzerProvider.java | 5 +- .../analysis/DutchStemTokenFilterFactory.java | 6 +- .../analysis/EdgeNGramTokenFilterFactory.java | 6 +- .../analysis/EdgeNGramTokenizerFactory.java | 6 +- .../analysis/ElisionTokenFilterFactory.java | 5 +- .../analysis/EnglishAnalyzerProvider.java | 5 +- .../analysis/FinnishAnalyzerProvider.java | 5 +- .../analysis/FrenchAnalyzerProvider.java | 5 +- .../FrenchStemTokenFilterFactory.java | 6 +- .../analysis/GalicianAnalyzerProvider.java | 5 +- .../analysis/GermanAnalyzerProvider.java | 5 +- .../GermanNormalizationFilterFactory.java | 6 +- .../GermanStemTokenFilterFactory.java | 6 +- .../index/analysis/GreekAnalyzerProvider.java | 5 +- .../index/analysis/HindiAnalyzerProvider.java | 5 +- .../HindiNormalizationFilterFactory.java | 6 +- .../analysis/HtmlStripCharFilterFactory.java | 6 +- .../analysis/HungarianAnalyzerProvider.java | 5 +- .../analysis/HunspellTokenFilterFactory.java | 6 +- .../IndicNormalizationFilterFactory.java | 6 +- .../analysis/IndonesianAnalyzerProvider.java | 5 +- .../index/analysis/IrishAnalyzerProvider.java | 5 +- .../analysis/ItalianAnalyzerProvider.java | 5 +- .../analysis/KStemTokenFilterFactory.java | 6 +- .../analysis/KeepTypesFilterFactory.java | 8 +- .../index/analysis/KeepWordFilterFactory.java | 8 +- .../analysis/KeywordAnalyzerProvider.java | 6 +- .../KeywordMarkerTokenFilterFactory.java | 8 +- .../analysis/KeywordTokenizerFactory.java | 6 +- .../analysis/LatvianAnalyzerProvider.java | 5 +- .../analysis/LengthTokenFilterFactory.java | 6 +- .../analysis/LetterTokenizerFactory.java | 6 +- .../LimitTokenCountFilterFactory.java | 5 +- .../analysis/LithuanianAnalyzerProvider.java | 5 +- .../analysis/LowerCaseTokenFilterFactory.java | 6 +- .../analysis/LowerCaseTokenizerFactory.java | 6 +- .../analysis/MappingCharFilterFactory.java | 6 +- .../analysis/NGramTokenFilterFactory.java | 6 +- .../index/analysis/NGramTokenizerFactory.java | 6 +- .../analysis/NorwegianAnalyzerProvider.java | 5 +- .../PathHierarchyTokenizerFactory.java | 6 +- .../analysis/PatternAnalyzerProvider.java | 5 +- ...PatternCaptureGroupTokenFilterFactory.java | 8 +- .../PatternReplaceCharFilterFactory.java | 7 +- .../PatternReplaceTokenFilterFactory.java | 7 +- .../analysis/PatternTokenizerFactory.java | 6 +- .../analysis/PersianAnalyzerProvider.java | 5 +- .../PersianNormalizationFilterFactory.java | 6 +- .../PorterStemTokenFilterFactory.java | 6 +- .../analysis/PortugueseAnalyzerProvider.java | 5 +- .../PreBuiltAnalyzerProviderFactory.java | 13 +- .../PreBuiltCharFilterFactoryFactory.java | 9 +- .../PreBuiltTokenFilterFactoryFactory.java | 9 +- .../PreBuiltTokenizerFactoryFactory.java | 10 +- .../analysis/ReverseTokenFilterFactory.java | 6 +- .../analysis/RomanianAnalyzerProvider.java | 5 +- .../analysis/RussianAnalyzerProvider.java | 5 +- .../RussianStemTokenFilterFactory.java | 6 +- .../ScandinavianFoldingFilterFactory.java | 6 +- ...candinavianNormalizationFilterFactory.java | 6 +- .../SerbianNormalizationFilterFactory.java | 6 +- .../analysis/ShingleTokenFilterFactory.java | 6 +- .../analysis/SimpleAnalyzerProvider.java | 6 +- .../analysis/SnowballAnalyzerProvider.java | 5 +- .../analysis/SnowballTokenFilterFactory.java | 6 +- .../analysis/SoraniAnalyzerProvider.java | 5 +- .../SoraniNormalizationFilterFactory.java | 6 +- .../analysis/SpanishAnalyzerProvider.java | 5 +- .../analysis/StandardAnalyzerProvider.java | 7 +- .../StandardHtmlStripAnalyzerProvider.java | 5 +- .../analysis/StandardTokenFilterFactory.java | 6 +- .../analysis/StandardTokenizerFactory.java | 6 +- .../StemmerOverrideTokenFilterFactory.java | 8 +- .../analysis/StemmerTokenFilterFactory.java | 6 +- .../index/analysis/StopAnalyzerProvider.java | 5 +- .../analysis/StopTokenFilterFactory.java | 5 +- .../analysis/SwedishAnalyzerProvider.java | 5 +- .../analysis/SynonymTokenFilterFactory.java | 22 +- .../index/analysis/ThaiAnalyzerProvider.java | 5 +- .../index/analysis/ThaiTokenizerFactory.java | 6 +- .../analysis/TokenFilterFactoryFactory.java | 30 -- .../analysis/TokenizerFactoryFactory.java | 30 -- .../analysis/TrimTokenFilterFactory.java | 5 +- .../analysis/TruncateTokenFilterFactory.java | 8 +- .../analysis/TurkishAnalyzerProvider.java | 5 +- .../UAX29URLEmailTokenizerFactory.java | 6 +- .../analysis/UniqueTokenFilterFactory.java | 7 +- .../analysis/UpperCaseTokenFilterFactory.java | 6 +- .../analysis/WhitespaceAnalyzerProvider.java | 6 +- .../analysis/WhitespaceTokenizerFactory.java | 6 +- .../WordDelimiterTokenFilterFactory.java | 5 +- ...bstractCompoundWordTokenFilterFactory.java | 5 +- ...tionaryCompoundWordTokenFilterFactory.java | 9 +- ...enationCompoundWordTokenFilterFactory.java | 9 +- .../elasticsearch/indices/IndicesModule.java | 15 - .../elasticsearch/indices/IndicesService.java | 29 +- .../indices/analysis/AnalysisModule.java | 213 ++++++++ .../indices/analysis/HunspellService.java | 2 - .../analysis/IndicesAnalysisService.java | 156 ------ .../analysis/PreBuiltCacheFactory.java | 2 +- .../java/org/elasticsearch/node/Node.java | 2 + .../indices/TransportAnalyzeActionTests.java | 243 +++++++++ .../elasticsearch/index/IndexModuleTests.java | 40 +- .../index/analysis/AnalysisModuleTests.java | 99 ++-- .../index/analysis/AnalysisServiceTests.java | 134 ++++- .../index/analysis/AnalysisTestsHelper.java | 34 +- .../index/analysis/CharFilterTests.java | 27 +- .../index/analysis/CompoundAnalysisTests.java | 31 +- .../analysis/KeepFilterFactoryTests.java | 17 +- .../analysis/NGramTokenizerFactoryTests.java | 28 +- .../PatternCaptureTokenFilterTests.java | 16 +- ...PreBuiltCharFilterFactoryFactoryTests.java | 10 +- ...reBuiltTokenFilterFactoryFactoryTests.java | 18 +- .../PreBuiltTokenizerFactoryFactoryTests.java | 10 +- .../index/analysis/StopAnalyzerTests.java | 18 +- .../index/analysis/StopTokenFilterTests.java | 4 +- .../CommonGramsTokenFilterFactoryTests.java | 5 +- .../filter1/MyFilterTokenFilterFactory.java | 5 +- .../synonyms/SynonymsAnalysisTests.java | 22 +- .../index/engine/InternalEngineTests.java | 2 +- .../index/query/AbstractQueryTestCase.java | 13 +- .../index/query/TemplateQueryParserTests.java | 13 +- .../indices/IndicesModuleTests.java | 9 - .../DummyAnalysisBinderProcessor.java | 47 -- .../indices/analysis/DummyAnalysisPlugin.java | 14 +- .../analysis/DummyIndicesAnalysis.java | 42 -- .../analysis/DummyIndicesAnalysisModule.java | 30 -- .../analysis/IcuAnalysisBinderProcessor.java | 43 -- .../IcuCollationTokenFilterFactory.java | 5 +- .../IcuFoldingTokenFilterFactory.java | 8 +- .../IcuNormalizerCharFilterFactory.java | 7 +- .../IcuNormalizerTokenFilterFactory.java | 4 +- .../index/analysis/IcuTokenizerFactory.java | 6 +- .../IcuTransformTokenFilterFactory.java | 3 +- .../indices/analysis/IcuIndicesAnalysis.java | 128 ----- .../analysis/IcuIndicesAnalysisModule.java | 32 -- .../analysis/icu/AnalysisICUPlugin.java | 21 +- .../index/analysis/AnalysisTestUtils.java | 22 +- .../analysis/SimpleIcuAnalysisTests.java | 4 +- .../JapaneseStopTokenFilterFactory.java | 5 +- .../analysis/KuromojiAnalyzerProvider.java | 3 +- .../KuromojiBaseFormFilterFactory.java | 3 +- ...uromojiIterationMarkCharFilterFactory.java | 7 +- .../KuromojiKatakanaStemmerFactory.java | 3 +- .../KuromojiPartOfSpeechFilterFactory.java | 5 +- .../KuromojiReadingFormFilterFactory.java | 3 +- .../analysis/KuromojiTokenizerFactory.java | 5 +- .../analysis/KuromojiIndicesAnalysis.java | 131 ----- .../KuromojiIndicesAnalysisModule.java | 32 -- .../kuromoji/AnalysisKuromojiPlugin.java | 27 +- .../index/analysis/KuromojiAnalysisTests.java | 17 +- .../test/analysis_kuromoji/10_basic.yaml | 2 +- .../PhoneticAnalysisBinderProcessor.java | 30 -- .../analysis/PhoneticTokenFilterFactory.java | 3 +- .../analysis/AnalysisPhoneticPlugin.java | 6 +- .../analysis/SimplePhoneticAnalysisTests.java | 24 +- .../SmartChineseAnalysisBinderProcessor.java | 43 -- .../SmartChineseAnalyzerProvider.java | 3 +- .../SmartChineseNoOpTokenFilterFactory.java | 4 +- ...SmartChineseTokenizerTokenizerFactory.java | 4 +- .../smartcn/SmartChineseIndicesAnalysis.java | 86 --- .../SmartChineseIndicesAnalysisModule.java | 32 -- .../smartcn/AnalysisSmartChinesePlugin.java | 23 +- .../SimpleSmartChineseAnalysisTests.java | 23 +- .../pl/PolishAnalysisBinderProcessor.java | 36 -- .../analysis/pl/PolishAnalyzerProvider.java | 6 +- .../pl/PolishStemTokenFilterFactory.java | 5 +- .../analysis/pl/PolishIndicesAnalysis.java | 65 --- .../pl/PolishIndicesAnalysisModule.java | 32 -- .../stempel/AnalysisStempelPlugin.java | 18 +- .../index/analysis/PolishAnalysisTests.java | 21 +- .../SimplePolishTokenFilterTests.java | 20 +- 205 files changed, 1693 insertions(+), 2813 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java create mode 100644 core/src/main/java/org/elasticsearch/index/analysis/AnalysisRegistry.java delete mode 100644 core/src/main/java/org/elasticsearch/index/analysis/AnalysisSettingsRequired.java delete mode 100644 core/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java delete mode 100644 core/src/main/java/org/elasticsearch/index/analysis/CharFilterFactoryFactory.java delete mode 100644 core/src/main/java/org/elasticsearch/index/analysis/TokenFilterFactoryFactory.java delete mode 100644 core/src/main/java/org/elasticsearch/index/analysis/TokenizerFactoryFactory.java create mode 100644 core/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java delete mode 100644 core/src/main/java/org/elasticsearch/indices/analysis/IndicesAnalysisService.java create mode 100644 core/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java delete mode 100644 core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisBinderProcessor.java delete mode 100644 core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysis.java delete mode 100644 core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysisModule.java delete mode 100644 plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java delete mode 100644 plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysis.java delete mode 100644 plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysisModule.java delete mode 100644 plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysis.java delete mode 100644 plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysisModule.java delete mode 100644 plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticAnalysisBinderProcessor.java delete mode 100644 plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java delete mode 100644 plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysis.java delete mode 100644 plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysisModule.java delete mode 100644 plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java delete mode 100644 plugins/analysis-stempel/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysis.java delete mode 100644 plugins/analysis-stempel/src/main/java/org/elasticsearch/indices/analysis/pl/PolishIndicesAnalysisModule.java diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java index 4f7a605341e..553c54f805b 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java @@ -24,32 +24,24 @@ import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; import org.apache.lucene.analysis.tokenattributes.TypeAttribute; -import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.single.shard.TransportSingleShardAction; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; -import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.routing.ShardsIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.analysis.CharFilterFactory; -import org.elasticsearch.index.analysis.CharFilterFactoryFactory; -import org.elasticsearch.index.analysis.CustomAnalyzer; -import org.elasticsearch.index.analysis.TokenFilterFactory; -import org.elasticsearch.index.analysis.TokenFilterFactoryFactory; -import org.elasticsearch.index.analysis.TokenizerFactory; -import org.elasticsearch.index.analysis.TokenizerFactoryFactory; +import org.elasticsearch.index.analysis.*; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.internal.AllFieldMapper; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesService; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -63,17 +55,15 @@ import java.util.List; public class TransportAnalyzeAction extends TransportSingleShardAction { private final IndicesService indicesService; - private final IndicesAnalysisService indicesAnalysisService; - - private static final Settings DEFAULT_SETTINGS = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + private final Environment environment; @Inject public TransportAnalyzeAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, - IndicesService indicesService, IndicesAnalysisService indicesAnalysisService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver) { + IndicesService indicesService, ActionFilters actionFilters, + IndexNameExpressionResolver indexNameExpressionResolver, Environment environment) { super(settings, AnalyzeAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver, AnalyzeRequest::new, ThreadPool.Names.INDEX); this.indicesService = indicesService; - this.indicesAnalysisService = indicesAnalysisService; + this.environment = environment; } @Override @@ -105,53 +95,69 @@ public class TransportAnalyzeAction extends TransportSingleShardAction tokenizerFactoryFactory = analysisRegistry.getTokenizerProvider(request.tokenizer()); if (tokenizerFactoryFactory == null) { throw new IllegalArgumentException("failed to find global tokenizer under [" + request.tokenizer() + "]"); } - tokenizerFactory = tokenizerFactoryFactory.create(request.tokenizer(), DEFAULT_SETTINGS); + tokenizerFactory = tokenizerFactoryFactory.get(environment, request.tokenizer()); } else { - tokenizerFactory = indexService.analysisService().tokenizer(request.tokenizer()); + tokenizerFactory = analysisService.tokenizer(request.tokenizer()); if (tokenizerFactory == null) { throw new IllegalArgumentException("failed to find tokenizer under [" + request.tokenizer() + "]"); } @@ -162,14 +168,14 @@ public class TransportAnalyzeAction extends TransportSingleShardAction tokenFilterFactoryFactory = analysisRegistry.getTokenFilterProvider(tokenFilterName); if (tokenFilterFactoryFactory == null) { throw new IllegalArgumentException("failed to find global token filter under [" + tokenFilterName + "]"); } - tokenFilterFactories[i] = tokenFilterFactoryFactory.create(tokenFilterName, DEFAULT_SETTINGS); + tokenFilterFactories[i] = tokenFilterFactoryFactory.get(environment, tokenFilterName); } else { - tokenFilterFactories[i] = indexService.analysisService().tokenFilter(tokenFilterName); + tokenFilterFactories[i] = analysisService.tokenFilter(tokenFilterName); if (tokenFilterFactories[i] == null) { throw new IllegalArgumentException("failed to find token filter under [" + tokenFilterName + "]"); } @@ -185,20 +191,20 @@ public class TransportAnalyzeAction extends TransportSingleShardAction charFilterFactoryFactory = analysisRegistry.getCharFilterProvider(charFilterName); if (charFilterFactoryFactory == null) { throw new IllegalArgumentException("failed to find global char filter under [" + charFilterName + "]"); } - charFilterFactories[i] = charFilterFactoryFactory.create(charFilterName, DEFAULT_SETTINGS); + charFilterFactories[i] = charFilterFactoryFactory.get(environment, charFilterName); } else { - charFilterFactories[i] = indexService.analysisService().charFilter(charFilterName); + charFilterFactories[i] = analysisService.charFilter(charFilterName); if (charFilterFactories[i] == null) { - throw new IllegalArgumentException("failed to find token char under [" + charFilterName + "]"); + throw new IllegalArgumentException("failed to find char filter under [" + charFilterName + "]"); } } if (charFilterFactories[i] == null) { - throw new IllegalArgumentException("failed to find token char under [" + charFilterName + "]"); + throw new IllegalArgumentException("failed to find char filter under [" + charFilterName + "]"); } } } @@ -206,10 +212,10 @@ public class TransportAnalyzeAction extends TransportSingleShardAction engineFactoryImpl = InternalEngineFactory.class; private SetOnce indexSearcherWrapper = new SetOnce<>(); @@ -81,11 +86,12 @@ public final class IndexModule extends AbstractModule { private IndicesWarmer indicesWarmer; - public IndexModule(IndexSettings indexSettings, IndexStoreConfig indexStoreConfig, IndicesQueryCache indicesQueryCache, IndicesWarmer warmer) { + public IndexModule(IndexSettings indexSettings, IndexStoreConfig indexStoreConfig, IndicesQueryCache indicesQueryCache, IndicesWarmer warmer, AnalysisRegistry analysisRegistry) { this.indexStoreConfig = indexStoreConfig; this.indexSettings = indexSettings; this.indicesQueryCache = indicesQueryCache; this.indicesWarmer = warmer; + this.analysisRegistry = analysisRegistry; registerQueryCache(INDEX_QUERY_CACHE, IndexQueryCache::new); registerQueryCache(NONE_QUERY_CACHE, (a, b) -> new NoneQueryCache(a)); } @@ -216,6 +222,11 @@ public final class IndexModule extends AbstractModule { @Override protected void configure() { + try { + bind(AnalysisService.class).toInstance(analysisRegistry.build(indexSettings)); + } catch (IOException e) { + throw new ElasticsearchException("can't create analysis service", e); + } bind(EngineFactory.class).to(engineFactoryImpl).asEagerSingleton(); bind(IndexSearcherWrapperFactory.class).toInstance(indexSearcherWrapper.get() == null ? (shard) -> null : indexSearcherWrapper.get()); bind(IndexEventListener.class).toInstance(freeze()); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java index 7e18e461933..4638a37de17 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/ASCIIFoldingTokenFilterFactory.java @@ -21,9 +21,8 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; /** @@ -32,8 +31,7 @@ import org.elasticsearch.index.IndexSettings; public class ASCIIFoldingTokenFilterFactory extends AbstractTokenFilterFactory { private final boolean preserveOriginal; - @Inject - public ASCIIFoldingTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public ASCIIFoldingTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); preserveOriginal = settings.getAsBoolean("preserve_original", false); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java deleted file mode 100644 index bfa71eefe13..00000000000 --- a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisModule.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.inject.Scopes; -import org.elasticsearch.common.inject.assistedinject.FactoryProvider; -import org.elasticsearch.common.inject.multibindings.MapBinder; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilterFactory; -import org.elasticsearch.index.analysis.compound.HyphenationCompoundWordTokenFilterFactory; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Objects; - -/** - * - */ -public class AnalysisModule extends AbstractModule { - - public static class AnalysisBinderProcessor { - - public void processCharFilters(CharFiltersBindings charFiltersBindings) { - - } - - public static class CharFiltersBindings { - private final Map> charFilters = new HashMap<>(); - - public CharFiltersBindings() { - } - - public void processCharFilter(String name, Class charFilterFactory) { - charFilters.put(name, charFilterFactory); - } - } - - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - - } - - public static class TokenFiltersBindings { - private final Map> tokenFilters = new HashMap<>(); - - public TokenFiltersBindings() { - } - - public void processTokenFilter(String name, Class tokenFilterFactory) { - tokenFilters.put(name, tokenFilterFactory); - } - } - - public void processTokenizers(TokenizersBindings tokenizersBindings) { - - } - - public static class TokenizersBindings { - private final Map> tokenizers = new HashMap<>(); - - public TokenizersBindings() { - } - - public void processTokenizer(String name, Class tokenizerFactory) { - tokenizers.put(name, tokenizerFactory); - } - } - - public void processAnalyzers(AnalyzersBindings analyzersBindings) { - - } - - public static class AnalyzersBindings { - private final Map> analyzers = new HashMap<>(); - - public AnalyzersBindings() { - } - - public void processAnalyzer(String name, Class analyzerProvider) { - analyzers.put(name, analyzerProvider); - } - } - } - - private final Settings settings; - - private final IndicesAnalysisService indicesAnalysisService; - - private final LinkedList processors = new LinkedList<>(); - - private final Map> charFilters = new HashMap<>(); - private final Map> tokenFilters = new HashMap<>(); - private final Map> tokenizers = new HashMap<>(); - private final Map> analyzers = new HashMap<>(); - - public AnalysisModule(Settings settings, IndicesAnalysisService indicesAnalysisService) { - Objects.requireNonNull(indicesAnalysisService); - this.settings = settings; - this.indicesAnalysisService = indicesAnalysisService; - processors.add(new DefaultProcessor()); - try { - processors.add(new ExtendedProcessor()); - } catch (Throwable t) { - // ignore. no extended ones - } - } - - public AnalysisModule addProcessor(AnalysisBinderProcessor processor) { - processors.addFirst(processor); - return this; - } - - public AnalysisModule addCharFilter(String name, Class charFilter) { - charFilters.put(name, charFilter); - return this; - } - - public AnalysisModule addTokenFilter(String name, Class tokenFilter) { - tokenFilters.put(name, tokenFilter); - return this; - } - - public AnalysisModule addTokenizer(String name, Class tokenizer) { - tokenizers.put(name, tokenizer); - return this; - } - - public AnalysisModule addAnalyzer(String name, Class analyzer) { - analyzers.put(name, analyzer); - return this; - } - - @Override - protected void configure() { - MapBinder charFilterBinder - = MapBinder.newMapBinder(binder(), String.class, CharFilterFactoryFactory.class); - - // CHAR FILTERS - - AnalysisBinderProcessor.CharFiltersBindings charFiltersBindings = new AnalysisBinderProcessor.CharFiltersBindings(); - for (AnalysisBinderProcessor processor : processors) { - processor.processCharFilters(charFiltersBindings); - } - charFiltersBindings.charFilters.putAll(charFilters); - - Map charFiltersSettings = settings.getGroups("index.analysis.char_filter"); - for (Map.Entry entry : charFiltersSettings.entrySet()) { - String charFilterName = entry.getKey(); - Settings charFilterSettings = entry.getValue(); - - String typeName = charFilterSettings.get("type"); - if (typeName == null) { - throw new IllegalArgumentException("CharFilter [" + charFilterName + "] must have a type associated with it"); - } - Class type = charFiltersBindings.charFilters.get(typeName); - if (type == null) { - throw new IllegalArgumentException("Unknown CharFilter type [" + typeName + "] for [" + charFilterName + "]"); - } - charFilterBinder.addBinding(charFilterName).toProvider(FactoryProvider.newFactory(CharFilterFactoryFactory.class, type)).in(Scopes.SINGLETON); - } - // go over the char filters in the bindings and register the ones that are not configured - for (Map.Entry> entry : charFiltersBindings.charFilters.entrySet()) { - String charFilterName = entry.getKey(); - Class clazz = entry.getValue(); - // we don't want to re-register one that already exists - if (charFiltersSettings.containsKey(charFilterName)) { - continue; - } - // check, if it requires settings, then don't register it, we know default has no settings... - if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) { - continue; - } - // register if it's not builtin - if (indicesAnalysisService.hasCharFilter(charFilterName) == false) { - charFilterBinder.addBinding(charFilterName).toProvider(FactoryProvider.newFactory(CharFilterFactoryFactory.class, clazz)).in(Scopes.SINGLETON); - } - } - - - // TOKEN FILTERS - - MapBinder tokenFilterBinder - = MapBinder.newMapBinder(binder(), String.class, TokenFilterFactoryFactory.class); - - // initial default bindings - AnalysisBinderProcessor.TokenFiltersBindings tokenFiltersBindings = new AnalysisBinderProcessor.TokenFiltersBindings(); - for (AnalysisBinderProcessor processor : processors) { - processor.processTokenFilters(tokenFiltersBindings); - } - tokenFiltersBindings.tokenFilters.putAll(tokenFilters); - - Map tokenFiltersSettings = settings.getGroups("index.analysis.filter"); - for (Map.Entry entry : tokenFiltersSettings.entrySet()) { - String tokenFilterName = entry.getKey(); - Settings tokenFilterSettings = entry.getValue(); - - String typeName = tokenFilterSettings.get("type"); - if (typeName == null) { - throw new IllegalArgumentException("TokenFilter [" + tokenFilterName + "] must have a type associated with it"); - } - Class type = tokenFiltersBindings.tokenFilters.get(typeName); - if (type == null) { - throw new IllegalArgumentException("Unknown TokenFilter type [" + typeName + "] for [" + tokenFilterName + "]"); - } - tokenFilterBinder.addBinding(tokenFilterName).toProvider(FactoryProvider.newFactory(TokenFilterFactoryFactory.class, type)).in(Scopes.SINGLETON); - } - // go over the filters in the bindings and register the ones that are not configured - for (Map.Entry> entry : tokenFiltersBindings.tokenFilters.entrySet()) { - String tokenFilterName = entry.getKey(); - Class clazz = entry.getValue(); - // we don't want to re-register one that already exists - if (tokenFiltersSettings.containsKey(tokenFilterName)) { - continue; - } - // check, if it requires settings, then don't register it, we know default has no settings... - if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) { - continue; - } - // register if it's not builtin - if (indicesAnalysisService.hasTokenFilter(tokenFilterName) == false) { - tokenFilterBinder.addBinding(tokenFilterName).toProvider(FactoryProvider.newFactory(TokenFilterFactoryFactory.class, clazz)).in(Scopes.SINGLETON); - } - } - - // TOKENIZER - - MapBinder tokenizerBinder - = MapBinder.newMapBinder(binder(), String.class, TokenizerFactoryFactory.class); - - // initial default bindings - AnalysisBinderProcessor.TokenizersBindings tokenizersBindings = new AnalysisBinderProcessor.TokenizersBindings(); - for (AnalysisBinderProcessor processor : processors) { - processor.processTokenizers(tokenizersBindings); - } - tokenizersBindings.tokenizers.putAll(tokenizers); - - Map tokenizersSettings = settings.getGroups("index.analysis.tokenizer"); - for (Map.Entry entry : tokenizersSettings.entrySet()) { - String tokenizerName = entry.getKey(); - Settings tokenizerSettings = entry.getValue(); - - String typeName = tokenizerSettings.get("type"); - if (typeName == null) { - throw new IllegalArgumentException("Tokenizer [" + tokenizerName + "] must have a type associated with it"); - } - Class type = tokenizersBindings.tokenizers.get(typeName); - if (type == null) { - throw new IllegalArgumentException("Unknown Tokenizer type [" + typeName + "] for [" + tokenizerName + "]"); - } - tokenizerBinder.addBinding(tokenizerName).toProvider(FactoryProvider.newFactory(TokenizerFactoryFactory.class, type)).in(Scopes.SINGLETON); - } - // go over the tokenizers in the bindings and register the ones that are not configured - for (Map.Entry> entry : tokenizersBindings.tokenizers.entrySet()) { - String tokenizerName = entry.getKey(); - Class clazz = entry.getValue(); - // we don't want to re-register one that already exists - if (tokenizersSettings.containsKey(tokenizerName)) { - continue; - } - // check, if it requires settings, then don't register it, we know default has no settings... - if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) { - continue; - } - // register if it's not builtin - if (indicesAnalysisService.hasTokenizer(tokenizerName) == false) { - tokenizerBinder.addBinding(tokenizerName).toProvider(FactoryProvider.newFactory(TokenizerFactoryFactory.class, clazz)).in(Scopes.SINGLETON); - } - } - - // ANALYZER - - MapBinder analyzerBinder - = MapBinder.newMapBinder(binder(), String.class, AnalyzerProviderFactory.class); - - // initial default bindings - AnalysisBinderProcessor.AnalyzersBindings analyzersBindings = new AnalysisBinderProcessor.AnalyzersBindings(); - for (AnalysisBinderProcessor processor : processors) { - processor.processAnalyzers(analyzersBindings); - } - analyzersBindings.analyzers.putAll(analyzers); - - Map analyzersSettings = settings.getGroups("index.analysis.analyzer"); - for (Map.Entry entry : analyzersSettings.entrySet()) { - String analyzerName = entry.getKey(); - Settings analyzerSettings = entry.getValue(); - - String typeName = analyzerSettings.get("type"); - Class type; - if (typeName == null) { - if (analyzerSettings.get("tokenizer") != null) { - // custom analyzer, need to add it - type = CustomAnalyzerProvider.class; - } else { - throw new IllegalArgumentException("Analyzer [" + analyzerName + "] must have a type associated with it"); - } - } else if (typeName.equals("custom")) { - type = CustomAnalyzerProvider.class; - } else { - type = analyzersBindings.analyzers.get(typeName); - if (type == null) { - throw new IllegalArgumentException("Unknown Analyzer type [" + typeName + "] for [" + analyzerName + "]"); - } - } - - analyzerBinder.addBinding(analyzerName).toProvider(FactoryProvider.newFactory(AnalyzerProviderFactory.class, type)).in(Scopes.SINGLETON); - } - - // go over the analyzers in the bindings and register the ones that are not configured - for (Map.Entry> entry : analyzersBindings.analyzers.entrySet()) { - String analyzerName = entry.getKey(); - Class clazz = entry.getValue(); - // we don't want to re-register one that already exists - if (analyzersSettings.containsKey(analyzerName)) { - continue; - } - // check, if it requires settings, then don't register it, we know default has no settings... - if (clazz.getAnnotation(AnalysisSettingsRequired.class) != null) { - continue; - } - // register if it's not builtin - if (indicesAnalysisService.hasAnalyzer(analyzerName) == false) { - analyzerBinder.addBinding(analyzerName).toProvider(FactoryProvider.newFactory(AnalyzerProviderFactory.class, clazz)).in(Scopes.SINGLETON); - } - } - - bind(AnalysisService.class).in(Scopes.SINGLETON); - } - - private static class DefaultProcessor extends AnalysisBinderProcessor { - - @Override - public void processCharFilters(CharFiltersBindings charFiltersBindings) { - charFiltersBindings.processCharFilter("html_strip", HtmlStripCharFilterFactory.class); - charFiltersBindings.processCharFilter("pattern_replace", PatternReplaceCharFilterFactory.class); - } - - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - tokenFiltersBindings.processTokenFilter("stop", StopTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("reverse", ReverseTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("asciifolding", ASCIIFoldingTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("length", LengthTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("lowercase", LowerCaseTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("uppercase", UpperCaseTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("porter_stem", PorterStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("kstem", KStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("standard", StandardTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("nGram", NGramTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("ngram", NGramTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("edgeNGram", EdgeNGramTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("edge_ngram", EdgeNGramTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("shingle", ShingleTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("unique", UniqueTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("truncate", TruncateTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("trim", TrimTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("limit", LimitTokenCountFilterFactory.class); - tokenFiltersBindings.processTokenFilter("common_grams", CommonGramsTokenFilterFactory.class); - } - - @Override - public void processTokenizers(TokenizersBindings tokenizersBindings) { - tokenizersBindings.processTokenizer("standard", StandardTokenizerFactory.class); - tokenizersBindings.processTokenizer("uax_url_email", UAX29URLEmailTokenizerFactory.class); - tokenizersBindings.processTokenizer("path_hierarchy", PathHierarchyTokenizerFactory.class); - tokenizersBindings.processTokenizer("keyword", KeywordTokenizerFactory.class); - tokenizersBindings.processTokenizer("letter", LetterTokenizerFactory.class); - tokenizersBindings.processTokenizer("lowercase", LowerCaseTokenizerFactory.class); - tokenizersBindings.processTokenizer("whitespace", WhitespaceTokenizerFactory.class); - - tokenizersBindings.processTokenizer("nGram", NGramTokenizerFactory.class); - tokenizersBindings.processTokenizer("ngram", NGramTokenizerFactory.class); - tokenizersBindings.processTokenizer("edgeNGram", EdgeNGramTokenizerFactory.class); - tokenizersBindings.processTokenizer("edge_ngram", EdgeNGramTokenizerFactory.class); - } - - @Override - public void processAnalyzers(AnalyzersBindings analyzersBindings) { - analyzersBindings.processAnalyzer("default", StandardAnalyzerProvider.class); - analyzersBindings.processAnalyzer("standard", StandardAnalyzerProvider.class); - analyzersBindings.processAnalyzer("standard_html_strip", StandardHtmlStripAnalyzerProvider.class); - analyzersBindings.processAnalyzer("simple", SimpleAnalyzerProvider.class); - analyzersBindings.processAnalyzer("stop", StopAnalyzerProvider.class); - analyzersBindings.processAnalyzer("whitespace", WhitespaceAnalyzerProvider.class); - analyzersBindings.processAnalyzer("keyword", KeywordAnalyzerProvider.class); - } - } - - private static class ExtendedProcessor extends AnalysisBinderProcessor { - @Override - public void processCharFilters(CharFiltersBindings charFiltersBindings) { - charFiltersBindings.processCharFilter("mapping", MappingCharFilterFactory.class); - } - - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - tokenFiltersBindings.processTokenFilter("snowball", SnowballTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("stemmer", StemmerTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("word_delimiter", WordDelimiterTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("delimited_payload_filter", DelimitedPayloadTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("synonym", SynonymTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("elision", ElisionTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("keep", KeepWordFilterFactory.class); - tokenFiltersBindings.processTokenFilter("keep_types", KeepTypesFilterFactory.class); - - tokenFiltersBindings.processTokenFilter("pattern_capture", PatternCaptureGroupTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("pattern_replace", PatternReplaceTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("dictionary_decompounder", DictionaryCompoundWordTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("hyphenation_decompounder", HyphenationCompoundWordTokenFilterFactory.class); - - tokenFiltersBindings.processTokenFilter("arabic_stem", ArabicStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("brazilian_stem", BrazilianStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("czech_stem", CzechStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("dutch_stem", DutchStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("french_stem", FrenchStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("german_stem", GermanStemTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("russian_stem", RussianStemTokenFilterFactory.class); - - tokenFiltersBindings.processTokenFilter("keyword_marker", KeywordMarkerTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("stemmer_override", StemmerOverrideTokenFilterFactory.class); - - tokenFiltersBindings.processTokenFilter("arabic_normalization", ArabicNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("german_normalization", GermanNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("hindi_normalization", HindiNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("indic_normalization", IndicNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("sorani_normalization", SoraniNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("persian_normalization", PersianNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("scandinavian_normalization", ScandinavianNormalizationFilterFactory.class); - tokenFiltersBindings.processTokenFilter("scandinavian_folding", ScandinavianFoldingFilterFactory.class); - tokenFiltersBindings.processTokenFilter("serbian_normalization", SerbianNormalizationFilterFactory.class); - - tokenFiltersBindings.processTokenFilter("hunspell", HunspellTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("cjk_bigram", CJKBigramFilterFactory.class); - tokenFiltersBindings.processTokenFilter("cjk_width", CJKWidthFilterFactory.class); - - tokenFiltersBindings.processTokenFilter("apostrophe", ApostropheFilterFactory.class); - tokenFiltersBindings.processTokenFilter("classic", ClassicFilterFactory.class); - tokenFiltersBindings.processTokenFilter("decimal_digit", DecimalDigitFilterFactory.class); - } - - @Override - public void processTokenizers(TokenizersBindings tokenizersBindings) { - tokenizersBindings.processTokenizer("pattern", PatternTokenizerFactory.class); - tokenizersBindings.processTokenizer("classic", ClassicTokenizerFactory.class); - tokenizersBindings.processTokenizer("thai", ThaiTokenizerFactory.class); - } - - @Override - public void processAnalyzers(AnalyzersBindings analyzersBindings) { - analyzersBindings.processAnalyzer("pattern", PatternAnalyzerProvider.class); - analyzersBindings.processAnalyzer("snowball", SnowballAnalyzerProvider.class); - - analyzersBindings.processAnalyzer("arabic", ArabicAnalyzerProvider.class); - analyzersBindings.processAnalyzer("armenian", ArmenianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("basque", BasqueAnalyzerProvider.class); - analyzersBindings.processAnalyzer("brazilian", BrazilianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("bulgarian", BulgarianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("catalan", CatalanAnalyzerProvider.class); - analyzersBindings.processAnalyzer("chinese", ChineseAnalyzerProvider.class); - analyzersBindings.processAnalyzer("cjk", CjkAnalyzerProvider.class); - analyzersBindings.processAnalyzer("czech", CzechAnalyzerProvider.class); - analyzersBindings.processAnalyzer("danish", DanishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("dutch", DutchAnalyzerProvider.class); - analyzersBindings.processAnalyzer("english", EnglishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("finnish", FinnishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("french", FrenchAnalyzerProvider.class); - analyzersBindings.processAnalyzer("galician", GalicianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("german", GermanAnalyzerProvider.class); - analyzersBindings.processAnalyzer("greek", GreekAnalyzerProvider.class); - analyzersBindings.processAnalyzer("hindi", HindiAnalyzerProvider.class); - analyzersBindings.processAnalyzer("hungarian", HungarianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("indonesian", IndonesianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("irish", IrishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("italian", ItalianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("latvian", LatvianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("lithuanian", LithuanianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("norwegian", NorwegianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("persian", PersianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("portuguese", PortugueseAnalyzerProvider.class); - analyzersBindings.processAnalyzer("romanian", RomanianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("russian", RussianAnalyzerProvider.class); - analyzersBindings.processAnalyzer("sorani", SoraniAnalyzerProvider.class); - analyzersBindings.processAnalyzer("spanish", SpanishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("swedish", SwedishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("turkish", TurkishAnalyzerProvider.class); - analyzersBindings.processAnalyzer("thai", ThaiAnalyzerProvider.class); - } - } -} diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisRegistry.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisRegistry.java new file mode 100644 index 00000000000..4e7b66dec8f --- /dev/null +++ b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisRegistry.java @@ -0,0 +1,461 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; + +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.util.IOUtils; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilterFactory; +import org.elasticsearch.index.analysis.compound.HyphenationCompoundWordTokenFilterFactory; +import org.elasticsearch.indices.analysis.*; + +import java.io.Closeable; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +/** + * An internal registry for tokenizer, token filter, char filter and analyzer. + * This class exists per node and allows to create per-index {@link AnalysisService} via {@link #build(IndexSettings)} + */ +public final class AnalysisRegistry implements Closeable { + private final Map> charFilters; + private final Map> tokenFilters; + private final Map> tokenizers; + private final Map> analyzers; + private final Map cachedAnalyzer = new ConcurrentHashMap<>(); + private final PrebuiltAnalysis prebuiltAnalysis; + private final HunspellService hunspellService; + private final Environment environemnt; + + public AnalysisRegistry(HunspellService hunspellService, Environment environment) { + this(hunspellService, environment, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP); + } + + public AnalysisRegistry(HunspellService hunspellService, Environment environment, + Map> charFilters, + Map> tokenFilters, + Map> tokenizers, + Map> analyzers) { + prebuiltAnalysis = new PrebuiltAnalysis(); + this.hunspellService = hunspellService; + this.environemnt = environment; + final Map> charFilterBuilder = new HashMap<>(charFilters); + final Map> tokenFilterBuilder = new HashMap<>(tokenFilters); + final Map> tokenizerBuilder = new HashMap<>(tokenizers); + final Map> analyzerBuilder= new HashMap<>(analyzers); + registerBuiltInAnalyzer(analyzerBuilder); + registerBuiltInCharFilter(charFilterBuilder); + registerBuiltInTokenizer(tokenizerBuilder); + registerBuiltInTokenFilters(tokenFilterBuilder); + this.tokenFilters = Collections.unmodifiableMap(tokenFilterBuilder); + this.tokenizers = Collections.unmodifiableMap(tokenizerBuilder); + this.charFilters = Collections.unmodifiableMap(charFilterBuilder); + this.analyzers = Collections.unmodifiableMap(analyzerBuilder); + } + + /** + * Returns a registered {@link TokenizerFactory} provider by name or null if the tokenizer was not registered + */ + public AnalysisModule.AnalysisProvider getTokenizerProvider(String tokenizer) { + return tokenizers.getOrDefault(tokenizer, this.prebuiltAnalysis.getTokenizerFactory(tokenizer)); + } + + /** + * Returns a registered {@link TokenFilterFactory} provider by name or null if the token filter was not registered + */ + public AnalysisModule.AnalysisProvider getTokenFilterProvider(String tokenFilter) { + return tokenFilters.getOrDefault(tokenFilter, this.prebuiltAnalysis.getTokenFilterFactory(tokenFilter)); + } + + /** + * Returns a registered {@link CharFilterFactory} provider by name or null if the char filter was not registered + */ + public AnalysisModule.AnalysisProvider getCharFilterProvider(String charFilter) { + return charFilters.getOrDefault(charFilter, this.prebuiltAnalysis.getCharFilterFactory(charFilter)); + } + + /** + * Returns a registered {@link Analyzer} provider by name or null if the analyzer was not registered + */ + public Analyzer getAnalyzer(String analyzer) throws IOException { + AnalysisModule.AnalysisProvider analyzerProvider = this.prebuiltAnalysis.getAnalyzerProvider(analyzer); + if (analyzerProvider == null) { + AnalysisModule.AnalysisProvider provider = analyzers.get(analyzer); + return provider == null ? null : cachedAnalyzer.computeIfAbsent(analyzer, (key) -> { + try { + return provider.get(environemnt, key).get(); + } catch (IOException ex) { + throw new ElasticsearchException("failed to load analyzer for name " + key, ex); + }} + ); + } + return analyzerProvider.get(environemnt, analyzer).get(); + } + + @Override + public void close() throws IOException { + try { + prebuiltAnalysis.close(); + } finally { + IOUtils.close(cachedAnalyzer.values()); + } + } + + /** + * Creates an index-level {@link AnalysisService} from this registry using the given index settings + */ + public AnalysisService build(IndexSettings indexSettings) throws IOException { + final Map charFiltersSettings = indexSettings.getSettings().getGroups("index.analysis.char_filter"); + final Map tokenFiltersSettings = indexSettings.getSettings().getGroups("index.analysis.filter"); + final Map tokenizersSettings = indexSettings.getSettings().getGroups("index.analysis.tokenizer"); + final Map analyzersSettings = indexSettings.getSettings().getGroups("index.analysis.analyzer"); + + final Map charFilterFactories = buildMapping(false, "charfilter", indexSettings, charFiltersSettings, charFilters, prebuiltAnalysis.charFilterFactories); + final Map tokenizerFactories = buildMapping(false, "tokenizer", indexSettings, tokenizersSettings, tokenizers, prebuiltAnalysis.tokenizerFactories); + + Map> tokenFilters = new HashMap<>(this.tokenFilters); + /* + * synonym is different than everything else since it needs access to the tokenizer factories for this index. + * instead of building the infrastructure for plugins we rather make it a real exception to not pollute the general interface and + * hide internal data-structures as much as possible. + */ + tokenFilters.put("synonym", requriesAnalysisSettings((is, env, name, settings) -> new SynonymTokenFilterFactory(is, env, tokenizerFactories, name, settings))); + final Map tokenFilterFactories = buildMapping(false, "tokenfilter", indexSettings, tokenFiltersSettings, Collections.unmodifiableMap(tokenFilters), prebuiltAnalysis.tokenFilterFactories); + final Map analyzierFactories = buildMapping(true, "analyzer", indexSettings, analyzersSettings, analyzers, prebuiltAnalysis.analyzerProviderFactories); + return new AnalysisService(indexSettings, analyzierFactories, tokenizerFactories, charFilterFactories, tokenFilterFactories); + } + + + private static AnalysisModule.AnalysisProvider requriesAnalysisSettings(AnalysisModule.AnalysisProvider provider) { + return new AnalysisModule.AnalysisProvider() { + @Override + public T get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException { + return provider.get(indexSettings, environment, name, settings); + } + @Override + public boolean requiresAnalysisSettings() { + return true; + } + }; + } + + private void registerBuiltInCharFilter(Map> charFilters) { + charFilters.put("html_strip", HtmlStripCharFilterFactory::new); + charFilters.put("pattern_replace", requriesAnalysisSettings(PatternReplaceCharFilterFactory::new)); + charFilters.put("mapping", requriesAnalysisSettings(MappingCharFilterFactory::new)); + } + + private void registerBuiltInTokenizer(Map> tokenizers) { + tokenizers.put("standard", StandardTokenizerFactory::new); + tokenizers.put("uax_url_email", UAX29URLEmailTokenizerFactory::new); + tokenizers.put("path_hierarchy", PathHierarchyTokenizerFactory::new); + tokenizers.put("keyword", KeywordTokenizerFactory::new); + tokenizers.put("letter", LetterTokenizerFactory::new); + tokenizers.put("lowercase", LowerCaseTokenizerFactory::new); + tokenizers.put("whitespace", WhitespaceTokenizerFactory::new); + tokenizers.put("nGram", NGramTokenizerFactory::new); + tokenizers.put("ngram", NGramTokenizerFactory::new); + tokenizers.put("edgeNGram", EdgeNGramTokenizerFactory::new); + tokenizers.put("edge_ngram", EdgeNGramTokenizerFactory::new); + tokenizers.put("pattern", PatternTokenizerFactory::new); + tokenizers.put("classic", ClassicTokenizerFactory::new); + tokenizers.put("thai", ThaiTokenizerFactory::new); + } + + private void registerBuiltInTokenFilters(Map> tokenFilters) { + tokenFilters.put("stop", StopTokenFilterFactory::new); + tokenFilters.put("reverse", ReverseTokenFilterFactory::new); + tokenFilters.put("asciifolding", ASCIIFoldingTokenFilterFactory::new); + tokenFilters.put("length", LengthTokenFilterFactory::new); + tokenFilters.put("lowercase", LowerCaseTokenFilterFactory::new); + tokenFilters.put("uppercase", UpperCaseTokenFilterFactory::new); + tokenFilters.put("porter_stem", PorterStemTokenFilterFactory::new); + tokenFilters.put("kstem", KStemTokenFilterFactory::new); + tokenFilters.put("standard", StandardTokenFilterFactory::new); + tokenFilters.put("nGram", NGramTokenFilterFactory::new); + tokenFilters.put("ngram", NGramTokenFilterFactory::new); + tokenFilters.put("edgeNGram", EdgeNGramTokenFilterFactory::new); + tokenFilters.put("edge_ngram", EdgeNGramTokenFilterFactory::new); + tokenFilters.put("shingle", ShingleTokenFilterFactory::new); + tokenFilters.put("unique", UniqueTokenFilterFactory::new); + tokenFilters.put("truncate", requriesAnalysisSettings(TruncateTokenFilterFactory::new)); + tokenFilters.put("trim", TrimTokenFilterFactory::new); + tokenFilters.put("limit", LimitTokenCountFilterFactory::new); + tokenFilters.put("common_grams", requriesAnalysisSettings(CommonGramsTokenFilterFactory::new)); + tokenFilters.put("snowball", SnowballTokenFilterFactory::new); + tokenFilters.put("stemmer", StemmerTokenFilterFactory::new); + tokenFilters.put("word_delimiter", WordDelimiterTokenFilterFactory::new); + tokenFilters.put("delimited_payload_filter", DelimitedPayloadTokenFilterFactory::new); + tokenFilters.put("elision", ElisionTokenFilterFactory::new); + tokenFilters.put("keep", requriesAnalysisSettings(KeepWordFilterFactory::new)); + tokenFilters.put("keep_types", requriesAnalysisSettings(KeepTypesFilterFactory::new)); + tokenFilters.put("pattern_capture", requriesAnalysisSettings(PatternCaptureGroupTokenFilterFactory::new)); + tokenFilters.put("pattern_replace", requriesAnalysisSettings(PatternReplaceTokenFilterFactory::new)); + tokenFilters.put("dictionary_decompounder", requriesAnalysisSettings(DictionaryCompoundWordTokenFilterFactory::new)); + tokenFilters.put("hyphenation_decompounder", requriesAnalysisSettings(HyphenationCompoundWordTokenFilterFactory::new)); + tokenFilters.put("arabic_stem", ArabicStemTokenFilterFactory::new); + tokenFilters.put("brazilian_stem", BrazilianStemTokenFilterFactory::new); + tokenFilters.put("czech_stem", CzechStemTokenFilterFactory::new); + tokenFilters.put("dutch_stem", DutchStemTokenFilterFactory::new); + tokenFilters.put("french_stem", FrenchStemTokenFilterFactory::new); + tokenFilters.put("german_stem", GermanStemTokenFilterFactory::new); + tokenFilters.put("russian_stem", RussianStemTokenFilterFactory::new); + tokenFilters.put("keyword_marker", requriesAnalysisSettings(KeywordMarkerTokenFilterFactory::new)); + tokenFilters.put("stemmer_override", requriesAnalysisSettings(StemmerOverrideTokenFilterFactory::new)); + tokenFilters.put("arabic_normalization", ArabicNormalizationFilterFactory::new); + tokenFilters.put("german_normalization", GermanNormalizationFilterFactory::new); + tokenFilters.put("hindi_normalization", HindiNormalizationFilterFactory::new); + tokenFilters.put("indic_normalization", IndicNormalizationFilterFactory::new); + tokenFilters.put("sorani_normalization", SoraniNormalizationFilterFactory::new); + tokenFilters.put("persian_normalization", PersianNormalizationFilterFactory::new); + tokenFilters.put("scandinavian_normalization", ScandinavianNormalizationFilterFactory::new); + tokenFilters.put("scandinavian_folding", ScandinavianFoldingFilterFactory::new); + tokenFilters.put("serbian_normalization", SerbianNormalizationFilterFactory::new); + + if (hunspellService != null) { + tokenFilters.put("hunspell", requriesAnalysisSettings((indexSettings, env, name, settings) -> new HunspellTokenFilterFactory(indexSettings, name, settings, hunspellService))); + } + tokenFilters.put("cjk_bigram", CJKBigramFilterFactory::new); + tokenFilters.put("cjk_width", CJKWidthFilterFactory::new); + + tokenFilters.put("apostrophe", ApostropheFilterFactory::new); + tokenFilters.put("classic", ClassicFilterFactory::new); + tokenFilters.put("decimal_digit", DecimalDigitFilterFactory::new); + } + + private void registerBuiltInAnalyzer(Map> analyzers) { + analyzers.put("default", StandardAnalyzerProvider::new); + analyzers.put("standard", StandardAnalyzerProvider::new); + analyzers.put("standard_html_strip", StandardHtmlStripAnalyzerProvider::new); + analyzers.put("simple", SimpleAnalyzerProvider::new); + analyzers.put("stop", StopAnalyzerProvider::new); + analyzers.put("whitespace", WhitespaceAnalyzerProvider::new); + analyzers.put("keyword", KeywordAnalyzerProvider::new); + analyzers.put("pattern", PatternAnalyzerProvider::new); + analyzers.put("snowball", SnowballAnalyzerProvider::new); + analyzers.put("arabic", ArabicAnalyzerProvider::new); + analyzers.put("armenian", ArmenianAnalyzerProvider::new); + analyzers.put("basque", BasqueAnalyzerProvider::new); + analyzers.put("brazilian", BrazilianAnalyzerProvider::new); + analyzers.put("bulgarian", BulgarianAnalyzerProvider::new); + analyzers.put("catalan", CatalanAnalyzerProvider::new); + analyzers.put("chinese", ChineseAnalyzerProvider::new); + analyzers.put("cjk", CjkAnalyzerProvider::new); + analyzers.put("czech", CzechAnalyzerProvider::new); + analyzers.put("danish", DanishAnalyzerProvider::new); + analyzers.put("dutch", DutchAnalyzerProvider::new); + analyzers.put("english", EnglishAnalyzerProvider::new); + analyzers.put("finnish", FinnishAnalyzerProvider::new); + analyzers.put("french", FrenchAnalyzerProvider::new); + analyzers.put("galician", GalicianAnalyzerProvider::new); + analyzers.put("german", GermanAnalyzerProvider::new); + analyzers.put("greek", GreekAnalyzerProvider::new); + analyzers.put("hindi", HindiAnalyzerProvider::new); + analyzers.put("hungarian", HungarianAnalyzerProvider::new); + analyzers.put("indonesian", IndonesianAnalyzerProvider::new); + analyzers.put("irish", IrishAnalyzerProvider::new); + analyzers.put("italian", ItalianAnalyzerProvider::new); + analyzers.put("latvian", LatvianAnalyzerProvider::new); + analyzers.put("lithuanian", LithuanianAnalyzerProvider::new); + analyzers.put("norwegian", NorwegianAnalyzerProvider::new); + analyzers.put("persian", PersianAnalyzerProvider::new); + analyzers.put("portuguese", PortugueseAnalyzerProvider::new); + analyzers.put("romanian", RomanianAnalyzerProvider::new); + analyzers.put("russian", RussianAnalyzerProvider::new); + analyzers.put("sorani", SoraniAnalyzerProvider::new); + analyzers.put("spanish", SpanishAnalyzerProvider::new); + analyzers.put("swedish", SwedishAnalyzerProvider::new); + analyzers.put("turkish", TurkishAnalyzerProvider::new); + analyzers.put("thai", ThaiAnalyzerProvider::new); + } + + private Map buildMapping(boolean analyzer, String toBuild, IndexSettings settings, Map settingsMap, Map> providerMap, Map> defaultInstance) throws IOException { + Settings defaultSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, settings.getIndexVersionCreated()).build(); + Map factories = new HashMap<>(); + for (Map.Entry entry : settingsMap.entrySet()) { + String name = entry.getKey(); + Settings currentSettings = entry.getValue(); + String typeName = currentSettings.get("type"); + if (analyzer) { + T factory; + if (typeName == null) { + if (currentSettings.get("tokenizer") != null) { + factory = (T) new CustomAnalyzerProvider(settings, name, currentSettings); + } else { + throw new IllegalArgumentException(toBuild + " [" + name + "] must have a type associated with it"); + } + } else if (typeName.equals("custom")) { + factory = (T) new CustomAnalyzerProvider(settings, name, currentSettings); + } else { + AnalysisModule.AnalysisProvider type = providerMap.get(typeName); + if (type == null) { + throw new IllegalArgumentException("Unknown " + toBuild + " type [" + typeName + "] for [" + name + "]"); + } + factory = type.get(settings, environemnt, name, currentSettings); + } + factories.put(name, factory); + } else { + if (typeName == null) { + throw new IllegalArgumentException(toBuild + " [" + name + "] must have a type associated with it"); + } + AnalysisModule.AnalysisProvider type = providerMap.get(typeName); + if (type == null) { + throw new IllegalArgumentException("Unknown " + toBuild + " type [" + typeName + "] for [" + name + "]"); + } + final T factory = type.get(settings, environemnt, name, currentSettings); + factories.put(name, factory); + } + + } + // go over the char filters in the bindings and register the ones that are not configured + for (Map.Entry> entry : providerMap.entrySet()) { + String name = entry.getKey(); + AnalysisModule.AnalysisProvider provider = entry.getValue(); + // we don't want to re-register one that already exists + if (settingsMap.containsKey(name)) { + continue; + } + // check, if it requires settings, then don't register it, we know default has no settings... + if (provider.requiresAnalysisSettings()) { + continue; + } + AnalysisModule.AnalysisProvider defaultProvider = defaultInstance.get(name); + final T instance; + if (defaultProvider == null) { + instance = provider.get(settings, environemnt, name, defaultSettings); + } else { + instance = defaultProvider.get(settings, environemnt, name, defaultSettings); + } + factories.put(name, instance); + String camelCase = Strings.toCamelCase(name); + if (providerMap.containsKey(camelCase) == false && factories.containsKey(camelCase) == false) { + factories.put(camelCase, instance); + } + } + + for (Map.Entry> entry : defaultInstance.entrySet()) { + final String name = entry.getKey(); + final AnalysisModule.AnalysisProvider provider = entry.getValue(); + final String camelCase = Strings.toCamelCase(name); + if (factories.containsKey(name) == false || (defaultInstance.containsKey(camelCase) == false && factories.containsKey(camelCase) == false)) { + final T instance = provider.get(settings, environemnt, name, defaultSettings); + if (factories.containsKey(name) == false) { + factories.put(name, instance); + } + if ((defaultInstance.containsKey(camelCase) == false && factories.containsKey(camelCase) == false)) { + factories.put(camelCase, instance); + } + } + } + return factories; + } + + private static class PrebuiltAnalysis implements Closeable { + + final Map> analyzerProviderFactories; + final Map> tokenizerFactories; + final Map> tokenFilterFactories; + final Map> charFilterFactories; + + private PrebuiltAnalysis() { + Map analyzerProviderFactories = new HashMap<>(); + Map tokenizerFactories = new HashMap<>(); + Map tokenFilterFactories = new HashMap<>(); + Map charFilterFactories = new HashMap<>(); + // Analyzers + for (PreBuiltAnalyzers preBuiltAnalyzerEnum : PreBuiltAnalyzers.values()) { + String name = preBuiltAnalyzerEnum.name().toLowerCase(Locale.ROOT); + analyzerProviderFactories.put(name, new PreBuiltAnalyzerProviderFactory(name, AnalyzerScope.INDICES, preBuiltAnalyzerEnum.getAnalyzer(Version.CURRENT))); + } + + // Tokenizers + for (PreBuiltTokenizers preBuiltTokenizer : PreBuiltTokenizers.values()) { + String name = preBuiltTokenizer.name().toLowerCase(Locale.ROOT); + tokenizerFactories.put(name, new PreBuiltTokenizerFactoryFactory(preBuiltTokenizer.getTokenizerFactory(Version.CURRENT))); + } + + // Tokenizer aliases + tokenizerFactories.put("nGram", new PreBuiltTokenizerFactoryFactory(PreBuiltTokenizers.NGRAM.getTokenizerFactory(Version.CURRENT))); + tokenizerFactories.put("edgeNGram", new PreBuiltTokenizerFactoryFactory(PreBuiltTokenizers.EDGE_NGRAM.getTokenizerFactory(Version.CURRENT))); + + + // Token filters + for (PreBuiltTokenFilters preBuiltTokenFilter : PreBuiltTokenFilters.values()) { + String name = preBuiltTokenFilter.name().toLowerCase(Locale.ROOT); + tokenFilterFactories.put(name, new PreBuiltTokenFilterFactoryFactory(preBuiltTokenFilter.getTokenFilterFactory(Version.CURRENT))); + } + // Token filter aliases + tokenFilterFactories.put("nGram", new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.NGRAM.getTokenFilterFactory(Version.CURRENT))); + tokenFilterFactories.put("edgeNGram", new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.EDGE_NGRAM.getTokenFilterFactory(Version.CURRENT))); + + + // Char Filters + for (PreBuiltCharFilters preBuiltCharFilter : PreBuiltCharFilters.values()) { + String name = preBuiltCharFilter.name().toLowerCase(Locale.ROOT); + charFilterFactories.put(name, new PreBuiltCharFilterFactoryFactory(preBuiltCharFilter.getCharFilterFactory(Version.CURRENT))); + } + // Char filter aliases + charFilterFactories.put("htmlStrip", new PreBuiltCharFilterFactoryFactory(PreBuiltCharFilters.HTML_STRIP.getCharFilterFactory(Version.CURRENT))); + this.analyzerProviderFactories = Collections.unmodifiableMap(analyzerProviderFactories); + this.charFilterFactories = Collections.unmodifiableMap(charFilterFactories); + this.tokenFilterFactories = Collections.unmodifiableMap(tokenFilterFactories); + this.tokenizerFactories = Collections.unmodifiableMap(tokenizerFactories); + } + + public AnalysisModule.AnalysisProvider getCharFilterFactory(String name) { + return charFilterFactories.get(name); + } + + public AnalysisModule.AnalysisProvider getTokenFilterFactory(String name) { + return tokenFilterFactories.get(name); + } + + public AnalysisModule.AnalysisProvider getTokenizerFactory(String name) { + return tokenizerFactories.get(name); + } + + public AnalysisModule.AnalysisProvider getAnalyzerProvider(String name) { + return analyzerProviderFactories.get(name); + } + + Analyzer analyzer(String name) { + PreBuiltAnalyzerProviderFactory analyzerProviderFactory = (PreBuiltAnalyzerProviderFactory) analyzerProviderFactories.get(name); + if (analyzerProviderFactory == null) { + return null; + } + return analyzerProviderFactory.analyzer(); + } + + @Override + public void close() throws IOException { + IOUtils.close(analyzerProviderFactories.values().stream().map((a) -> ((PreBuiltAnalyzerProviderFactory)a).analyzer()).collect(Collectors.toList())); + } + } +} diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java index 562d70512d3..261add4e220 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisService.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.Analyzer; import org.elasticsearch.Version; -import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -29,9 +28,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.mapper.core.StringFieldMapper; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import java.io.Closeable; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -51,160 +50,20 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable private final NamedAnalyzer defaultSearchAnalyzer; private final NamedAnalyzer defaultSearchQuoteAnalyzer; - - public AnalysisService(IndexSettings indexSettings) { - this(indexSettings, null, null, null, null, null); - } - - @Inject - public AnalysisService(IndexSettings indexSettings, @Nullable IndicesAnalysisService indicesAnalysisService, - @Nullable Map analyzerFactoryFactories, - @Nullable Map tokenizerFactoryFactories, - @Nullable Map charFilterFactoryFactories, - @Nullable Map tokenFilterFactoryFactories) { + public AnalysisService(IndexSettings indexSettings, + Map analyzerProviders, + Map tokenizerFactoryFactories, + Map charFilterFactoryFactories, + Map tokenFilterFactoryFactories) { super(indexSettings); - Settings defaultSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexSettings.getIndexVersionCreated()).build(); - Map tokenizers = new HashMap<>(); - if (tokenizerFactoryFactories != null) { - Map tokenizersSettings = this.indexSettings.getSettings().getGroups("index.analysis.tokenizer"); - for (Map.Entry entry : tokenizerFactoryFactories.entrySet()) { - String tokenizerName = entry.getKey(); - TokenizerFactoryFactory tokenizerFactoryFactory = entry.getValue(); - - Settings tokenizerSettings = tokenizersSettings.get(tokenizerName); - if (tokenizerSettings == null) { - tokenizerSettings = defaultSettings; - } - - TokenizerFactory tokenizerFactory = tokenizerFactoryFactory.create(tokenizerName, tokenizerSettings); - tokenizers.put(tokenizerName, tokenizerFactory); - tokenizers.put(Strings.toCamelCase(tokenizerName), tokenizerFactory); - } - } - - if (indicesAnalysisService != null) { - for (Map.Entry entry : indicesAnalysisService.tokenizerFactories().entrySet()) { - String name = entry.getKey(); - if (!tokenizers.containsKey(name)) { - tokenizers.put(name, entry.getValue().create(name, defaultSettings)); - } - name = Strings.toCamelCase(entry.getKey()); - if (!name.equals(entry.getKey())) { - if (!tokenizers.containsKey(name)) { - tokenizers.put(name, entry.getValue().create(name, defaultSettings)); - } - } - } - } - - this.tokenizers = unmodifiableMap(tokenizers); - - Map charFilters = new HashMap<>(); - if (charFilterFactoryFactories != null) { - Map charFiltersSettings = this.indexSettings.getSettings().getGroups("index.analysis.char_filter"); - for (Map.Entry entry : charFilterFactoryFactories.entrySet()) { - String charFilterName = entry.getKey(); - CharFilterFactoryFactory charFilterFactoryFactory = entry.getValue(); - - Settings charFilterSettings = charFiltersSettings.get(charFilterName); - if (charFilterSettings == null) { - charFilterSettings = defaultSettings; - } - - CharFilterFactory tokenFilterFactory = charFilterFactoryFactory.create(charFilterName, charFilterSettings); - charFilters.put(charFilterName, tokenFilterFactory); - charFilters.put(Strings.toCamelCase(charFilterName), tokenFilterFactory); - } - } - - if (indicesAnalysisService != null) { - for (Map.Entry entry : indicesAnalysisService.charFilterFactories().entrySet()) { - String name = entry.getKey(); - if (!charFilters.containsKey(name)) { - charFilters.put(name, entry.getValue().create(name, defaultSettings)); - } - name = Strings.toCamelCase(entry.getKey()); - if (!name.equals(entry.getKey())) { - if (!charFilters.containsKey(name)) { - charFilters.put(name, entry.getValue().create(name, defaultSettings)); - } - } - } - } - - this.charFilters = unmodifiableMap(charFilters); - - Map tokenFilters = new HashMap<>(); - if (tokenFilterFactoryFactories != null) { - Map tokenFiltersSettings = this.indexSettings.getSettings().getGroups("index.analysis.filter"); - for (Map.Entry entry : tokenFilterFactoryFactories.entrySet()) { - String tokenFilterName = entry.getKey(); - TokenFilterFactoryFactory tokenFilterFactoryFactory = entry.getValue(); - - Settings tokenFilterSettings = tokenFiltersSettings.get(tokenFilterName); - if (tokenFilterSettings == null) { - tokenFilterSettings = defaultSettings; - } - - TokenFilterFactory tokenFilterFactory = tokenFilterFactoryFactory.create(tokenFilterName, tokenFilterSettings); - tokenFilters.put(tokenFilterName, tokenFilterFactory); - tokenFilters.put(Strings.toCamelCase(tokenFilterName), tokenFilterFactory); - } - } - - // pre initialize the globally registered ones into the map - if (indicesAnalysisService != null) { - for (Map.Entry entry : indicesAnalysisService.tokenFilterFactories().entrySet()) { - String name = entry.getKey(); - if (!tokenFilters.containsKey(name)) { - tokenFilters.put(name, entry.getValue().create(name, defaultSettings)); - } - name = Strings.toCamelCase(entry.getKey()); - if (!name.equals(entry.getKey())) { - if (!tokenFilters.containsKey(name)) { - tokenFilters.put(name, entry.getValue().create(name, defaultSettings)); - } - } - } - } - this.tokenFilters = unmodifiableMap(tokenFilters); - - Map analyzerProviders = new HashMap<>(); - if (analyzerFactoryFactories != null) { - Map analyzersSettings = this.indexSettings.getSettings().getGroups("index.analysis.analyzer"); - for (Map.Entry entry : analyzerFactoryFactories.entrySet()) { - String analyzerName = entry.getKey(); - AnalyzerProviderFactory analyzerFactoryFactory = entry.getValue(); - - Settings analyzerSettings = analyzersSettings.get(analyzerName); - if (analyzerSettings == null) { - analyzerSettings = defaultSettings; - } - - AnalyzerProvider analyzerFactory = analyzerFactoryFactory.create(analyzerName, analyzerSettings); - analyzerProviders.put(analyzerName, analyzerFactory); - } - } - if (indicesAnalysisService != null) { - for (Map.Entry entry : indicesAnalysisService.analyzerProviderFactories().entrySet()) { - String name = entry.getKey(); - Version indexVersion = indexSettings.getIndexVersionCreated(); - if (!analyzerProviders.containsKey(name)) { - analyzerProviders.put(name, entry.getValue().create(name, Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, indexVersion).build())); - } - String camelCaseName = Strings.toCamelCase(name); - if (!camelCaseName.equals(entry.getKey()) && !analyzerProviders.containsKey(camelCaseName)) { - analyzerProviders.put(camelCaseName, entry.getValue().create(name, Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, indexVersion).build())); - } - } - } + this.tokenizers = unmodifiableMap(tokenizerFactoryFactories); + this.charFilters = unmodifiableMap(charFilterFactoryFactories); + this.tokenFilters = unmodifiableMap(tokenFilterFactoryFactories); + analyzerProviders = new HashMap<>(analyzerProviders); if (!analyzerProviders.containsKey("default")) { analyzerProviders.put("default", new StandardAnalyzerProvider(indexSettings, null, "default", Settings.Builder.EMPTY_SETTINGS)); } - if (!analyzerProviders.containsKey("default_index")) { - analyzerProviders.put("default_index", analyzerProviders.get("default")); - } if (!analyzerProviders.containsKey("default_search")) { analyzerProviders.put("default_search", analyzerProviders.get("default")); } @@ -213,7 +72,9 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable } Map analyzers = new HashMap<>(); - for (AnalyzerProvider analyzerFactory : analyzerProviders.values()) { + for (Map.Entry entry : analyzerProviders.entrySet()) { + AnalyzerProvider analyzerFactory = entry.getValue(); + String name = entry.getKey(); /* * Lucene defaults positionIncrementGap to 0 in all analyzers but * Elasticsearch defaults them to 0 only before version 2.0 @@ -245,10 +106,12 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable analyzer = new NamedAnalyzer(analyzer, overridePositionIncrementGap); } } else { - analyzer = new NamedAnalyzer(analyzerFactory.name(), analyzerFactory.scope(), analyzerF, overridePositionIncrementGap); + analyzer = new NamedAnalyzer(name, analyzerFactory.scope(), analyzerF, overridePositionIncrementGap); } - analyzers.put(analyzerFactory.name(), analyzer); - analyzers.put(Strings.toCamelCase(analyzerFactory.name()), analyzer); + if (analyzers.containsKey(name)) { + throw new IllegalStateException("already registered analyzer with name: " + name); + } + analyzers.put(name, analyzer); String strAliases = this.indexSettings.getSettings().get("index.analysis.analyzer." + analyzerFactory.name() + ".alias"); if (strAliases != null) { for (String alias : Strings.commaDelimitedListToStringArray(strAliases)) { diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisSettingsRequired.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalysisSettingsRequired.java deleted file mode 100644 index 847752c5140..00000000000 --- a/core/src/main/java/org/elasticsearch/index/analysis/AnalysisSettingsRequired.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; - -import java.lang.annotation.*; - -/** - * A marker annotation on {@link CharFilterFactory}, {@link AnalyzerProvider}, {@link TokenFilterFactory}, - * or {@link TokenizerFactory} which will cause the provider/factory to only be created when explicit settings - * are provided. - */ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface AnalysisSettingsRequired { -} diff --git a/core/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java deleted file mode 100644 index a4a3e7ffce5..00000000000 --- a/core/src/main/java/org/elasticsearch/index/analysis/AnalyzerProviderFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; - -import org.elasticsearch.common.settings.Settings; - -/** - * - */ -public interface AnalyzerProviderFactory { - - AnalyzerProvider create(String name, Settings settings); -} diff --git a/core/src/main/java/org/elasticsearch/index/analysis/ApostropheFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/ApostropheFilterFactory.java index 9e907e40f0b..0ab84f7caf6 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/ApostropheFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/ApostropheFilterFactory.java @@ -20,9 +20,8 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tr.ApostropheFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; /** @@ -30,8 +29,7 @@ import org.elasticsearch.index.IndexSettings; */ public class ApostropheFilterFactory extends AbstractTokenFilterFactory { - @Inject - public ApostropheFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public ApostropheFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java index 7879967ae70..5a1754a02fe 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/ArabicAnalyzerProvider.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.ar.ArabicAnalyzer; import org.apache.lucene.analysis.util.CharArraySet; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -34,8 +32,7 @@ public class ArabicAnalyzerProvider extends AbstractIndexAnalyzerProvider escapedTags; - @Inject - public HtmlStripCharFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public HtmlStripCharFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name); String[] escapedTags = settings.getAsArray("escaped_tags"); if (escapedTags.length > 0) { diff --git a/core/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java index 462bde276e7..751ef0094f6 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/HungarianAnalyzerProvider.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.hu.HungarianAnalyzer; import org.apache.lucene.analysis.util.CharArraySet; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -34,8 +32,7 @@ public class HungarianAnalyzerProvider extends AbstractIndexAnalyzerProvider{@value #KEEP_TYPES_KEY} the array of words / tokens to keep. * */ -@AnalysisSettingsRequired public class KeepTypesFilterFactory extends AbstractTokenFilterFactory { private final Set keepTypes; private static final String KEEP_TYPES_KEY = "types"; - @Inject public KeepTypesFilterFactory(IndexSettings indexSettings, - Environment env, @Assisted String name, @Assisted Settings settings) { + Environment env, String name, Settings settings) { super(indexSettings, name, settings); final String[] arrayKeepTypes = settings.getAsArray(KEEP_TYPES_KEY, null); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/KeepWordFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/KeepWordFilterFactory.java index 3111370e318..56a62624af9 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/KeepWordFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/KeepWordFilterFactory.java @@ -24,10 +24,8 @@ import org.apache.lucene.analysis.miscellaneous.KeepWordFilter; import org.apache.lucene.analysis.miscellaneous.Lucene43KeepWordFilter; import org.apache.lucene.analysis.util.CharArraySet; import org.apache.lucene.util.Version; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; /** @@ -51,7 +49,6 @@ import org.elasticsearch.index.IndexSettings; * * @see StopTokenFilterFactory */ -@AnalysisSettingsRequired public class KeepWordFilterFactory extends AbstractTokenFilterFactory { private final CharArraySet keepWords; private final boolean enablePositionIncrements; @@ -60,9 +57,8 @@ public class KeepWordFilterFactory extends AbstractTokenFilterFactory { private static final String KEEP_WORDS_CASE_KEY = KEEP_WORDS_KEY + "_case"; // for javadoc private static final String ENABLE_POS_INC_KEY = "enable_position_increments"; - @Inject public KeepWordFilterFactory(IndexSettings indexSettings, - Environment env, @Assisted String name, @Assisted Settings settings) { + Environment env, String name, Settings settings) { super(indexSettings, name, settings); final String[] arrayKeepWords = settings.getAsArray(KEEP_WORDS_KEY, null); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java index f41002f4491..0bf134cb380 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/KeywordAnalyzerProvider.java @@ -20,9 +20,8 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.core.KeywordAnalyzer; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; /** @@ -32,8 +31,7 @@ public class KeywordAnalyzerProvider extends AbstractIndexAnalyzerProvider rules = Analysis.getWordList(env, settings, "mappings"); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java index 9c879badd2d..80e0aeb32eb 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenFilterFactory.java @@ -23,9 +23,8 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.ngram.Lucene43NGramTokenFilter; import org.apache.lucene.analysis.ngram.NGramTokenFilter; import org.apache.lucene.util.Version; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -39,8 +38,7 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { private final int maxGram; - @Inject - public NGramTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public NGramTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.minGram = settings.getAsInt("min_gram", NGramTokenFilter.DEFAULT_MIN_NGRAM_SIZE); this.maxGram = settings.getAsInt("max_gram", NGramTokenFilter.DEFAULT_MAX_NGRAM_SIZE); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java index af80adfc845..84da43497ac 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/NGramTokenizerFactory.java @@ -23,9 +23,8 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ngram.Lucene43NGramTokenizer; import org.apache.lucene.analysis.ngram.NGramTokenizer; import org.apache.lucene.util.Version; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import java.lang.reflect.Field; @@ -88,8 +87,7 @@ public class NGramTokenizerFactory extends AbstractTokenizerFactory { return builder.build(); } - @Inject - public NGramTokenizerFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public NGramTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.minGram = settings.getAsInt("min_gram", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE); this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java index 857abe946f5..1b136bfcef9 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/NorwegianAnalyzerProvider.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.no.NorwegianAnalyzer; import org.apache.lucene.analysis.util.CharArraySet; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -34,8 +32,7 @@ public class NorwegianAnalyzerProvider extends AbstractIndexAnalyzerProvider { private final PreBuiltAnalyzerProvider analyzerProvider; @@ -35,7 +40,6 @@ public class PreBuiltAnalyzerProviderFactory implements AnalyzerProviderFactory analyzerProvider = new PreBuiltAnalyzerProvider(name, scope, analyzer); } - @Override public AnalyzerProvider create(String name, Settings settings) { Version indexVersion = Version.indexCreated(settings); if (!Version.CURRENT.equals(indexVersion)) { @@ -49,6 +53,11 @@ public class PreBuiltAnalyzerProviderFactory implements AnalyzerProviderFactory return analyzerProvider; } + @Override + public AnalyzerProvider get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException { + return create(name, settings); + } + public Analyzer analyzer() { return analyzerProvider.get(); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java index f88b904436b..62a8ff1ff3e 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactory.java @@ -21,9 +21,14 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.indices.analysis.PreBuiltCharFilters; -public class PreBuiltCharFilterFactoryFactory implements CharFilterFactoryFactory { +import java.io.IOException; + +public class PreBuiltCharFilterFactoryFactory implements AnalysisModule.AnalysisProvider { private final CharFilterFactory charFilterFactory; @@ -32,7 +37,7 @@ public class PreBuiltCharFilterFactoryFactory implements CharFilterFactoryFactor } @Override - public CharFilterFactory create(String name, Settings settings) { + public CharFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException { Version indexVersion = Version.indexCreated(settings); if (!Version.CURRENT.equals(indexVersion)) { PreBuiltCharFilters preBuiltCharFilters = PreBuiltCharFilters.getOrDefault(name, null); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java index 4430204d47e..52c9f2851a2 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactory.java @@ -21,9 +21,14 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.indices.analysis.PreBuiltTokenFilters; -public class PreBuiltTokenFilterFactoryFactory implements TokenFilterFactoryFactory { +import java.io.IOException; + +public class PreBuiltTokenFilterFactoryFactory implements AnalysisModule.AnalysisProvider { private final TokenFilterFactory tokenFilterFactory; @@ -32,7 +37,7 @@ public class PreBuiltTokenFilterFactoryFactory implements TokenFilterFactoryFact } @Override - public TokenFilterFactory create(String name, Settings settings) { + public TokenFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException { Version indexVersion = Version.indexCreated(settings); if (!Version.CURRENT.equals(indexVersion)) { PreBuiltTokenFilters preBuiltTokenFilters = PreBuiltTokenFilters.getOrDefault(name, null); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java index 64213f7d400..02218bd7ceb 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactory.java @@ -21,9 +21,14 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.indices.analysis.PreBuiltTokenizers; -public class PreBuiltTokenizerFactoryFactory implements TokenizerFactoryFactory { +import java.io.IOException; + +public class PreBuiltTokenizerFactoryFactory implements AnalysisModule.AnalysisProvider { private final TokenizerFactory tokenizerFactory; @@ -31,8 +36,7 @@ public class PreBuiltTokenizerFactoryFactory implements TokenizerFactoryFactory this.tokenizerFactory = tokenizerFactory; } - @Override - public TokenizerFactory create(String name, Settings settings) { + public TokenizerFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException { Version indexVersion = Version.indexCreated(settings); if (!Version.CURRENT.equals(indexVersion)) { PreBuiltTokenizers preBuiltTokenizers = PreBuiltTokenizers.getOrDefault(name, null); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java index bafbef9f3f7..8fad0a14c7f 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/ReverseTokenFilterFactory.java @@ -21,9 +21,8 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.reverse.ReverseStringFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; /** @@ -31,8 +30,7 @@ import org.elasticsearch.index.IndexSettings; */ public class ReverseTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject - public ReverseTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public ReverseTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java index 3ff85c642bd..a455cef3ad1 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/RomanianAnalyzerProvider.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.ro.RomanianAnalyzer; import org.apache.lucene.analysis.util.CharArraySet; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -34,8 +32,7 @@ public class RomanianAnalyzerProvider extends AbstractIndexAnalyzerProvider rules = Analysis.getWordList(env, settings, "rules"); diff --git a/core/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java b/core/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java index f31b17a4082..7f8b65676bf 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/StemmerTokenFilterFactory.java @@ -54,9 +54,8 @@ import org.apache.lucene.analysis.snowball.SnowballFilter; import org.apache.lucene.analysis.sv.SwedishLightStemFilter; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import org.tartarus.snowball.ext.*; @@ -66,8 +65,7 @@ public class StemmerTokenFilterFactory extends AbstractTokenFilterFactory { private String language; - @Inject - public StemmerTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public StemmerTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.language = Strings.capitalize(settings.get("language", settings.get("name", "porter"))); } diff --git a/core/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java index eca30d0c5d9..cb1c4b8f5c5 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/StopAnalyzerProvider.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.core.StopAnalyzer; import org.apache.lucene.analysis.util.CharArraySet; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -34,8 +32,7 @@ public class StopAnalyzerProvider extends AbstractIndexAnalyzerProvider tokenizerFactories, - @Assisted String name, @Assisted Settings settings) { + public SynonymTokenFilterFactory(IndexSettings indexSettings, Environment env, Map tokenizerFactories, + String name, Settings settings) throws IOException { super(indexSettings, name, settings); Reader rulesReader = null; @@ -69,17 +65,11 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory { boolean expand = settings.getAsBoolean("expand", true); String tokenizerName = settings.get("tokenizer", "whitespace"); - - TokenizerFactoryFactory tokenizerFactoryFactory = tokenizerFactories.get(tokenizerName); - if (tokenizerFactoryFactory == null) { - tokenizerFactoryFactory = indicesAnalysisService.tokenizerFactoryFactory(tokenizerName); - } - if (tokenizerFactoryFactory == null) { + final TokenizerFactory tokenizerFactory = tokenizerFactories.get(tokenizerName); + if (tokenizerFactory == null) { throw new IllegalArgumentException("failed to find tokenizer [" + tokenizerName + "] for synonym token filter"); } - final TokenizerFactory tokenizerFactory = tokenizerFactoryFactory.create(tokenizerName, Settings.builder().put(this.indexSettings.getSettings()).put(settings).build()); - Analyzer analyzer = new Analyzer() { @Override protected TokenStreamComponents createComponents(String fieldName) { diff --git a/core/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java b/core/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java index 84eb8c5093b..cf4b9dbdb1e 100644 --- a/core/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java +++ b/core/src/main/java/org/elasticsearch/index/analysis/ThaiAnalyzerProvider.java @@ -20,8 +20,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.th.ThaiAnalyzer; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -33,8 +31,7 @@ public class ThaiAnalyzerProvider extends AbstractIndexAnalyzerProvider queryParsers = new ExtensionPoint.ClassSet<>("query_parser", QueryParser.class); - private final ExtensionPoint.InstanceMap hunspellDictionaries - = new ExtensionPoint.InstanceMap<>("hunspell_dictionary", String.class, Dictionary.class); public IndicesModule() { registerBuiltinQueryParsers(); @@ -116,14 +111,10 @@ public class IndicesModule extends AbstractModule { queryParsers.registerExtension(queryParser); } - public void registerHunspellDictionary(String name, Dictionary dictionary) { - hunspellDictionaries.registerExtension(name, dictionary); - } @Override protected void configure() { bindQueryParsersExtension(); - bindHunspellExtension(); bind(IndicesService.class).asEagerSingleton(); bind(RecoverySettings.class).asEagerSingleton(); @@ -149,10 +140,4 @@ public class IndicesModule extends AbstractModule { queryParsers.bind(binder()); bind(IndicesQueriesRegistry.class).asEagerSingleton(); } - - protected void bindHunspellExtension() { - hunspellDictionaries.bind(binder()); - bind(HunspellService.class).asEagerSingleton(); - bind(IndicesAnalysisService.class).asEagerSingleton(); - } } diff --git a/core/src/main/java/org/elasticsearch/indices/IndicesService.java b/core/src/main/java/org/elasticsearch/indices/IndicesService.java index 883add00665..62ca747e122 100644 --- a/core/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/core/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -41,7 +41,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.env.ShardLock; import org.elasticsearch.gateway.MetaDataStateFormat; import org.elasticsearch.index.*; -import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.cache.IndexCache; import org.elasticsearch.index.fielddata.IndexFieldDataService; @@ -59,7 +59,6 @@ import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.IndexEventListener; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.store.IndexStoreConfig; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import org.elasticsearch.indices.cache.query.IndicesQueryCache; import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.node.settings.NodeSettingsService; @@ -87,18 +86,19 @@ import static org.elasticsearch.common.util.CollectionUtils.arrayAsArrayList; public class IndicesService extends AbstractLifecycleComponent implements Iterable { public static final String INDICES_SHARDS_CLOSED_TIMEOUT = "indices.shards_closed_timeout"; - private final IndicesAnalysisService indicesAnalysisService; - private final Injector injector; - private final PluginsService pluginsService; private final NodeEnvironment nodeEnv; private final TimeValue shardsClosedTimeout; private final IndicesWarmer indicesWarmer; private final IndicesQueryCache indicesQueryCache; - + private final AnalysisRegistry analysisRegistry; private volatile Map indices = emptyMap(); + public AnalysisRegistry getAnalysis() { + return analysisRegistry; + } + static class IndexServiceInjectorPair { private final IndexService indexService; private final Injector injector; @@ -122,10 +122,13 @@ public class IndicesService extends AbstractLifecycleComponent i private final OldShardsStats oldShardsStats = new OldShardsStats(); private final IndexStoreConfig indexStoreConfig; + @Override + protected void doStart() { + } + @Inject - public IndicesService(Settings settings, IndicesAnalysisService indicesAnalysisService, Injector injector, PluginsService pluginsService, NodeEnvironment nodeEnv, NodeSettingsService nodeSettingsService, IndicesQueryCache indicesQueryCache, IndicesWarmer indicesWarmer) { + public IndicesService(Settings settings, Injector injector, PluginsService pluginsService, NodeEnvironment nodeEnv, NodeSettingsService nodeSettingsService, IndicesQueryCache indicesQueryCache, IndicesWarmer indicesWarmer, AnalysisRegistry analysisRegistry) { super(settings); - this.indicesAnalysisService = indicesAnalysisService; this.injector = injector; this.pluginsService = pluginsService; this.nodeEnv = nodeEnv; @@ -133,13 +136,10 @@ public class IndicesService extends AbstractLifecycleComponent i this.indicesQueryCache = indicesQueryCache; this.shardsClosedTimeout = settings.getAsTime(INDICES_SHARDS_CLOSED_TIMEOUT, new TimeValue(1, TimeUnit.DAYS)); this.indexStoreConfig = new IndexStoreConfig(settings); + this.analysisRegistry = analysisRegistry; nodeSettingsService.addListener(indexStoreConfig); } - @Override - protected void doStart() { - } - @Override protected void doStop() { ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown")); @@ -172,7 +172,7 @@ public class IndicesService extends AbstractLifecycleComponent i @Override protected void doClose() { IOUtils.closeWhileHandlingException(injector.getInstance(RecoverySettings.class), - indicesAnalysisService); + analysisRegistry); } /** @@ -310,12 +310,11 @@ public class IndicesService extends AbstractLifecycleComponent i for (Module pluginModule : pluginsService.indexModules(idxSettings.getSettings())) { modules.add(pluginModule); } - final IndexModule indexModule = new IndexModule(idxSettings, indexStoreConfig, indicesQueryCache, indicesWarmer); + final IndexModule indexModule = new IndexModule(idxSettings, indexStoreConfig, indicesQueryCache, indicesWarmer, analysisRegistry); for (IndexEventListener listener : builtInListeners) { indexModule.addIndexEventListener(listener); } indexModule.addIndexEventListener(oldShardsStats); - modules.add(new AnalysisModule(idxSettings.getSettings(), indicesAnalysisService)); modules.add(indexModule); pluginsService.processModules(modules); final IndexEventListener listener = indexModule.freeze(); diff --git a/core/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java b/core/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java new file mode 100644 index 00000000000..11cf4dc5c12 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java @@ -0,0 +1,213 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; + +import org.apache.lucene.analysis.hunspell.Dictionary; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.analysis.*; + +import java.io.IOException; +import java.util.*; + +/** + * The AnalysisModule is the main extension point for node and index level analysis components. The lucene classes + * {@link org.apache.lucene.analysis.Analyzer}, {@link org.apache.lucene.analysis.TokenFilter}, {@link org.apache.lucene.analysis.Tokenizer} + * and {@link org.apache.lucene.analysis.CharFilter} can be extended in plugins and registered on node startup when the analysis module + * gets loaded. Since elasticsearch needs to create multiple instances for different configurations dedicated factories need to be provided for + * each of the components: + *
    + *
  • {@link org.apache.lucene.analysis.Analyzer} can be exposed via {@link AnalyzerProvider} and registered on {@link #registerAnalyzer(String, AnalysisProvider)}
  • + *
  • {@link org.apache.lucene.analysis.TokenFilter} can be exposed via {@link TokenFilterFactory} and registered on {@link #registerTokenFilter(String, AnalysisProvider)}
  • + *
  • {@link org.apache.lucene.analysis.Tokenizer} can be exposed via {@link TokenizerFactory} and registered on {@link #registerTokenizer(String, AnalysisProvider)}
  • + *
  • {@link org.apache.lucene.analysis.CharFilter} can be exposed via {@link CharFilterFactory} and registered on {@link #registerCharFilter(String, AnalysisProvider)}
  • + *
+ * + * The {@link org.elasticsearch.indices.analysis.AnalysisModule.AnalysisProvider} is only a functional interface that allows to register factory constructors directly like the plugin example below: + *
+ *     public class MyAnalysisPlugin extends Plugin {
+ *       @Override
+ *       public String name() {
+ *         return "analysis-my-plugin";
+ *       }
+ *
+ *       @Override
+ *       public String description() {
+ *         return "my very fast and efficient analyzer";
+ *       }
+ *
+ *       public void onModule(AnalysisModule module) {
+ *         module.registerAnalyzer("my-analyzer-name", MyAnalyzer::new);
+ *       }
+ *     }
+ * 
+ */ +public final class AnalysisModule extends AbstractModule { + + static { + Settings build = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1) + .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) + .build(); + IndexMetaData metaData = IndexMetaData.builder("_na_").settings(build).build(); + NA_INDEX_SETTINGS = new IndexSettings(metaData, Settings.EMPTY, Collections.emptyList()); + } + private static final IndexSettings NA_INDEX_SETTINGS; + private final Environment environment; + private final Map> charFilters = new HashMap<>(); + private final Map> tokenFilters = new HashMap<>(); + private final Map> tokenizers = new HashMap<>(); + private final Map> analyzers = new HashMap<>(); + private final Map knownDictionaries = new HashMap<>(); + + /** + * Creates a new AnalysisModule + */ + public AnalysisModule(Environment environment) { + this.environment = environment; + } + + /** + * Registers a new {@link AnalysisProvider} to create + * {@link CharFilterFactory} instance per node as well as per index. + */ + public void registerCharFilter(String name, AnalysisProvider charFilter) { + if (charFilter == null) { + throw new IllegalArgumentException("char_filter provider must not be null"); + } + if (charFilters.putIfAbsent(name, charFilter) != null) { + throw new IllegalArgumentException("char_filter provider for name " + name + " already registered"); + } + } + + /** + * Registers a new {@link AnalysisProvider} to create + * {@link TokenFilterFactory} instance per node as well as per index. + */ + public void registerTokenFilter(String name, AnalysisProvider tokenFilter) { + if (tokenFilter == null) { + throw new IllegalArgumentException("token_filter provider must not be null"); + } + if (tokenFilters.putIfAbsent(name, tokenFilter) != null) { + throw new IllegalArgumentException("token_filter provider for name " + name + " already registered"); + } + } + + /** + * Registers a new {@link AnalysisProvider} to create + * {@link TokenizerFactory} instance per node as well as per index. + */ + public void registerTokenizer(String name, AnalysisProvider tokenizer) { + if (tokenizer == null) { + throw new IllegalArgumentException("tokenizer provider must not be null"); + } + if (tokenizers.putIfAbsent(name, tokenizer) != null) { + throw new IllegalArgumentException("tokenizer provider for name " + name + " already registered"); + } + } + + /** + * Registers a new {@link AnalysisProvider} to create + * {@link AnalyzerProvider} instance per node as well as per index. + */ + public void registerAnalyzer(String name, AnalysisProvider analyzer) { + if (analyzer == null) { + throw new IllegalArgumentException("analyzer provider must not be null"); + } + if (analyzers.putIfAbsent(name, analyzer) != null) { + throw new IllegalArgumentException("analyzer provider for name " + name + " already registered"); + } + } + + /** + * Registers a new hunspell {@link Dictionary} that can be referenced by the given name in + * hunspell analysis configuration. + */ + public void registerHunspellDictionary(String name, Dictionary dictionary) { + if (knownDictionaries.putIfAbsent(name, dictionary) != null) { + throw new IllegalArgumentException("dictionary for [" + name + "] is already registered"); + } + } + + @Override + protected void configure() { + try { + HunspellService service = new HunspellService(environment.settings(), environment, knownDictionaries); + AnalysisRegistry registry = new AnalysisRegistry(service, environment, charFilters, tokenFilters, tokenizers, analyzers); + bind(HunspellService.class).toInstance(service); + bind(AnalysisRegistry.class).toInstance(registry); + } catch (IOException e) { + throw new ElasticsearchException("failed to load hunspell service", e); + } + } + + /** + * AnalysisProvider is the basic factory interface for registering analysis components like: + *
    + *
  • {@link TokenizerFactory} - see {@link AnalysisModule#registerTokenizer(String, AnalysisProvider)}
  • + *
  • {@link CharFilterFactory} - see {@link AnalysisModule#registerCharFilter(String, AnalysisProvider)}
  • + *
  • {@link AnalyzerProvider} - see {@link AnalysisModule#registerAnalyzer(String, AnalysisProvider)}
  • + *
  • {@link TokenFilterFactory}- see {@link AnalysisModule#registerTokenFilter(String, AnalysisProvider)} )}
  • + *
+ */ + public interface AnalysisProvider { + + /** + * Creates a new analysis provider. + * @param indexSettings the index settings for the index this provider is created for + * @param environment the nodes environment to load resources from persistent storage + * @param name the name of the analysis component + * @param settings the component specific settings without context prefixes + * @return a new provider instance + * @throws IOException if an {@link IOException} occurs + */ + T get(IndexSettings indexSettings, Environment environment, String name, Settings settings) throws IOException; + + /** + * Creates a new global scope analysis provider without index specific settings not settings for the provider itself. + * This can be used to get a default instance of an analysis factory without binding to an index. + * + * @param environment the nodes environment to load resources from persistent storage + * @param name the name of the analysis component + * @return a new provider instance + * @throws IOException if an {@link IOException} occurs + * @throws IllegalArgumentException if the provider requires analysis settings ie. if {@link #requiresAnalysisSettings()} returns true + */ + default T get(Environment environment, String name) throws IOException { + if (requiresAnalysisSettings()) { + throw new IllegalArgumentException("Analysis settings required - can't instantiate analysis factory"); + } + return get(NA_INDEX_SETTINGS, environment, name, NA_INDEX_SETTINGS.getSettings()); + } + + /** + * If true the analysis component created by this provider requires certain settings to be instantiated. + * it can't be created with defaults. The default is false. + */ + default boolean requiresAnalysisSettings() { + return false; + } + } +} diff --git a/core/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java b/core/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java index 1a48c5c3ca5..1ae41560067 100644 --- a/core/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java +++ b/core/src/main/java/org/elasticsearch/indices/analysis/HunspellService.java @@ -22,7 +22,6 @@ import org.apache.lucene.analysis.hunspell.Dictionary; import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.FileSystemUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -76,7 +75,6 @@ public class HunspellService extends AbstractComponent { private final Path hunspellDir; private final Function loadingFunction; - @Inject public HunspellService(final Settings settings, final Environment env, final Map knownDictionaries) throws IOException { super(settings); this.knownDictionaries = Collections.unmodifiableMap(knownDictionaries); diff --git a/core/src/main/java/org/elasticsearch/indices/analysis/IndicesAnalysisService.java b/core/src/main/java/org/elasticsearch/indices/analysis/IndicesAnalysisService.java deleted file mode 100644 index 9acdce3f8ab..00000000000 --- a/core/src/main/java/org/elasticsearch/indices/analysis/IndicesAnalysisService.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.apache.lucene.analysis.Analyzer; -import org.elasticsearch.Version; -import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.ConcurrentCollections; -import org.elasticsearch.index.analysis.*; - -import java.io.Closeable; -import java.util.Locale; -import java.util.Map; - -import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS; - -/** - * A node level registry of analyzers, to be reused by different indices which use default analyzers. - */ -public class IndicesAnalysisService extends AbstractComponent implements Closeable { - - private final Map analyzerProviderFactories = ConcurrentCollections.newConcurrentMap(); - private final Map tokenizerFactories = ConcurrentCollections.newConcurrentMap(); - private final Map tokenFilterFactories = ConcurrentCollections.newConcurrentMap(); - private final Map charFilterFactories = ConcurrentCollections.newConcurrentMap(); - - public IndicesAnalysisService() { - super(EMPTY_SETTINGS); - } - - @Inject - public IndicesAnalysisService(Settings settings) { - super(settings); - - // Analyzers - for (PreBuiltAnalyzers preBuiltAnalyzerEnum : PreBuiltAnalyzers.values()) { - String name = preBuiltAnalyzerEnum.name().toLowerCase(Locale.ROOT); - analyzerProviderFactories.put(name, new PreBuiltAnalyzerProviderFactory(name, AnalyzerScope.INDICES, preBuiltAnalyzerEnum.getAnalyzer(Version.CURRENT))); - } - - // Tokenizers - for (PreBuiltTokenizers preBuiltTokenizer : PreBuiltTokenizers.values()) { - String name = preBuiltTokenizer.name().toLowerCase(Locale.ROOT); - tokenizerFactories.put(name, new PreBuiltTokenizerFactoryFactory(preBuiltTokenizer.getTokenizerFactory(Version.CURRENT))); - } - - // Tokenizer aliases - tokenizerFactories.put("nGram", new PreBuiltTokenizerFactoryFactory(PreBuiltTokenizers.NGRAM.getTokenizerFactory(Version.CURRENT))); - tokenizerFactories.put("edgeNGram", new PreBuiltTokenizerFactoryFactory(PreBuiltTokenizers.EDGE_NGRAM.getTokenizerFactory(Version.CURRENT))); - - - // Token filters - for (PreBuiltTokenFilters preBuiltTokenFilter : PreBuiltTokenFilters.values()) { - String name = preBuiltTokenFilter.name().toLowerCase(Locale.ROOT); - tokenFilterFactories.put(name, new PreBuiltTokenFilterFactoryFactory(preBuiltTokenFilter.getTokenFilterFactory(Version.CURRENT))); - } - // Token filter aliases - tokenFilterFactories.put("nGram", new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.NGRAM.getTokenFilterFactory(Version.CURRENT))); - tokenFilterFactories.put("edgeNGram", new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.EDGE_NGRAM.getTokenFilterFactory(Version.CURRENT))); - - - // Char Filters - for (PreBuiltCharFilters preBuiltCharFilter : PreBuiltCharFilters.values()) { - String name = preBuiltCharFilter.name().toLowerCase(Locale.ROOT); - charFilterFactories.put(name, new PreBuiltCharFilterFactoryFactory(preBuiltCharFilter.getCharFilterFactory(Version.CURRENT))); - } - // Char filter aliases - charFilterFactories.put("htmlStrip", new PreBuiltCharFilterFactoryFactory(PreBuiltCharFilters.HTML_STRIP.getCharFilterFactory(Version.CURRENT))); - } - - public boolean hasCharFilter(String name) { - return charFilterFactoryFactory(name) != null; - } - - public Map charFilterFactories() { - return charFilterFactories; - } - - public CharFilterFactoryFactory charFilterFactoryFactory(String name) { - return charFilterFactories.get(name); - } - - public boolean hasTokenFilter(String name) { - return tokenFilterFactoryFactory(name) != null; - } - - public Map tokenFilterFactories() { - return tokenFilterFactories; - } - - public TokenFilterFactoryFactory tokenFilterFactoryFactory(String name) { - return tokenFilterFactories.get(name); - } - - public boolean hasTokenizer(String name) { - return tokenizerFactoryFactory(name) != null; - } - - public Map tokenizerFactories() { - return tokenizerFactories; - } - - public TokenizerFactoryFactory tokenizerFactoryFactory(String name) { - return tokenizerFactories.get(name); - } - - public Map analyzerProviderFactories() { - return analyzerProviderFactories; - } - - public PreBuiltAnalyzerProviderFactory analyzerProviderFactory(String name) { - return analyzerProviderFactories.get(name); - } - - public boolean hasAnalyzer(String name) { - return analyzerProviderFactories.containsKey(name); - } - - public Analyzer analyzer(String name) { - PreBuiltAnalyzerProviderFactory analyzerProviderFactory = analyzerProviderFactory(name); - if (analyzerProviderFactory == null) { - return null; - } - return analyzerProviderFactory.analyzer(); - } - - @Override - public void close() { - for (PreBuiltAnalyzerProviderFactory analyzerProviderFactory : analyzerProviderFactories.values()) { - try { - analyzerProviderFactory.analyzer().close(); - } catch (Exception e) { - // ignore - } - } - } -} diff --git a/core/src/main/java/org/elasticsearch/indices/analysis/PreBuiltCacheFactory.java b/core/src/main/java/org/elasticsearch/indices/analysis/PreBuiltCacheFactory.java index 31908eb79f2..ddda8a08745 100644 --- a/core/src/main/java/org/elasticsearch/indices/analysis/PreBuiltCacheFactory.java +++ b/core/src/main/java/org/elasticsearch/indices/analysis/PreBuiltCacheFactory.java @@ -36,7 +36,7 @@ public class PreBuiltCacheFactory { * LUCENE Exactly one version for each lucene version is stored. Useful to prevent different analyzers with the same version * ELASTICSEARCH Exactly one version per elasticsearch version is stored. Useful if you change an analyzer between elasticsearch releases, when the lucene version does not change */ - static enum CachingStrategy { ONE, LUCENE, ELASTICSEARCH }; + public enum CachingStrategy { ONE, LUCENE, ELASTICSEARCH }; public interface PreBuiltCache { T get(Version version); diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 15279fc0743..405271ad07a 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -57,6 +57,7 @@ import org.elasticsearch.http.HttpServer; import org.elasticsearch.http.HttpServerModule; import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.indices.breaker.CircuitBreakerModule; import org.elasticsearch.indices.cache.query.IndicesQueryCache; import org.elasticsearch.indices.cluster.IndicesClusterStateService; @@ -191,6 +192,7 @@ public class Node implements Releasable { modules.add(new ResourceWatcherModule()); modules.add(new RepositoriesModule()); modules.add(new TribeModule()); + modules.add(new AnalysisModule(environment)); pluginsService.processModules(modules); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java new file mode 100644 index 00000000000..d9a1c37abee --- /dev/null +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java @@ -0,0 +1,243 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.action.admin.indices; + +import org.elasticsearch.Version; +import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest; +import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; +import org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.analysis.AnalysisRegistry; +import org.elasticsearch.index.analysis.AnalysisService; +import org.elasticsearch.index.mapper.internal.AllFieldMapper; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.IndexSettingsModule; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import static org.elasticsearch.common.settings.Settings.settingsBuilder; + +public class TransportAnalyzeActionTests extends ESTestCase { + + private AnalysisService analysisService; + private AnalysisRegistry registry; + private Environment environment; + + @Override + public void setUp() throws Exception { + super.setUp(); + Settings settings = Settings.builder().put("path.home", createTempDir().toString()).build(); + + Settings indexSettings = settingsBuilder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("index.analysis.filter.wordDelimiter.type", "word_delimiter") + .put("index.analysis.filter.wordDelimiter.split_on_numerics", false) + .put("index.analysis.analyzer.custom_analyzer.tokenizer", "whitespace") + .putArray("index.analysis.analyzer.custom_analyzer.filter", "lowercase", "wordDelimiter") + .put("index.analysis.analyzer.custom_analyzer.tokenizer", "whitespace") + .putArray("index.analysis.analyzer.custom_analyzer.filter", "lowercase", "wordDelimiter").build(); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), indexSettings, Collections.EMPTY_LIST); + environment = new Environment(settings); + registry = new AnalysisRegistry(null, environment); + analysisService = registry.build(idxSettings); + } + + public void testNoAnalysisService() throws IOException { + AnalyzeRequest request = new AnalyzeRequest(); + request.analyzer("standard"); + request.text("the quick brown fox"); + AnalyzeResponse analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, null, registry, environment); + List tokens = analyze.getTokens(); + assertEquals(4, tokens.size()); + + request.analyzer(null); + request.tokenizer("whitespace"); + request.tokenFilters("lowercase", "word_delimiter"); + request.text("the qu1ck brown fox"); + analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, randomBoolean() ? analysisService : null, registry, environment); + tokens = analyze.getTokens(); + assertEquals(6, tokens.size()); + assertEquals("qu", tokens.get(1).getTerm()); + assertEquals("1", tokens.get(2).getTerm()); + assertEquals("ck", tokens.get(3).getTerm()); + + request.analyzer(null); + request.tokenizer("whitespace"); + request.charFilters("html_strip"); + request.tokenFilters("lowercase", "word_delimiter"); + request.text("

the qu1ck brown fox

"); + analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, randomBoolean() ? analysisService : null, registry, environment); + tokens = analyze.getTokens(); + assertEquals(6, tokens.size()); + assertEquals("the", tokens.get(0).getTerm()); + assertEquals("qu", tokens.get(1).getTerm()); + assertEquals("1", tokens.get(2).getTerm()); + assertEquals("ck", tokens.get(3).getTerm()); + assertEquals("brown", tokens.get(4).getTerm()); + assertEquals("fox", tokens.get(5).getTerm()); + } + + public void testFillsAttributes() throws IOException { + AnalyzeRequest request = new AnalyzeRequest(); + request.analyzer("standard"); + request.text("the 1 brown fox"); + AnalyzeResponse analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, null, registry, environment); + List tokens = analyze.getTokens(); + assertEquals(4, tokens.size()); + assertEquals("the", tokens.get(0).getTerm()); + assertEquals(0, tokens.get(0).getStartOffset()); + assertEquals(3, tokens.get(0).getEndOffset()); + assertEquals(0, tokens.get(0).getPosition()); + assertEquals("", tokens.get(0).getType()); + + assertEquals("1", tokens.get(1).getTerm()); + assertEquals(4, tokens.get(1).getStartOffset()); + assertEquals(5, tokens.get(1).getEndOffset()); + assertEquals(1, tokens.get(1).getPosition()); + assertEquals("", tokens.get(1).getType()); + + assertEquals("brown", tokens.get(2).getTerm()); + assertEquals(6, tokens.get(2).getStartOffset()); + assertEquals(11, tokens.get(2).getEndOffset()); + assertEquals(2, tokens.get(2).getPosition()); + assertEquals("", tokens.get(2).getType()); + + assertEquals("fox", tokens.get(3).getTerm()); + assertEquals(12, tokens.get(3).getStartOffset()); + assertEquals(15, tokens.get(3).getEndOffset()); + assertEquals(3, tokens.get(3).getPosition()); + assertEquals("", tokens.get(3).getType()); + } + + public void testWithAnalysisService() throws IOException { + + AnalyzeRequest request = new AnalyzeRequest(); + request.analyzer("standard"); + request.text("the quick brown fox"); + request.analyzer("custom_analyzer"); + request.text("the qu1ck brown fox"); + AnalyzeResponse analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, analysisService, registry, environment); + List tokens = analyze.getTokens(); + assertEquals(4, tokens.size()); + + request.analyzer("whitespace"); + request.text("the qu1ck brown fox-dog"); + analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, analysisService, registry, environment); + tokens = analyze.getTokens(); + assertEquals(4, tokens.size()); + + request.analyzer("custom_analyzer"); + request.text("the qu1ck brown fox-dog"); + analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, analysisService, registry, environment); + tokens = analyze.getTokens(); + assertEquals(5, tokens.size()); + + request.analyzer(null); + request.tokenizer("whitespace"); + request.tokenFilters("lowercase", "wordDelimiter"); + request.text("the qu1ck brown fox-dog"); + analyze = TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, analysisService, registry, environment); + tokens = analyze.getTokens(); + assertEquals(5, tokens.size()); + assertEquals("the", tokens.get(0).getTerm()); + assertEquals("qu1ck", tokens.get(1).getTerm()); + assertEquals("brown", tokens.get(2).getTerm()); + assertEquals("fox", tokens.get(3).getTerm()); + assertEquals("dog", tokens.get(4).getTerm()); + } + + public void testGetIndexAnalyserWithoutAnalysisService() throws IOException { + AnalyzeRequest request = new AnalyzeRequest(); + request.analyzer("custom_analyzer"); + request.text("the qu1ck brown fox-dog"); + try { + TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, null, registry, environment); + fail("no analysis service provided"); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "failed to find global analyzer [custom_analyzer]"); + } + } + + public void testUnknown() throws IOException { + boolean notGlobal = randomBoolean(); + try { + AnalyzeRequest request = new AnalyzeRequest(); + request.analyzer("foobar"); + request.text("the qu1ck brown fox"); + TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, notGlobal ? analysisService : null, registry, environment); + fail("no such analyzer"); + } catch (IllegalArgumentException e) { + if (notGlobal) { + assertEquals(e.getMessage(), "failed to find analyzer [foobar]"); + } else { + assertEquals(e.getMessage(), "failed to find global analyzer [foobar]"); + } + } + try { + AnalyzeRequest request = new AnalyzeRequest(); + request.tokenizer("foobar"); + request.text("the qu1ck brown fox"); + TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, notGlobal ? analysisService : null, registry, environment); + fail("no such analyzer"); + } catch (IllegalArgumentException e) { + if (notGlobal) { + assertEquals(e.getMessage(), "failed to find tokenizer under [foobar]"); + } else { + assertEquals(e.getMessage(), "failed to find global tokenizer under [foobar]"); + } + } + + try { + AnalyzeRequest request = new AnalyzeRequest(); + request.tokenizer("whitespace"); + request.tokenFilters("foobar"); + request.text("the qu1ck brown fox"); + TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, notGlobal ? analysisService : null, registry, environment); + fail("no such analyzer"); + } catch (IllegalArgumentException e) { + if (notGlobal) { + assertEquals(e.getMessage(), "failed to find token filter under [foobar]"); + } else { + assertEquals(e.getMessage(), "failed to find global token filter under [foobar]"); + } + } + + try { + AnalyzeRequest request = new AnalyzeRequest(); + request.tokenizer("whitespace"); + request.tokenFilters("lowercase"); + request.charFilters("foobar"); + request.text("the qu1ck brown fox"); + TransportAnalyzeAction.analyze(request, AllFieldMapper.NAME, null, notGlobal ? analysisService : null, registry, environment); + fail("no such analyzer"); + } catch (IllegalArgumentException e) { + if (notGlobal) { + assertEquals(e.getMessage(), "failed to find char filter under [foobar]"); + } else { + assertEquals(e.getMessage(), "failed to find global char filter under [foobar]"); + } + } + } +} diff --git a/core/src/test/java/org/elasticsearch/index/IndexModuleTests.java b/core/src/test/java/org/elasticsearch/index/IndexModuleTests.java index 5b7577e27ce..0cfca3a0ce1 100644 --- a/core/src/test/java/org/elasticsearch/index/IndexModuleTests.java +++ b/core/src/test/java/org/elasticsearch/index/IndexModuleTests.java @@ -28,6 +28,8 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.inject.ModuleTestCase; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.cache.query.QueryCache; import org.elasticsearch.index.cache.query.index.IndexQueryCache; import org.elasticsearch.index.cache.query.none.NoneQueryCache; @@ -54,9 +56,9 @@ public class IndexModuleTests extends ModuleTestCase { private final IndicesWarmer warmer = new IndicesWarmer(Settings.EMPTY, null); public void testWrapperIsBound() { final Index index = new Index("foo"); - final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", createTempDir().toString()).build(); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); - IndexModule module = new IndexModule(indexSettings, null, null, warmer); + IndexModule module = new IndexModule(indexSettings, null, null, warmer, new AnalysisRegistry(null, new Environment(settings))); assertInstanceBinding(module, IndexModule.IndexSearcherWrapperFactory.class, (x) -> x.newWrapper(null) == null); module.setSearcherWrapper((s) -> new Wrapper()); assertInstanceBinding(module, IndexModule.IndexSearcherWrapperFactory.class, (x) -> x.newWrapper(null) instanceof Wrapper); @@ -64,9 +66,9 @@ public class IndexModuleTests extends ModuleTestCase { public void testEngineFactoryBound() { final Index index = new Index("foo"); - final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", createTempDir().toString()).build(); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); - IndexModule module = new IndexModule(indexSettings, null, null, warmer); + IndexModule module = new IndexModule(indexSettings, null, null, warmer, new AnalysisRegistry(null, new Environment(settings))); assertBinding(module, EngineFactory.class, InternalEngineFactory.class); module.engineFactoryImpl = MockEngineFactory.class; assertBinding(module, EngineFactory.class, MockEngineFactory.class); @@ -74,9 +76,9 @@ public class IndexModuleTests extends ModuleTestCase { public void testRegisterIndexStore() { final Index index = new Index("foo"); - final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put(IndexModule.STORE_TYPE, "foo_store").build(); + final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", createTempDir().toString()).put(IndexModule.STORE_TYPE, "foo_store").build(); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); - IndexModule module = new IndexModule(indexSettings, null, null, warmer); + IndexModule module = new IndexModule(indexSettings, null, null, warmer, new AnalysisRegistry(null, new Environment(settings))); module.addIndexStore("foo_store", FooStore::new); assertInstanceBinding(module, IndexStore.class, (x) -> x.getClass() == FooStore.class); try { @@ -96,9 +98,9 @@ public class IndexModuleTests extends ModuleTestCase { } }; final Index index = new Index("foo"); - final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", createTempDir().toString()).build(); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); - IndexModule module = new IndexModule(indexSettings, null, null, warmer); + IndexModule module = new IndexModule(indexSettings, null, null, warmer, new AnalysisRegistry(null, new Environment(settings))); Consumer listener = (s) -> {}; module.addIndexSettingsListener(listener); module.addIndexEventListener(eventListener); @@ -117,9 +119,9 @@ public class IndexModuleTests extends ModuleTestCase { public void testListener() { final Index index = new Index("foo"); - final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).put("path.home", createTempDir().toString()).build(); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); - IndexModule module = new IndexModule(indexSettings, null, null, warmer); + IndexModule module = new IndexModule(indexSettings, null, null, warmer, new AnalysisRegistry(null, new Environment(settings))); Consumer listener = (s) -> { }; module.addIndexSettingsListener(listener); @@ -146,8 +148,9 @@ public class IndexModuleTests extends ModuleTestCase { .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put("index.similarity.my_similarity.type", "test_similarity") .put("index.similarity.my_similarity.key", "there is a key") + .put("path.home", createTempDir().toString()) .build(); - IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer); + IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer, new AnalysisRegistry(null, new Environment(indexSettings))); module.addSimilarity("test_similarity", (string, settings) -> new SimilarityProvider() { @Override public String name() { @@ -175,8 +178,9 @@ public class IndexModuleTests extends ModuleTestCase { Settings indexSettings = Settings.settingsBuilder() .put("index.similarity.my_similarity.type", "test_similarity") .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("path.home", createTempDir().toString()) .build(); - IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer); + IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer, new AnalysisRegistry(null, new Environment(indexSettings))); try { assertInstanceBinding(module, SimilarityService.class, (inst) -> inst instanceof SimilarityService); } catch (IllegalArgumentException ex) { @@ -188,9 +192,10 @@ public class IndexModuleTests extends ModuleTestCase { public void testSetupWithoutType() { Settings indexSettings = Settings.settingsBuilder() .put("index.similarity.my_similarity.foo", "bar") + .put("path.home", createTempDir().toString()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); - IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer); + IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer, new AnalysisRegistry(null, new Environment(indexSettings))); try { assertInstanceBinding(module, SimilarityService.class, (inst) -> inst instanceof SimilarityService); } catch (IllegalArgumentException ex) { @@ -200,8 +205,9 @@ public class IndexModuleTests extends ModuleTestCase { public void testCannotRegisterProvidedImplementations() { Settings indexSettings = Settings.settingsBuilder() + .put("path.home", createTempDir().toString()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); - IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer); + IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer, new AnalysisRegistry(null, new Environment(indexSettings))); try { module.registerQueryCache("index", IndexQueryCache::new); fail("only once"); @@ -227,8 +233,9 @@ public class IndexModuleTests extends ModuleTestCase { public void testRegisterCustomQueryCache() { Settings indexSettings = Settings.settingsBuilder() .put(IndexModule.QUERY_CACHE_TYPE, "custom") + .put("path.home", createTempDir().toString()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); - IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer); + IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer, new AnalysisRegistry(null, new Environment(indexSettings))); module.registerQueryCache("custom", (a, b) -> new CustomQueryCache()); try { module.registerQueryCache("custom", (a, b) -> new CustomQueryCache()); @@ -241,8 +248,9 @@ public class IndexModuleTests extends ModuleTestCase { public void testDefaultQueryCacheImplIsSelected() { Settings indexSettings = Settings.settingsBuilder() + .put("path.home", createTempDir().toString()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); - IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer); + IndexModule module = new IndexModule(IndexSettingsModule.newIndexSettings(new Index("foo"), indexSettings, Collections.EMPTY_LIST), null, null, warmer, new AnalysisRegistry(null, new Environment(indexSettings))); assertInstanceBinding(module, QueryCache.class, (x) -> x instanceof IndexQueryCache); } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java index 48fb734f7a9..3e50a71f206 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisModuleTests.java @@ -25,31 +25,31 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ar.ArabicNormalizationFilter; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.apache.lucene.analysis.fa.PersianNormalizationFilter; +import org.apache.lucene.analysis.hunspell.Dictionary; import org.apache.lucene.analysis.miscellaneous.KeywordRepeatFilter; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; -import org.elasticsearch.common.inject.ProvisionException; +import org.elasticsearch.common.inject.ModuleTestCase; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; -import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.indices.analysis.HunspellService; import org.elasticsearch.test.IndexSettingsModule; import org.elasticsearch.test.VersionUtils; import org.hamcrest.MatcherAssert; import java.io.BufferedWriter; import java.io.IOException; +import java.io.InputStream; import java.io.StringReader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; import java.util.Set; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -58,21 +58,21 @@ import static org.hamcrest.Matchers.*; /** * */ -public class AnalysisModuleTests extends ESTestCase { +public class AnalysisModuleTests extends ModuleTestCase { - private Injector injector; + public AnalysisService getAnalysisService(Settings settings) throws IOException { + return getAnalysisService(getNewRegistry(settings), settings); + } - public AnalysisService getAnalysisService(Settings settings) { + public AnalysisService getAnalysisService(AnalysisRegistry registry, Settings settings) throws IOException { Index index = new Index("test"); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)); - analysisModule.addTokenFilter("myfilter", MyFilterTokenFilterFactory.class); - injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - analysisModule) - .createChildInjector(parentInjector); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + return registry.build(idxSettings); + } - return injector.getInstance(AnalysisService.class); + public AnalysisRegistry getNewRegistry(Settings settings) { + return new AnalysisRegistry(null, new Environment(settings), + Collections.EMPTY_MAP, Collections.singletonMap("myfilter", MyFilterTokenFilterFactory::new), Collections.EMPTY_MAP, Collections.EMPTY_MAP); } private Settings loadFromClasspath(String path) { @@ -83,12 +83,12 @@ public class AnalysisModuleTests extends ESTestCase { } - public void testSimpleConfigurationJson() { + public void testSimpleConfigurationJson() throws IOException { Settings settings = loadFromClasspath("/org/elasticsearch/index/analysis/test1.json"); testSimpleConfiguration(settings); } - public void testSimpleConfigurationYaml() { + public void testSimpleConfigurationYaml() throws IOException { Settings settings = loadFromClasspath("/org/elasticsearch/index/analysis/test1.yml"); testSimpleConfiguration(settings); } @@ -106,11 +106,12 @@ public class AnalysisModuleTests extends ESTestCase { .put("path.home", createTempDir().toString()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0) .build(); - AnalysisService analysisService2 = getAnalysisService(settings2); - // indicesanalysisservice always has the current version - IndicesAnalysisService indicesAnalysisService2 = injector.getInstance(IndicesAnalysisService.class); - assertThat(indicesAnalysisService2.analyzer("default"), is(instanceOf(NamedAnalyzer.class))); - NamedAnalyzer defaultNamedAnalyzer = (NamedAnalyzer) indicesAnalysisService2.analyzer("default"); + AnalysisRegistry newRegistry = getNewRegistry(settings2); + AnalysisService analysisService2 = getAnalysisService(newRegistry, settings2); + + // registry always has the current version + assertThat(newRegistry.getAnalyzer("default"), is(instanceOf(NamedAnalyzer.class))); + NamedAnalyzer defaultNamedAnalyzer = (NamedAnalyzer) newRegistry.getAnalyzer("default"); assertThat(defaultNamedAnalyzer.analyzer(), is(instanceOf(StandardAnalyzer.class))); assertEquals(Version.CURRENT.luceneVersion, defaultNamedAnalyzer.analyzer().getVersion()); @@ -118,6 +119,9 @@ public class AnalysisModuleTests extends ESTestCase { assertThat(analysisService2.analyzer("standard").analyzer(), is(instanceOf(StandardAnalyzer.class))); assertEquals(Version.V_0_90_0.luceneVersion, analysisService2.analyzer("standard").analyzer().getVersion()); assertEquals(Version.V_0_90_0.luceneVersion, analysisService2.analyzer("thai").analyzer().getVersion()); + + assertThat(analysisService2.analyzer("custom7").analyzer(), is(instanceOf(StandardAnalyzer.class))); + assertEquals(org.apache.lucene.util.Version.fromBits(3,6,0), analysisService2.analyzer("custom7").analyzer().getVersion()); } private void assertTokenFilter(String name, Class clazz) throws IOException { @@ -132,7 +136,7 @@ public class AnalysisModuleTests extends ESTestCase { assertThat(stream, instanceOf(clazz)); } - private void testSimpleConfiguration(Settings settings) { + private void testSimpleConfiguration(Settings settings) throws IOException { AnalysisService analysisService = getAnalysisService(settings); Analyzer analyzer = analysisService.analyzer("custom1").analyzer(); @@ -233,7 +237,7 @@ public class AnalysisModuleTests extends ESTestCase { return wordListFile; } - public void testUnderscoreInAnalyzerName() { + public void testUnderscoreInAnalyzerName() throws IOException { Settings settings = Settings.builder() .put("index.analysis.analyzer._invalid_name.tokenizer", "keyword") .put("path.home", createTempDir().toString()) @@ -242,13 +246,12 @@ public class AnalysisModuleTests extends ESTestCase { try { getAnalysisService(settings); fail("This should fail with IllegalArgumentException because the analyzers name starts with _"); - } catch (ProvisionException e) { - assertTrue(e.getCause() instanceof IllegalArgumentException); - assertThat(e.getCause().getMessage(), either(equalTo("analyzer name must not start with '_'. got \"_invalid_name\"")).or(equalTo("analyzer name must not start with '_'. got \"_invalidName\""))); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), either(equalTo("analyzer name must not start with '_'. got \"_invalid_name\"")).or(equalTo("analyzer name must not start with '_'. got \"_invalidName\""))); } } - public void testUnderscoreInAnalyzerNameAlias() { + public void testUnderscoreInAnalyzerNameAlias() throws IOException { Settings settings = Settings.builder() .put("index.analysis.analyzer.valid_name.tokenizer", "keyword") .put("index.analysis.analyzer.valid_name.alias", "_invalid_name") @@ -258,13 +261,12 @@ public class AnalysisModuleTests extends ESTestCase { try { getAnalysisService(settings); fail("This should fail with IllegalArgumentException because the analyzers alias starts with _"); - } catch (ProvisionException e) { - assertTrue(e.getCause() instanceof IllegalArgumentException); - assertThat(e.getCause().getMessage(), equalTo("analyzer name must not start with '_'. got \"_invalid_name\"")); + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), equalTo("analyzer name must not start with '_'. got \"_invalid_name\"")); } } - public void testBackwardCompatible() { + public void testBackwardCompatible() throws IOException { Settings settings = settingsBuilder() .put("index.analysis.analyzer.custom1.tokenizer", "standard") .put("index.analysis.analyzer.custom1.position_offset_gap", "128") @@ -285,7 +287,7 @@ public class AnalysisModuleTests extends ESTestCase { assertThat(custom2.getPositionIncrementGap("custom2"), equalTo(256)); } - public void testWithBothSettings() { + public void testWithBothSettings() throws IOException { Settings settings = settingsBuilder() .put("index.analysis.analyzer.custom.tokenizer", "standard") .put("index.analysis.analyzer.custom.position_offset_gap", "128") @@ -297,14 +299,13 @@ public class AnalysisModuleTests extends ESTestCase { try { getAnalysisService(settings); fail("Analyzer has both position_offset_gap and position_increment_gap should fail"); - } catch (ProvisionException e) { - assertTrue(e.getCause() instanceof IllegalArgumentException); - assertThat(e.getCause().getMessage(), equalTo("Custom Analyzer [custom] defined both [position_offset_gap] and [position_increment_gap]" + + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), equalTo("Custom Analyzer [custom] defined both [position_offset_gap] and [position_increment_gap]" + ", use only [position_increment_gap]")); } } - public void testDeprecatedPositionOffsetGap() { + public void testDeprecatedPositionOffsetGap() throws IOException { Settings settings = settingsBuilder() .put("index.analysis.analyzer.custom.tokenizer", "standard") .put("index.analysis.analyzer.custom.position_offset_gap", "128") @@ -314,10 +315,22 @@ public class AnalysisModuleTests extends ESTestCase { try { getAnalysisService(settings); fail("Analyzer should fail if it has position_offset_gap"); - } catch (ProvisionException e) { - assertTrue(e.getCause() instanceof IllegalArgumentException); - assertThat(e.getCause().getMessage(), equalTo("Option [position_offset_gap] in Custom Analyzer [custom] " + + } catch (IllegalArgumentException e) { + assertThat(e.getMessage(), equalTo("Option [position_offset_gap] in Custom Analyzer [custom] " + "has been renamed, please use [position_increment_gap] instead.")); } } + + public void testRegisterHunspellDictionary() throws Exception { + Settings settings = settingsBuilder() + .put("path.home", createTempDir().toString()) + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .build(); + AnalysisModule module = new AnalysisModule(new Environment(settings)); + InputStream aff = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.aff"); + InputStream dic = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.dic"); + Dictionary dictionary = new Dictionary(aff, dic); + module.registerHunspellDictionary("foo", dictionary); + assertInstanceBinding(module, HunspellService.class, (x) -> x.getDictionary("foo") == dictionary); + } } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java index 981deeccf46..89ad9594469 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisServiceTests.java @@ -19,46 +19,48 @@ package org.elasticsearch.index.analysis; +import com.carrotsearch.randomizedtesting.generators.RandomPicks; +import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.en.EnglishAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.elasticsearch.test.VersionUtils; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; +import java.io.IOException; +import java.util.*; +import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.hamcrest.Matchers.instanceOf; public class AnalysisServiceTests extends ESTestCase { - private static AnalyzerProviderFactory analyzerProvider(final String name) { - return (name1, settings) -> new PreBuiltAnalyzerProvider(name1, AnalyzerScope.INDEX, new EnglishAnalyzer()); + private static AnalyzerProvider analyzerProvider(final String name) { + return new PreBuiltAnalyzerProvider(name, AnalyzerScope.INDEX, new EnglishAnalyzer()); } - public void testDefaultAnalyzers() { + public void testDefaultAnalyzers() throws IOException { Version version = VersionUtils.randomVersion(getRandom()); - Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); - IndicesAnalysisService indicesAnalysisService = new IndicesAnalysisService(settings); - AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), indicesAnalysisService, - Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); + Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).put("path.home", createTempDir().toString()).build(); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); assertThat(analysisService.defaultIndexAnalyzer().analyzer(), instanceOf(StandardAnalyzer.class)); assertThat(analysisService.defaultSearchAnalyzer().analyzer(), instanceOf(StandardAnalyzer.class)); assertThat(analysisService.defaultSearchQuoteAnalyzer().analyzer(), instanceOf(StandardAnalyzer.class)); } - public void testOverrideDefaultAnalyzer() { + public void testOverrideDefaultAnalyzer() throws IOException { Version version = VersionUtils.randomVersion(getRandom()); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); - IndicesAnalysisService indicesAnalysisService = new IndicesAnalysisService(settings); - AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), indicesAnalysisService, + AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), Collections.singletonMap("default", analyzerProvider("default")), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); assertThat(analysisService.defaultIndexAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class)); @@ -69,10 +71,9 @@ public class AnalysisServiceTests extends ESTestCase { public void testOverrideDefaultIndexAnalyzer() { Version version = VersionUtils.randomVersionBetween(getRandom(), Version.V_3_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); - IndicesAnalysisService indicesAnalysisService = new IndicesAnalysisService(settings); try { - AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), indicesAnalysisService, - Collections.singletonMap("default_index", new PreBuiltAnalyzerProviderFactory("default_index", AnalyzerScope.INDEX, new EnglishAnalyzer())), + AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), + Collections.singletonMap("default_index", new PreBuiltAnalyzerProvider("default_index", AnalyzerScope.INDEX, new EnglishAnalyzer())), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); fail("Expected ISE"); } catch (IllegalArgumentException e) { @@ -84,8 +85,7 @@ public class AnalysisServiceTests extends ESTestCase { public void testBackCompatOverrideDefaultIndexAnalyzer() { Version version = VersionUtils.randomVersionBetween(getRandom(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_3_0_0)); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); - IndicesAnalysisService indicesAnalysisService = new IndicesAnalysisService(settings); - AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), indicesAnalysisService, + AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), Collections.singletonMap("default_index", analyzerProvider("default_index")), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); assertThat(analysisService.defaultIndexAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class)); @@ -96,8 +96,7 @@ public class AnalysisServiceTests extends ESTestCase { public void testOverrideDefaultSearchAnalyzer() { Version version = VersionUtils.randomVersion(getRandom()); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); - IndicesAnalysisService indicesAnalysisService = new IndicesAnalysisService(settings); - AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), indicesAnalysisService, + AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), Collections.singletonMap("default_search", analyzerProvider("default_search")), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); assertThat(analysisService.defaultIndexAnalyzer().analyzer(), instanceOf(StandardAnalyzer.class)); @@ -108,14 +107,101 @@ public class AnalysisServiceTests extends ESTestCase { public void testBackCompatOverrideDefaultIndexAndSearchAnalyzer() { Version version = VersionUtils.randomVersionBetween(getRandom(), VersionUtils.getFirstVersion(), VersionUtils.getPreviousVersion(Version.V_3_0_0)); Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); - IndicesAnalysisService indicesAnalysisService = new IndicesAnalysisService(settings); - Map analyzers = new HashMap<>(); + Map analyzers = new HashMap<>(); analyzers.put("default_index", analyzerProvider("default_index")); analyzers.put("default_search", analyzerProvider("default_search")); - AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), indicesAnalysisService, + AnalysisService analysisService = new AnalysisService(IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.EMPTY_LIST), analyzers, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); assertThat(analysisService.defaultIndexAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class)); assertThat(analysisService.defaultSearchAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class)); assertThat(analysisService.defaultSearchQuoteAnalyzer().analyzer(), instanceOf(EnglishAnalyzer.class)); } + + public void testConfigureCamelCaseTokenFilter() throws IOException { + // tests a filter that + Settings settings = Settings.builder().put("path.home", createTempDir().toString()).build(); + Settings indexSettings = settingsBuilder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("index.analysis.filter.wordDelimiter.type", "word_delimiter") + .put("index.analysis.filter.wordDelimiter.split_on_numerics", false) + .put("index.analysis.analyzer.custom_analyzer.tokenizer", "whitespace") + .putArray("index.analysis.analyzer.custom_analyzer.filter", "lowercase", "wordDelimiter") + .put("index.analysis.analyzer.custom_analyzer_1.tokenizer", "whitespace") + .putArray("index.analysis.analyzer.custom_analyzer_1.filter", "lowercase", "word_delimiter").build(); + + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), indexSettings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); + try (NamedAnalyzer custom_analyser = analysisService.analyzer("custom_analyzer")) { + assertNotNull(custom_analyser); + TokenStream tokenStream = custom_analyser.tokenStream("foo", "J2SE j2ee"); + tokenStream.reset(); + CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class); + List token = new ArrayList<>(); + while(tokenStream.incrementToken()) { + token.add(charTermAttribute.toString()); + } + assertEquals(token.toString(), 2, token.size()); + assertEquals("j2se", token.get(0)); + assertEquals("j2ee", token.get(1)); + } + + try (NamedAnalyzer custom_analyser = analysisService.analyzer("custom_analyzer_1")) { + assertNotNull(custom_analyser); + TokenStream tokenStream = custom_analyser.tokenStream("foo", "J2SE j2ee"); + tokenStream.reset(); + CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class); + List token = new ArrayList<>(); + while(tokenStream.incrementToken()) { + token.add(charTermAttribute.toString()); + } + assertEquals(token.toString(), 6, token.size()); + assertEquals("j", token.get(0)); + assertEquals("2", token.get(1)); + assertEquals("se", token.get(2)); + assertEquals("j", token.get(3)); + assertEquals("2", token.get(4)); + assertEquals("ee", token.get(5)); + } + } + + public void testCameCaseOverride() throws IOException { + Settings settings = Settings.builder().put("path.home", createTempDir().toString()).build(); + Settings indexSettings = settingsBuilder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) + .put("index.analysis.filter.wordDelimiter.type", "word_delimiter") + .put("index.analysis.filter.wordDelimiter.split_on_numerics", false) + .put("index.analysis.analyzer.custom_analyzer.tokenizer", "whitespace") + .putArray("index.analysis.analyzer.custom_analyzer.filter", "lowercase", "wordDelimiter") + .put("index.analysis.analyzer.custom_analyzer_1.tokenizer", "whitespace") + .putArray("index.analysis.analyzer.custom_analyzer_1.filter", "lowercase", "word_delimiter").build(); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), indexSettings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); + + TokenFilterFactory word_delimiter = analysisService.tokenFilter("word_delimiter"); + TokenFilterFactory override = analysisService.tokenFilter("wordDelimiter"); + assertNotEquals(word_delimiter.name(), override.name()); + assertNotSame(analysisService.tokenFilter("wordDelimiter"), analysisService.tokenFilter("word_delimiter")); + assertSame(analysisService.tokenFilter("porterStem"), analysisService.tokenFilter("porter_stem")); + + //unconfigured + IndexSettings idxSettings1 = IndexSettingsModule.newIndexSettings(new Index("index"), settingsBuilder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(), Collections.EMPTY_LIST); + AnalysisService analysisService1 = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings1); + assertSame(analysisService1.tokenFilter("wordDelimiter"), analysisService1.tokenFilter("word_delimiter")); + assertSame(analysisService1.tokenFilter("porterStem"), analysisService1.tokenFilter("porter_stem")); + } + + public void testBuiltInAnalyzersAreCached() throws IOException { + Settings settings = Settings.builder().put("path.home", createTempDir().toString()).build(); + Settings indexSettings = settingsBuilder() + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), indexSettings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); + AnalysisService otherAnalysisSergice = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); + final int numIters = randomIntBetween(5, 20); + for (int i = 0; i < numIters; i++) { + PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(random(), PreBuiltAnalyzers.values()); + assertSame(analysisService.analyzer(preBuiltAnalyzers.name()), otherAnalysisSergice.analyzer(preBuiltAnalyzers.name())); + } + } } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTestsHelper.java b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTestsHelper.java index 8459341dac4..b6ba4b4dba0 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTestsHelper.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/AnalysisTestsHelper.java @@ -21,22 +21,20 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.IndicesModule; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.indices.analysis.HunspellService; import org.elasticsearch.test.IndexSettingsModule; +import java.io.IOException; import java.nio.file.Path; +import java.util.Collections; public class AnalysisTestsHelper { - public static AnalysisService createAnalysisServiceFromClassPath(Path baseDir, String resource) { + public static AnalysisService createAnalysisServiceFromClassPath(Path baseDir, String resource) throws IOException { Settings settings = Settings.settingsBuilder() .loadFromStream(resource, AnalysisTestsHelper.class.getResourceAsStream(resource)) .put("path.home", baseDir.toString()) @@ -46,27 +44,13 @@ public class AnalysisTestsHelper { } public static AnalysisService createAnalysisServiceFromSettings( - Settings settings) { + Settings settings) throws IOException { Index index = new Index("test"); if (settings.get(IndexMetaData.SETTING_VERSION_CREATED) == null) { settings = Settings.builder().put(settings).put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); } - IndicesModule indicesModule = new IndicesModule() { - @Override - public void configure() { - // skip services - bindHunspellExtension(); - } - }; - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), - new EnvironmentModule(new Environment(settings)), indicesModule).createInjector(); - - AnalysisModule analysisModule = new AnalysisModule(settings, - parentInjector.getInstance(IndicesAnalysisService.class)); - - Injector injector = new ModulesBuilder().add(new IndexSettingsModule(index, settings), - analysisModule).createChildInjector(parentInjector); - - return injector.getInstance(AnalysisService.class); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + Environment environment = new Environment(settings); + return new AnalysisRegistry(new HunspellService(settings, environment, Collections.EMPTY_MAP), environment).build(idxSettings); } } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java b/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java index aa95a305433..34f5939559a 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/CharFilterTests.java @@ -20,17 +20,15 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.ESTokenStreamTestCase; import org.elasticsearch.test.IndexSettingsModule; +import java.util.Collections; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; /** @@ -46,14 +44,8 @@ public class CharFilterTests extends ESTokenStreamTestCase { .putArray("index.analysis.analyzer.custom_with_char_filter.char_filter", "my_mapping") .put("path.home", createTempDir().toString()) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))) - .createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); - + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); NamedAnalyzer analyzer1 = analysisService.analyzer("custom_with_char_filter"); assertTokenStreamContents(analyzer1.tokenStream("test", "jeff quit phish"), new String[]{"jeff", "qit", "fish"}); @@ -70,13 +62,8 @@ public class CharFilterTests extends ESTokenStreamTestCase { .putArray("index.analysis.analyzer.custom_with_char_filter.char_filter", "html_strip") .put("path.home", createTempDir().toString()) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))) - .createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); NamedAnalyzer analyzer1 = analysisService.analyzer("custom_with_char_filter"); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java b/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java index 0c7150ec471..89276a8a242 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/CompoundAnalysisTests.java @@ -24,24 +24,21 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.lucene.all.AllEntries; import org.elasticsearch.common.lucene.all.AllTokenStream; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.compound.DictionaryCompoundWordTokenFilterFactory; import org.elasticsearch.index.analysis.filter1.MyFilterTokenFilterFactory; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.hamcrest.MatcherAssert; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -55,15 +52,9 @@ public class CompoundAnalysisTests extends ESTestCase { public void testDefaultsCompoundAnalysis() throws Exception { Index index = new Index("test"); Settings settings = getJsonSettings(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)); - analysisModule.addTokenFilter("myfilter", MyFilterTokenFilterFactory.class); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - analysisModule) - .createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings), + Collections.EMPTY_MAP,Collections.singletonMap("myfilter", MyFilterTokenFilterFactory::new),Collections.EMPTY_MAP,Collections.EMPTY_MAP).build(idxSettings); TokenFilterFactory filterFactory = analysisService.tokenFilter("dict_dec"); MatcherAssert.assertThat(filterFactory, instanceOf(DictionaryCompoundWordTokenFilterFactory.class)); @@ -80,15 +71,9 @@ public class CompoundAnalysisTests extends ESTestCase { private List analyze(Settings settings, String analyzerName, String text) throws IOException { Index index = new Index("test"); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)); - analysisModule.addTokenFilter("myfilter", MyFilterTokenFilterFactory.class); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - analysisModule) - .createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings), + Collections.EMPTY_MAP, Collections.singletonMap("myfilter", MyFilterTokenFilterFactory::new),Collections.EMPTY_MAP,Collections.EMPTY_MAP).build(idxSettings); Analyzer analyzer = analysisService.analyzer(analyzerName).analyzer(); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java index fc1459a170a..99c936cd346 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/KeepFilterFactoryTests.java @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.instanceOf; public class KeepFilterFactoryTests extends ESTokenStreamTestCase { private static final String RESOURCE = "/org/elasticsearch/index/analysis/keep_analysis.json"; - public void testLoadWithoutSettings() { + public void testLoadWithoutSettings() throws IOException { AnalysisService analysisService = AnalysisTestsHelper.createAnalysisServiceFromClassPath(createTempDir(), RESOURCE); TokenFilterFactory tokenFilter = analysisService.tokenFilter("keep"); Assert.assertNull(tokenFilter); @@ -49,8 +49,9 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase { try { AnalysisTestsHelper.createAnalysisServiceFromSettings(settings); Assert.fail("path and array are configured"); - } catch (Exception e) { - assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); + } catch (IllegalArgumentException e) { + } catch (IOException e) { + fail("expected IAE"); } } @@ -64,8 +65,9 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase { // test our none existing setup is picked up AnalysisTestsHelper.createAnalysisServiceFromSettings(settings); fail("expected an exception due to non existent keep_words_path"); - } catch (Throwable e) { - assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); + } catch (IllegalArgumentException e) { + } catch (IOException e) { + fail("expected IAE"); } settings = Settings.settingsBuilder().put(settings) @@ -75,8 +77,9 @@ public class KeepFilterFactoryTests extends ESTokenStreamTestCase { // test our none existing setup is picked up AnalysisTestsHelper.createAnalysisServiceFromSettings(settings); fail("expected an exception indicating that you can't use [keep_words_path] with [keep_words] "); - } catch (Throwable e) { - assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); + } catch (IllegalArgumentException e) { + } catch (IOException e) { + fail("expected IAE"); } } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java index b7d3201778d..c467f642d73 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/NGramTokenizerFactoryTests.java @@ -56,7 +56,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { for (String tokenChars : Arrays.asList("letters", "number", "DIRECTIONALITY_UNDEFINED")) { final Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", tokenChars).build(); try { - new NGramTokenizerFactory(indexProperties, name, settings).create(); + new NGramTokenizerFactory(indexProperties, null, name, settings).create(); fail(); } catch (IllegalArgumentException expected) { // OK @@ -66,7 +66,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { final Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", tokenChars).build(); indexProperties = IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST); - new NGramTokenizerFactory(indexProperties, name, settings).create(); + new NGramTokenizerFactory(indexProperties, null, name, settings).create(); // no exception } } @@ -76,7 +76,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { final String name = "ngr"; final Settings indexSettings = newAnalysisSettingsBuilder().build(); final Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 4).putArray("token_chars", new String[0]).build(); - Tokenizer tokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer tokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); tokenizer.setReader(new StringReader("1.34")); assertTokenStreamContents(tokenizer, new String[] {"1.", "1.3", "1.34", ".3", ".34", "34"}); } @@ -87,12 +87,12 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { final String name = "ngr"; final Settings indexSettings = newAnalysisSettingsBuilder().build(); Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", "letter,digit").build(); - Tokenizer tokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer tokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); tokenizer.setReader(new StringReader("Åbc déf g\uD801\uDC00f ")); assertTokenStreamContents(tokenizer, new String[] {"Åb", "Åbc", "bc", "dé", "déf", "éf", "g\uD801\uDC00", "g\uD801\uDC00f", "\uD801\uDC00f"}); settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", "letter,digit,punctuation,whitespace,symbol").build(); - tokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + tokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); tokenizer.setReader(new StringReader(" a!$ 9")); assertTokenStreamContents(tokenizer, new String[] {" a", " a!", "a!", "a!$", "!$", "!$ ", "$ ", "$ 9", " 9"}); @@ -104,12 +104,12 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { final String name = "ngr"; final Settings indexSettings = newAnalysisSettingsBuilder().build(); Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", "letter,digit").build(); - Tokenizer tokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer tokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); tokenizer.setReader(new StringReader("Åbc déf g\uD801\uDC00f ")); assertTokenStreamContents(tokenizer, new String[] {"Åb", "Åbc", "dé", "déf", "g\uD801\uDC00", "g\uD801\uDC00f"}); settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("token_chars", "letter,digit,punctuation,whitespace,symbol").build(); - tokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + tokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); tokenizer.setReader(new StringReader(" a!$ 9")); assertTokenStreamContents(tokenizer, new String[] {" a", " a!"}); @@ -130,7 +130,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { } Settings settings = builder.build(); Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build(); - Tokenizer edgeNGramTokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer edgeNGramTokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); edgeNGramTokenizer.setReader(new StringReader("foo bar")); if (compatVersion) { assertThat(edgeNGramTokenizer, instanceOf(Lucene43EdgeNGramTokenizer.class)); @@ -141,7 +141,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { } else { Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("side", "back").build(); Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build(); - Tokenizer edgeNGramTokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer edgeNGramTokenizer = new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); edgeNGramTokenizer.setReader(new StringReader("foo bar")); assertThat(edgeNGramTokenizer, instanceOf(Lucene43EdgeNGramTokenizer.class)); } @@ -149,7 +149,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).put("side", "back").build(); Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); try { - new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + new EdgeNGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); fail("should fail side:back is not supported anymore"); } catch (IllegalArgumentException ex) { } @@ -170,7 +170,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { } Settings settings = builder.build(); Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build(); - Tokenizer nGramTokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer nGramTokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); nGramTokenizer.setReader(new StringReader("foo bar")); if (compatVersion) { assertThat(nGramTokenizer, instanceOf(Lucene43NGramTokenizer.class)); @@ -181,7 +181,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { } else { Settings settings = newAnalysisSettingsBuilder().put("min_gram", 2).put("max_gram", 3).build(); Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build(); - Tokenizer nGramTokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(); + Tokenizer nGramTokenizer = new NGramTokenizerFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(); nGramTokenizer.setReader(new StringReader("foo bar")); assertThat(nGramTokenizer, instanceOf(Lucene43NGramTokenizer.class)); } @@ -208,7 +208,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build(); Tokenizer tokenizer = new MockTokenizer(); tokenizer.setReader(new StringReader("foo bar")); - TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(tokenizer); + TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(tokenizer); if (reverse) { assertThat(edgeNGramTokenFilter, instanceOf(ReverseStringFilter.class)); } else if (compatVersion) { @@ -227,7 +227,7 @@ public class NGramTokenizerFactoryTests extends ESTokenStreamTestCase { Settings indexSettings = newAnalysisSettingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, v.id).build(); Tokenizer tokenizer = new MockTokenizer(); tokenizer.setReader(new StringReader("foo bar")); - TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), name, settings).create(tokenizer); + TokenStream edgeNGramTokenFilter = new EdgeNGramTokenFilterFactory(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.EMPTY_LIST), null, name, settings).create(tokenizer); if (reverse) { assertThat(edgeNGramTokenFilter, instanceOf(ReverseStringFilter.class)); } else { diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java index a74079ec285..6b11685817c 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/PatternCaptureTokenFilterTests.java @@ -21,15 +21,10 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import org.elasticsearch.test.ESTokenStreamTestCase; import org.elasticsearch.test.IndexSettingsModule; @@ -41,19 +36,14 @@ import static org.hamcrest.Matchers.containsString; public class PatternCaptureTokenFilterTests extends ESTokenStreamTestCase { public void testPatternCaptureTokenFilter() throws Exception { String json = "/org/elasticsearch/index/analysis/pattern_capture.json"; - Index index = new Index("test"); Settings settings = settingsBuilder() .put("path.home", createTempDir()) .loadFromStream(json, getClass().getResourceAsStream(json)) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))) - .createChildInjector(parentInjector); - AnalysisService analysisService = injector.getInstance(AnalysisService.class); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.emptyList()); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); NamedAnalyzer analyzer1 = analysisService.analyzer("single"); @@ -70,7 +60,7 @@ public class PatternCaptureTokenFilterTests extends ESTokenStreamTestCase { public void testNoPatterns() { try { - new PatternCaptureGroupTokenFilterFactory(IndexSettingsModule.newIndexSettings(new Index("test"), Settings.EMPTY, Collections.EMPTY_LIST), "pattern_capture", settingsBuilder().put("pattern", "foobar").build()); + new PatternCaptureGroupTokenFilterFactory(IndexSettingsModule.newIndexSettings(new Index("test"), Settings.EMPTY, Collections.EMPTY_LIST), null, "pattern_capture", settingsBuilder().put("pattern", "foobar").build()); fail ("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("required setting 'patterns' is missing")); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java index a5064880798..39de728a484 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltCharFilterFactoryFactoryTests.java @@ -24,18 +24,20 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.analysis.PreBuiltCharFilters; import org.elasticsearch.test.ESTestCase; +import java.io.IOException; + import static org.hamcrest.CoreMatchers.is; /** * */ public class PreBuiltCharFilterFactoryFactoryTests extends ESTestCase { - public void testThatDifferentVersionsCanBeLoaded() { + public void testThatDifferentVersionsCanBeLoaded() throws IOException { PreBuiltCharFilterFactoryFactory factory = new PreBuiltCharFilterFactoryFactory(PreBuiltCharFilters.HTML_STRIP.getCharFilterFactory(Version.CURRENT)); - CharFilterFactory former090TokenizerFactory = factory.create("html_strip", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0).build()); - CharFilterFactory former090TokenizerFactoryCopy = factory.create("html_strip", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0).build()); - CharFilterFactory currentTokenizerFactory = factory.create("html_strip", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); + CharFilterFactory former090TokenizerFactory = factory.get(null, null, "html_strip", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0).build()); + CharFilterFactory former090TokenizerFactoryCopy = factory.get(null, null, "html_strip", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_0).build()); + CharFilterFactory currentTokenizerFactory = factory.get(null, null, "html_strip", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); assertThat(currentTokenizerFactory, is(former090TokenizerFactory)); assertThat(currentTokenizerFactory, is(former090TokenizerFactoryCopy)); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java index 27113793e9c..670df069926 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenFilterFactoryFactoryTests.java @@ -24,6 +24,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.analysis.PreBuiltTokenFilters; import org.elasticsearch.test.ESTestCase; +import java.io.IOException; + import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; @@ -31,23 +33,23 @@ import static org.hamcrest.CoreMatchers.not; * */ public class PreBuiltTokenFilterFactoryFactoryTests extends ESTestCase { - public void testThatCachingWorksForCachingStrategyOne() { + public void testThatCachingWorksForCachingStrategyOne() throws IOException { PreBuiltTokenFilterFactoryFactory factory = new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.WORD_DELIMITER.getTokenFilterFactory(Version.CURRENT)); - TokenFilterFactory former090TokenizerFactory = factory.create("word_delimiter", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_1).build()); - TokenFilterFactory former090TokenizerFactoryCopy = factory.create("word_delimiter", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_2).build()); - TokenFilterFactory currentTokenizerFactory = factory.create("word_delimiter", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); + TokenFilterFactory former090TokenizerFactory = factory.get(null, null, "word_delimiter", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_1).build()); + TokenFilterFactory former090TokenizerFactoryCopy = factory.get(null, null, "word_delimiter", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_2).build()); + TokenFilterFactory currentTokenizerFactory = factory.get(null, null, "word_delimiter", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); assertThat(currentTokenizerFactory, is(former090TokenizerFactory)); assertThat(currentTokenizerFactory, is(former090TokenizerFactoryCopy)); } - public void testThatDifferentVersionsCanBeLoaded() { + public void testThatDifferentVersionsCanBeLoaded() throws IOException { PreBuiltTokenFilterFactoryFactory factory = new PreBuiltTokenFilterFactoryFactory(PreBuiltTokenFilters.STOP.getTokenFilterFactory(Version.CURRENT)); - TokenFilterFactory former090TokenizerFactory = factory.create("stop", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_1).build()); - TokenFilterFactory former090TokenizerFactoryCopy = factory.create("stop", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_2).build()); - TokenFilterFactory currentTokenizerFactory = factory.create("stop", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); + TokenFilterFactory former090TokenizerFactory = factory.get(null, null, "stop", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_1).build()); + TokenFilterFactory former090TokenizerFactoryCopy = factory.get(null, null, "stop", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_2).build()); + TokenFilterFactory currentTokenizerFactory = factory.get(null, null, "stop", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); assertThat(currentTokenizerFactory, is(not(former090TokenizerFactory))); assertThat(former090TokenizerFactory, is(former090TokenizerFactoryCopy)); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java index ecf52a9dadb..162dbb36424 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltTokenizerFactoryFactoryTests.java @@ -24,6 +24,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.indices.analysis.PreBuiltTokenizers; import org.elasticsearch.test.ESTestCase; +import java.io.IOException; + import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; @@ -31,13 +33,13 @@ import static org.hamcrest.CoreMatchers.not; * */ public class PreBuiltTokenizerFactoryFactoryTests extends ESTestCase { - public void testThatDifferentVersionsCanBeLoaded() { + public void testThatDifferentVersionsCanBeLoaded() throws IOException { PreBuiltTokenizerFactoryFactory factory = new PreBuiltTokenizerFactoryFactory(PreBuiltTokenizers.STANDARD.getTokenizerFactory(Version.CURRENT)); // different es versions, same lucene version, thus cached - TokenizerFactory former090TokenizerFactory = factory.create("standard", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_1).build()); - TokenizerFactory former090TokenizerFactoryCopy = factory.create("standard", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_2).build()); - TokenizerFactory currentTokenizerFactory = factory.create("standard", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); + TokenizerFactory former090TokenizerFactory = factory.get(null, null, "standard", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_1).build()); + TokenizerFactory former090TokenizerFactoryCopy = factory.get(null, null, "standard", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_0_90_2).build()); + TokenizerFactory currentTokenizerFactory = factory.get(null, null, "standard", Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build()); assertThat(currentTokenizerFactory, is(not(former090TokenizerFactory))); assertThat(currentTokenizerFactory, is(not(former090TokenizerFactoryCopy))); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java index 0379fced877..9aea985809b 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/StopAnalyzerTests.java @@ -21,35 +21,27 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.test.ESTokenStreamTestCase; import org.elasticsearch.test.IndexSettingsModule; +import java.util.Collections; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; public class StopAnalyzerTests extends ESTokenStreamTestCase { public void testDefaultsCompoundAnalysis() throws Exception { String json = "/org/elasticsearch/index/analysis/stop.json"; - Index index = new Index("test"); Settings settings = settingsBuilder() .loadFromStream(json, getClass().getResourceAsStream(json)) .put("path.home", createTempDir().toString()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))) - .createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.emptyList()); + AnalysisService analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); NamedAnalyzer analyzer1 = analysisService.analyzer("analyzer1"); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java b/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java index 79e49cd8b89..aa063a1d37e 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/StopTokenFilterTests.java @@ -49,8 +49,8 @@ public class StopTokenFilterTests extends ESTokenStreamTestCase { Settings settings = builder.build(); try { AnalysisTestsHelper.createAnalysisServiceFromSettings(settings); - fail("Expected ProvisionException"); - } catch (ProvisionException e) { + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("enable_position_increments is not supported anymore")); } } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java b/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java index e7a1ebf579a..52730dd2616 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/commongrams/CommonGramsTokenFilterFactoryTests.java @@ -46,8 +46,9 @@ public class CommonGramsTokenFilterFactoryTests extends ESTokenStreamTestCase { try { AnalysisTestsHelper.createAnalysisServiceFromSettings(settings); Assert.fail("[common_words] or [common_words_path] is set"); - } catch (Exception e) { - assertThat(e.getCause(), instanceOf(IllegalArgumentException.class)); + } catch (IllegalArgumentException e) { + } catch (IOException e) { + fail("expected IAE"); } } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java b/core/src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java index 60256a5a955..c7cd3cd625e 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/filter1/MyFilterTokenFilterFactory.java @@ -21,15 +21,14 @@ package org.elasticsearch.index.analysis.filter1; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.StopAnalyzer; import org.apache.lucene.analysis.core.StopFilter; -import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AbstractTokenFilterFactory; public class MyFilterTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject - public MyFilterTokenFilterFactory(IndexSettings indexSettings, String name) { + public MyFilterTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, Settings.Builder.EMPTY_SETTINGS); } diff --git a/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java b/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java index de67c578b01..67b90590fb9 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/synonyms/SynonymsAnalysisTests.java @@ -24,20 +24,16 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetaData; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.lucene.all.AllEntries; import org.elasticsearch.common.lucene.all.AllTokenStream; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; -import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.analysis.AnalysisService; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.hamcrest.MatcherAssert; @@ -46,6 +42,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.hamcrest.Matchers.equalTo; @@ -71,18 +68,9 @@ public class SynonymsAnalysisTests extends ESTestCase { .put("path.home", home) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); - Index index = new Index("test"); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(new Index("index"), settings, Collections.emptyList()); + analysisService = new AnalysisRegistry(null, new Environment(settings)).build(idxSettings); - Injector parentInjector = new ModulesBuilder().add( - new SettingsModule(settings), - new EnvironmentModule(new Environment(settings))) - .createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))) - .createChildInjector(parentInjector); - - analysisService = injector.getInstance(AnalysisService.class); match("synonymAnalyzer", "kimchy is the dude abides", "shay is the elasticsearch man!"); match("synonymAnalyzer_file", "kimchy is the dude abides", "shay is the elasticsearch man!"); diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index fe7fb7c41b0..88278727ae2 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -1920,7 +1920,7 @@ public class InternalEngineTests extends ESTestCase { RootObjectMapper.Builder rootBuilder = new RootObjectMapper.Builder("test"); Index index = new Index(indexName); IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); - AnalysisService analysisService = new AnalysisService(indexSettings); + AnalysisService analysisService = new AnalysisService(indexSettings, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP); SimilarityService similarityService = new SimilarityService(indexSettings, Collections.EMPTY_MAP); MapperService mapperService = new MapperService(indexSettings, analysisService, similarityService, null); DocumentMapper.Builder b = new DocumentMapper.Builder(settings, rootBuilder, mapperService); diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java index 01f61969606..677da47a2de 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java @@ -23,6 +23,7 @@ import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator; import com.fasterxml.jackson.core.io.JsonStringEncoder; import org.apache.lucene.search.Query; +import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.get.GetRequest; @@ -59,7 +60,8 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.analysis.AnalysisRegistry; +import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.cache.IndexCache; import org.elasticsearch.index.cache.bitset.BitsetFilterCache; import org.elasticsearch.index.cache.query.none.NoneQueryCache; @@ -70,7 +72,6 @@ import org.elasticsearch.index.query.support.QueryParsers; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.indices.IndicesWarmer; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.script.*; @@ -156,6 +157,7 @@ public abstract class AbstractQueryTestCase> Settings indexSettings = Settings.settingsBuilder() .put(IndexMetaData.SETTING_VERSION_CREATED, version).build(); index = new Index(randomAsciiOfLengthBetween(1, 10)); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.emptyList()); final TestClusterService clusterService = new TestClusterService(); clusterService.setState(new ClusterState.Builder(clusterService.state()).metaData(new MetaData.Builder().put( new IndexMetaData.Builder(index.name()).settings(indexSettings).numberOfShards(1).numberOfReplicas(0)))); @@ -207,11 +209,14 @@ public abstract class AbstractQueryTestCase> } }, new IndexSettingsModule(index, indexSettings), - new AnalysisModule(indexSettings, new IndicesAnalysisService(indexSettings)), new AbstractModule() { @Override protected void configure() { - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.emptyList()); + try { + bind(AnalysisService.class).toInstance(new AnalysisRegistry(null, new Environment(settings)).build(idxSettings)); + } catch (IOException e) { + throw new ElasticsearchException(e); + } SimilarityService service = new SimilarityService(idxSettings, Collections.emptyMap()); bind(SimilarityService.class).toInstance(service); BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(idxSettings, new IndicesWarmer(idxSettings.getNodeSettings(), null)); diff --git a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java index 22eb8cc39b7..c5b8e8ce2ff 100644 --- a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.index.query; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; +import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterService; @@ -38,7 +39,8 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.analysis.AnalysisRegistry; +import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.cache.IndexCache; import org.elasticsearch.index.cache.bitset.BitsetFilterCache; import org.elasticsearch.index.cache.query.none.NoneQueryCache; @@ -46,7 +48,6 @@ import org.elasticsearch.index.query.functionscore.ScoreFunctionParser; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.indices.IndicesWarmer; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.script.ScriptModule; @@ -86,6 +87,7 @@ public class TemplateQueryParserTests extends ESTestCase { throw new UnsupportedOperationException("client is just a dummy"); }); Index index = new Index("test"); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); injector = new ModulesBuilder().add( new EnvironmentModule(new Environment(settings)), new SettingsModule(settings), @@ -99,11 +101,14 @@ public class TemplateQueryParserTests extends ESTestCase { }, new ScriptModule(settings), new IndexSettingsModule(index, settings), - new AnalysisModule(settings, new IndicesAnalysisService(settings)), new AbstractModule() { @Override protected void configure() { - IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); + try { + bind(AnalysisService.class).toInstance(new AnalysisRegistry(null, new Environment(settings)).build(idxSettings)); + } catch (IOException e) { + throw new ElasticsearchException(e); + } SimilarityService service = new SimilarityService(idxSettings, Collections.EMPTY_MAP); BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(idxSettings, new IndicesWarmer(idxSettings.getNodeSettings(), null)); bind(BitsetFilterCache.class).toInstance(bitsetFilterCache); diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java b/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java index 3070735672f..968266f00c3 100644 --- a/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java +++ b/core/src/test/java/org/elasticsearch/indices/IndicesModuleTests.java @@ -62,15 +62,6 @@ public class IndicesModuleTests extends ModuleTestCase { } } - public void testRegisterHunspellDictionary() throws Exception { - IndicesModule module = new IndicesModule(); - InputStream aff = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.aff"); - InputStream dic = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.dic"); - Dictionary dictionary = new Dictionary(aff, dic); - module.registerHunspellDictionary("foo", dictionary); - assertMapInstanceBinding(module, String.class, Dictionary.class, Collections.singletonMap("foo", dictionary)); - } - public void testRegisterHunspellDictionaryDuplicate() { IndicesModule module = new IndicesModule(); try { diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisBinderProcessor.java b/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisBinderProcessor.java deleted file mode 100644 index fdb5ab05bde..00000000000 --- a/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisBinderProcessor.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.elasticsearch.index.analysis.AnalysisModule; - -/** - */ -public class DummyAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor { - - @Override - public void processAnalyzers(AnalyzersBindings analyzersBindings) { - analyzersBindings.processAnalyzer("dummy", DummyAnalyzerProvider.class); - } - - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - tokenFiltersBindings.processTokenFilter("dummy_token_filter", DummyTokenFilterFactory.class); - } - - @Override - public void processTokenizers(TokenizersBindings tokenizersBindings) { - tokenizersBindings.processTokenizer("dummy_tokenizer", DummyTokenizerFactory.class); - } - - @Override - public void processCharFilters(CharFiltersBindings charFiltersBindings) { - charFiltersBindings.processCharFilter("dummy_char_filter", DummyCharFilterFactory.class); - } -} diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisPlugin.java b/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisPlugin.java index 003771f8cc7..8e15a6f02f4 100644 --- a/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisPlugin.java +++ b/core/src/test/java/org/elasticsearch/indices/analysis/DummyAnalysisPlugin.java @@ -19,13 +19,8 @@ package org.elasticsearch.indices.analysis; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.index.analysis.AnalysisModule; import org.elasticsearch.plugins.Plugin; -import java.util.Collection; -import java.util.Collections; - public class DummyAnalysisPlugin extends Plugin { /** * The name of the plugin. @@ -43,13 +38,12 @@ public class DummyAnalysisPlugin extends Plugin { return "Analysis Dummy Plugin"; } - @Override - public Collection nodeModules() { - return Collections.singletonList(new DummyIndicesAnalysisModule()); - } public void onModule(AnalysisModule module) { - module.addProcessor(new DummyAnalysisBinderProcessor()); + module.registerAnalyzer("dummy", (a, b, c, d) -> new DummyAnalyzerProvider()); + module.registerTokenFilter("dummy_token_filter", (a, b, c, d) -> new DummyTokenFilterFactory()); + module.registerTokenizer("dummy_tokenizer", (a, b, c, d) -> new DummyTokenizerFactory()); + module.registerCharFilter("dummy_char_filter", (a, b, c, d) -> new DummyCharFilterFactory()); } } diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysis.java b/core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysis.java deleted file mode 100644 index 9642b610f69..00000000000 --- a/core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysis.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.analysis.*; - -public class DummyIndicesAnalysis extends AbstractComponent { - - @Inject - public DummyIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { - super(settings); - indicesAnalysisService.analyzerProviderFactories().put("dummy", - new PreBuiltAnalyzerProviderFactory("dummy", AnalyzerScope.INDICES, - new DummyAnalyzer())); - indicesAnalysisService.tokenFilterFactories().put("dummy_token_filter", - new PreBuiltTokenFilterFactoryFactory(new DummyTokenFilterFactory())); - indicesAnalysisService.charFilterFactories().put("dummy_char_filter", - new PreBuiltCharFilterFactoryFactory(new DummyCharFilterFactory())); - indicesAnalysisService.tokenizerFactories().put("dummy_tokenizer", - new PreBuiltTokenizerFactoryFactory(new DummyTokenizerFactory())); - } -} diff --git a/core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysisModule.java b/core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysisModule.java deleted file mode 100644 index 9d14f67ec60..00000000000 --- a/core/src/test/java/org/elasticsearch/indices/analysis/DummyIndicesAnalysisModule.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.elasticsearch.common.inject.AbstractModule; - -public class DummyIndicesAnalysisModule extends AbstractModule { - - @Override - protected void configure() { - bind(DummyIndicesAnalysis.class).asEagerSingleton(); - } -} diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java deleted file mode 100644 index 8db169b9318..00000000000 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; - -/** - */ -public class IcuAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor { - - @Override - public void processCharFilters(CharFiltersBindings charFiltersBindings) { - charFiltersBindings.processCharFilter("icu_normalizer", IcuNormalizerCharFilterFactory.class); - } - - @Override - public void processTokenizers(TokenizersBindings tokenizersBindings) { - tokenizersBindings.processTokenizer("icu_tokenizer", IcuTokenizerFactory.class); - } - - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - tokenFiltersBindings.processTokenFilter("icu_normalizer", IcuNormalizerTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("icu_folding", IcuFoldingTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("icu_collation", IcuCollationTokenFilterFactory.class); - tokenFiltersBindings.processTokenFilter("icu_transform", IcuTransformTokenFilterFactory.class); - } -} diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java index 6a9fb44cf2b..1e7cd1b09f4 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java @@ -23,8 +23,6 @@ import com.ibm.icu.text.Collator; import com.ibm.icu.text.RuleBasedCollator; import com.ibm.icu.util.ULocale; import org.apache.lucene.analysis.TokenStream; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -47,8 +45,7 @@ public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory { private final Collator collator; - @Inject - public IcuCollationTokenFilterFactory(IndexSettings indexSettings, Environment environment, @Assisted String name, @Assisted Settings settings) { + public IcuCollationTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); Collator collator; diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java index aac49ec8217..51243856a1f 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java @@ -21,13 +21,12 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.icu.ICUFoldingFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import com.ibm.icu.text.FilteredNormalizer2; import com.ibm.icu.text.Normalizer2; import com.ibm.icu.text.UnicodeSet; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -45,12 +44,13 @@ import org.elasticsearch.index.IndexSettings; public class IcuFoldingTokenFilterFactory extends AbstractTokenFilterFactory { private final String unicodeSetFilter; - @Inject public IcuFoldingTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public IcuFoldingTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.unicodeSetFilter = settings.get("unicodeSetFilter"); } - @Override public TokenStream create(TokenStream tokenStream) { + @Override + public TokenStream create(TokenStream tokenStream) { // The ICUFoldingFilter is in fact implemented as a ICUNormalizer2Filter. // ICUFoldingFilter lacks a constructor for adding filtering so we implemement it here diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerCharFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerCharFilterFactory.java index a3ae823cb74..02f9b5a3371 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerCharFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerCharFilterFactory.java @@ -22,9 +22,8 @@ package org.elasticsearch.index.analysis; import com.ibm.icu.text.Normalizer2; import org.apache.lucene.analysis.icu.ICUNormalizer2CharFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import java.io.Reader; @@ -41,9 +40,7 @@ public class IcuNormalizerCharFilterFactory extends AbstractCharFilterFactory { private final Normalizer2 normalizer; - - @Inject - public IcuNormalizerCharFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public IcuNormalizerCharFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name); this.name = settings.get("name", "nfkc_cf"); String mode = settings.get("mode"); diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java index ebd68615ee1..6f830b29d15 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java @@ -24,6 +24,7 @@ import org.apache.lucene.analysis.TokenStream; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -37,8 +38,7 @@ public class IcuNormalizerTokenFilterFactory extends AbstractTokenFilterFactory private final String name; - @Inject - public IcuNormalizerTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public IcuNormalizerTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.name = settings.get("name", "nfkc_cf"); } diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTokenizerFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTokenizerFactory.java index c5c220e51b9..0d2a6cdeb22 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTokenizerFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTokenizerFactory.java @@ -21,17 +21,15 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.icu.segmentation.ICUTokenizer; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; /** */ public class IcuTokenizerFactory extends AbstractTokenizerFactory { - @Inject - public IcuTokenizerFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public IcuTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); } diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTransformTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTransformTokenFilterFactory.java index 9be90ba2ab4..1d5136f60e1 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTransformTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuTransformTokenFilterFactory.java @@ -25,6 +25,7 @@ import org.apache.lucene.analysis.icu.ICUTransformFilter; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -37,7 +38,7 @@ public class IcuTransformTokenFilterFactory extends AbstractTokenFilterFactory { private final Transliterator transliterator; @Inject - public IcuTransformTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public IcuTransformTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.id = settings.get("id", "Null"); String s = settings.get("dir", "forward"); diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysis.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysis.java deleted file mode 100644 index cc7d56994da..00000000000 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysis.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import com.ibm.icu.text.Collator; -import com.ibm.icu.text.Normalizer2; -import com.ibm.icu.text.Transliterator; - -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.icu.ICUFoldingFilter; -import org.apache.lucene.analysis.icu.ICUNormalizer2CharFilter; -import org.apache.lucene.analysis.icu.ICUTransformFilter; -import org.apache.lucene.analysis.icu.segmentation.ICUTokenizer; -import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.analysis.ICUCollationKeyFilter; -import org.elasticsearch.index.analysis.PreBuiltCharFilterFactoryFactory; -import org.elasticsearch.index.analysis.PreBuiltTokenFilterFactoryFactory; -import org.elasticsearch.index.analysis.PreBuiltTokenizerFactoryFactory; -import org.elasticsearch.index.analysis.CharFilterFactory; -import org.elasticsearch.index.analysis.TokenFilterFactory; -import org.elasticsearch.index.analysis.TokenizerFactory; - -import java.io.Reader; - -/** - * Registers indices level analysis components so, if not explicitly configured, will be shared - * among all indices. - */ -public class IcuIndicesAnalysis extends AbstractComponent { - - @Inject - public IcuIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { - super(settings); - - indicesAnalysisService.tokenizerFactories().put("icu_tokenizer", new PreBuiltTokenizerFactoryFactory(new TokenizerFactory() { - @Override - public String name() { - return "icu_tokenizer"; - } - - @Override - public Tokenizer create() { - return new ICUTokenizer(); - } - })); - - indicesAnalysisService.tokenFilterFactories().put("icu_normalizer", new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "icu_normalizer"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new org.apache.lucene.analysis.icu.ICUNormalizer2Filter(tokenStream, Normalizer2.getInstance(null, "nfkc_cf", Normalizer2.Mode.COMPOSE)); - } - })); - - - indicesAnalysisService.tokenFilterFactories().put("icu_folding", new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "icu_folding"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new ICUFoldingFilter(tokenStream); - } - })); - - indicesAnalysisService.tokenFilterFactories().put("icu_collation", new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "icu_collation"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new ICUCollationKeyFilter(tokenStream, Collator.getInstance()); - } - })); - - indicesAnalysisService.tokenFilterFactories().put("icu_transform", new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "icu_transform"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new ICUTransformFilter(tokenStream, Transliterator.getInstance("Null", Transliterator.FORWARD)); - } - })); - - indicesAnalysisService.charFilterFactories().put("icu_normalizer", new PreBuiltCharFilterFactoryFactory(new CharFilterFactory() { - @Override - public String name() { - return "icu_normalizer"; - } - - @Override - public Reader create(Reader reader) { - return new ICUNormalizer2CharFilter(reader); - } - })); - } -} diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysisModule.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysisModule.java deleted file mode 100644 index e7587205a04..00000000000 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/indices/analysis/IcuIndicesAnalysisModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - */ -public class IcuIndicesAnalysisModule extends AbstractModule { - - @Override - protected void configure() { - bind(IcuIndicesAnalysis.class).asEagerSingleton(); - } -} diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java index 6b9314cacff..47c2f8f051a 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java @@ -19,15 +19,10 @@ package org.elasticsearch.plugin.analysis.icu; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.index.analysis.AnalysisModule; -import org.elasticsearch.index.analysis.IcuAnalysisBinderProcessor; -import org.elasticsearch.indices.analysis.IcuIndicesAnalysisModule; +import org.elasticsearch.index.analysis.*; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.plugins.Plugin; -import java.util.Collection; -import java.util.Collections; - /** * */ @@ -43,15 +38,15 @@ public class AnalysisICUPlugin extends Plugin { return "UTF related ICU analysis support"; } - @Override - public Collection nodeModules() { - return Collections.singletonList(new IcuIndicesAnalysisModule()); - } - /** * Automatically called with the analysis module. */ public void onModule(AnalysisModule module) { - module.addProcessor(new IcuAnalysisBinderProcessor()); + module.registerCharFilter("icu_normalizer", IcuNormalizerCharFilterFactory::new); + module.registerTokenizer("icu_tokenizer", IcuTokenizerFactory::new); + module.registerTokenFilter("icu_normalizer", IcuNormalizerTokenFilterFactory::new); + module.registerTokenFilter("icu_folding", IcuFoldingTokenFilterFactory::new); + module.registerTokenFilter("icu_collation", IcuCollationTokenFilterFactory::new); + module.registerTokenFilter("icu_transform", IcuTransformTokenFilterFactory::new); } } diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/AnalysisTestUtils.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/AnalysisTestUtils.java index a25a8bfd016..10c9ba09017 100644 --- a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/AnalysisTestUtils.java +++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/AnalysisTestUtils.java @@ -28,24 +28,28 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin; import org.elasticsearch.test.IndexSettingsModule; +import java.io.IOException; +import java.util.Collections; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; public class AnalysisTestUtils { - public static AnalysisService createAnalysisService(Settings settings) { + public static AnalysisService createAnalysisService(Settings settings) throws IOException { Index index = new Index("test"); Settings indexSettings = settingsBuilder().put(settings) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, indexSettings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new IcuAnalysisBinderProcessor())) - .createChildInjector(parentInjector); - - return injector.getInstance(AnalysisService.class); + AnalysisModule analysisModule = new AnalysisModule(new Environment(settings)); + new AnalysisICUPlugin().onModule(analysisModule); + Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), + new EnvironmentModule(new Environment(settings)), analysisModule) + .createInjector(); + final AnalysisService analysisService = parentInjector.getInstance(AnalysisRegistry.class).build(IndexSettingsModule.newIndexSettings(index, indexSettings, Collections.emptyList())); + return analysisService; } } diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java index 5dfff29b2a8..d4b2530dbb6 100644 --- a/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java +++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java @@ -22,13 +22,15 @@ package org.elasticsearch.index.analysis; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESTestCase; +import java.io.IOException; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.index.analysis.AnalysisTestUtils.createAnalysisService; import static org.hamcrest.Matchers.instanceOf; /** */ public class SimpleIcuAnalysisTests extends ESTestCase { - public void testDefaultsIcuAnalysis() { + public void testDefaultsIcuAnalysis() throws IOException { Settings settings = settingsBuilder() .put("path.home", createTempDir()).build(); AnalysisService analysisService = createAnalysisService(settings); diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java index 8e574296a39..7b760bc4f63 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java @@ -25,8 +25,6 @@ import org.apache.lucene.analysis.core.StopFilter; import org.apache.lucene.analysis.ja.JapaneseAnalyzer; import org.apache.lucene.analysis.util.CharArraySet; import org.apache.lucene.search.suggest.analyzing.SuggestStopFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -45,8 +43,7 @@ public class JapaneseStopTokenFilterFactory extends AbstractTokenFilterFactory{ private final boolean removeTrailing; - @Inject - public JapaneseStopTokenFilterFactory(IndexSettings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + public JapaneseStopTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); this.ignoreCase = settings.getAsBoolean("ignore_case", false); this.removeTrailing = settings.getAsBoolean("remove_trailing", true); diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiAnalyzerProvider.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiAnalyzerProvider.java index c6bf5df8b29..8aa8ff3c1dd 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiAnalyzerProvider.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiAnalyzerProvider.java @@ -24,7 +24,6 @@ import org.apache.lucene.analysis.ja.JapaneseTokenizer; import org.apache.lucene.analysis.ja.dict.UserDictionary; import org.apache.lucene.analysis.util.CharArraySet; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -38,7 +37,7 @@ public class KuromojiAnalyzerProvider extends AbstractIndexAnalyzerProvider stopWords = Analysis.parseStopWords(env, settings, JapaneseAnalyzer.getDefaultStopSet()); final JapaneseTokenizer.Mode mode = KuromojiTokenizerFactory.getMode(settings); diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiBaseFormFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiBaseFormFilterFactory.java index 7922aa966d2..f363cf0c15c 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiBaseFormFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiBaseFormFilterFactory.java @@ -24,12 +24,13 @@ import org.apache.lucene.analysis.ja.JapaneseBaseFormFilter; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; public class KuromojiBaseFormFilterFactory extends AbstractTokenFilterFactory { @Inject - public KuromojiBaseFormFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public KuromojiBaseFormFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); } diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java index 916a0091b9f..a1220dba2be 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiIterationMarkCharFilterFactory.java @@ -20,9 +20,8 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.ja.JapaneseIterationMarkCharFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import java.io.Reader; @@ -32,9 +31,7 @@ public class KuromojiIterationMarkCharFilterFactory extends AbstractCharFilterFa private final boolean normalizeKanji; private final boolean normalizeKana; - @Inject - public KuromojiIterationMarkCharFilterFactory(IndexSettings indexSettings, - @Assisted String name, @Assisted Settings settings) { + public KuromojiIterationMarkCharFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name); normalizeKanji = settings.getAsBoolean("normalize_kanji", JapaneseIterationMarkCharFilter.NORMALIZE_KANJI_DEFAULT); normalizeKana = settings.getAsBoolean("normalize_kana", JapaneseIterationMarkCharFilter.NORMALIZE_KANA_DEFAULT); diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiKatakanaStemmerFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiKatakanaStemmerFactory.java index f1986d6cce6..7d25ca03fdb 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiKatakanaStemmerFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiKatakanaStemmerFactory.java @@ -24,6 +24,7 @@ import org.apache.lucene.analysis.ja.JapaneseKatakanaStemFilter; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; public class KuromojiKatakanaStemmerFactory extends AbstractTokenFilterFactory { @@ -31,7 +32,7 @@ public class KuromojiKatakanaStemmerFactory extends AbstractTokenFilterFactory { private final int minimumLength; @Inject - public KuromojiKatakanaStemmerFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public KuromojiKatakanaStemmerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); minimumLength = settings.getAsInt("minimum_length", JapaneseKatakanaStemFilter.DEFAULT_MINIMUM_LENGTH); } diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiPartOfSpeechFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiPartOfSpeechFilterFactory.java index 5fb293daec9..4598f6293ce 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiPartOfSpeechFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiPartOfSpeechFilterFactory.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.ja.JapanesePartOfSpeechStopFilter; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -35,8 +33,7 @@ public class KuromojiPartOfSpeechFilterFactory extends AbstractTokenFilterFactor private final Set stopTags = new HashSet(); - @Inject - public KuromojiPartOfSpeechFilterFactory(IndexSettings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + public KuromojiPartOfSpeechFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); List wordList = Analysis.getWordList(env, settings, "stoptags"); if (wordList != null) { diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java index 55251a1a93d..1d4ecc2c33d 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiReadingFormFilterFactory.java @@ -24,6 +24,7 @@ import org.apache.lucene.analysis.ja.JapaneseReadingFormFilter; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; public class KuromojiReadingFormFilterFactory extends AbstractTokenFilterFactory { @@ -31,7 +32,7 @@ public class KuromojiReadingFormFilterFactory extends AbstractTokenFilterFactory private final boolean useRomaji; @Inject - public KuromojiReadingFormFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public KuromojiReadingFormFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); useRomaji = settings.getAsBoolean("use_romaji", false); } diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java index 6a9bc617bc9..87e08c757b4 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/KuromojiTokenizerFactory.java @@ -24,8 +24,6 @@ import org.apache.lucene.analysis.ja.JapaneseTokenizer; import org.apache.lucene.analysis.ja.JapaneseTokenizer.Mode; import org.apache.lucene.analysis.ja.dict.UserDictionary; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -44,8 +42,7 @@ public class KuromojiTokenizerFactory extends AbstractTokenizerFactory { private boolean discartPunctuation; - @Inject - public KuromojiTokenizerFactory(IndexSettings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { + public KuromojiTokenizerFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); mode = getMode(settings); userDictionary = getUserDictionary(env, settings); diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysis.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysis.java deleted file mode 100644 index ba5d58073a3..00000000000 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysis.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.ja.*; -import org.apache.lucene.analysis.ja.JapaneseTokenizer.Mode; -import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.analysis.*; - -import java.io.Reader; - -/** - * Registers indices level analysis components so, if not explicitly configured, - * will be shared among all indices. - */ -public class KuromojiIndicesAnalysis extends AbstractComponent { - - @Inject - public KuromojiIndicesAnalysis(Settings settings, - IndicesAnalysisService indicesAnalysisService) { - super(settings); - - indicesAnalysisService.analyzerProviderFactories().put("kuromoji", - new PreBuiltAnalyzerProviderFactory("kuromoji", AnalyzerScope.INDICES, - new JapaneseAnalyzer())); - - indicesAnalysisService.charFilterFactories().put("kuromoji_iteration_mark", - new PreBuiltCharFilterFactoryFactory(new CharFilterFactory() { - @Override - public String name() { - return "kuromoji_iteration_mark"; - } - - @Override - public Reader create(Reader reader) { - return new JapaneseIterationMarkCharFilter(reader, - JapaneseIterationMarkCharFilter.NORMALIZE_KANJI_DEFAULT, - JapaneseIterationMarkCharFilter.NORMALIZE_KANA_DEFAULT); - } - })); - - indicesAnalysisService.tokenizerFactories().put("kuromoji_tokenizer", - new PreBuiltTokenizerFactoryFactory(new TokenizerFactory() { - @Override - public String name() { - return "kuromoji_tokenizer"; - } - - @Override - public Tokenizer create() { - return new JapaneseTokenizer(null, true, Mode.SEARCH); - } - })); - - indicesAnalysisService.tokenFilterFactories().put("kuromoji_baseform", - new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "kuromoji_baseform"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new JapaneseBaseFormFilter(tokenStream); - } - })); - - indicesAnalysisService.tokenFilterFactories().put( - "kuromoji_part_of_speech", - new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "kuromoji_part_of_speech"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new JapanesePartOfSpeechStopFilter(tokenStream, JapaneseAnalyzer - .getDefaultStopTags()); - } - })); - - indicesAnalysisService.tokenFilterFactories().put( - "kuromoji_readingform", - new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "kuromoji_readingform"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new JapaneseReadingFormFilter(tokenStream, true); - } - })); - - indicesAnalysisService.tokenFilterFactories().put("kuromoji_stemmer", - new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "kuromoji_stemmer"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return new JapaneseKatakanaStemFilter(tokenStream); - } - })); - } -} diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysisModule.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysisModule.java deleted file mode 100644 index 8046aece373..00000000000 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/indices/analysis/KuromojiIndicesAnalysisModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - */ -public class KuromojiIndicesAnalysisModule extends AbstractModule { - - @Override - protected void configure() { - bind(KuromojiIndicesAnalysis.class).asEagerSingleton(); - } -} diff --git a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/plugin/analysis/kuromoji/AnalysisKuromojiPlugin.java b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/plugin/analysis/kuromoji/AnalysisKuromojiPlugin.java index 46dce43b307..fde7d3d5964 100644 --- a/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/plugin/analysis/kuromoji/AnalysisKuromojiPlugin.java +++ b/plugins/analysis-kuromoji/src/main/java/org/elasticsearch/plugin/analysis/kuromoji/AnalysisKuromojiPlugin.java @@ -19,8 +19,7 @@ package org.elasticsearch.plugin.analysis.kuromoji; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.index.analysis.JapaneseStopTokenFilterFactory; import org.elasticsearch.index.analysis.KuromojiAnalyzerProvider; import org.elasticsearch.index.analysis.KuromojiBaseFormFilterFactory; @@ -29,12 +28,8 @@ import org.elasticsearch.index.analysis.KuromojiKatakanaStemmerFactory; import org.elasticsearch.index.analysis.KuromojiPartOfSpeechFilterFactory; import org.elasticsearch.index.analysis.KuromojiReadingFormFilterFactory; import org.elasticsearch.index.analysis.KuromojiTokenizerFactory; -import org.elasticsearch.indices.analysis.KuromojiIndicesAnalysisModule; import org.elasticsearch.plugins.Plugin; -import java.util.Collection; -import java.util.Collections; - /** * */ @@ -50,19 +45,15 @@ public class AnalysisKuromojiPlugin extends Plugin { return "Kuromoji analysis support"; } - @Override - public Collection nodeModules() { - return Collections.singletonList(new KuromojiIndicesAnalysisModule()); - } public void onModule(AnalysisModule module) { - module.addCharFilter("kuromoji_iteration_mark", KuromojiIterationMarkCharFilterFactory.class); - module.addAnalyzer("kuromoji", KuromojiAnalyzerProvider.class); - module.addTokenizer("kuromoji_tokenizer", KuromojiTokenizerFactory.class); - module.addTokenFilter("kuromoji_baseform", KuromojiBaseFormFilterFactory.class); - module.addTokenFilter("kuromoji_part_of_speech", KuromojiPartOfSpeechFilterFactory.class); - module.addTokenFilter("kuromoji_readingform", KuromojiReadingFormFilterFactory.class); - module.addTokenFilter("kuromoji_stemmer", KuromojiKatakanaStemmerFactory.class); - module.addTokenFilter("ja_stop", JapaneseStopTokenFilterFactory.class); + module.registerCharFilter("kuromoji_iteration_mark", KuromojiIterationMarkCharFilterFactory::new); + module.registerAnalyzer("kuromoji", KuromojiAnalyzerProvider::new); + module.registerTokenizer("kuromoji_tokenizer", KuromojiTokenizerFactory::new); + module.registerTokenFilter("kuromoji_baseform", KuromojiBaseFormFilterFactory::new); + module.registerTokenFilter("kuromoji_part_of_speech", KuromojiPartOfSpeechFilterFactory::new); + module.registerTokenFilter("kuromoji_readingform", KuromojiReadingFormFilterFactory::new); + module.registerTokenFilter("kuromoji_stemmer", KuromojiKatakanaStemmerFactory::new); + module.registerTokenFilter("ja_stop", JapaneseStopTokenFilterFactory::new); } } diff --git a/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java b/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java index c43488b4213..f866331c011 100644 --- a/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java +++ b/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java @@ -33,7 +33,7 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.plugin.analysis.kuromoji.AnalysisKuromojiPlugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; @@ -44,6 +44,7 @@ import java.io.Reader; import java.io.StringReader; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -204,19 +205,13 @@ public class KuromojiAnalysisTests extends ESTestCase { Index index = new Index("test"); + AnalysisModule analysisModule = new AnalysisModule(new Environment(settings)); + new AnalysisKuromojiPlugin().onModule(analysisModule); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), - new EnvironmentModule(new Environment(settings))) + new EnvironmentModule(new Environment(settings)), analysisModule) .createInjector(); - AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)); - new AnalysisKuromojiPlugin().onModule(analysisModule); - - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - analysisModule) - .createChildInjector(parentInjector); - - return injector.getInstance(AnalysisService.class); + return parentInjector.getInstance(AnalysisRegistry.class).build(IndexSettingsModule.newIndexSettings(index, settings, Collections.emptyList())); } public static void assertSimpleTSOutput(TokenStream stream, diff --git a/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml b/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml index dfeac8b18ff..92c6527fe6a 100644 --- a/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml +++ b/plugins/analysis-kuromoji/src/test/resources/rest-api-spec/test/analysis_kuromoji/10_basic.yaml @@ -42,7 +42,7 @@ tokenizer: kuromoji_tokenizer filters: kuromoji_readingform - length: { tokens: 1 } - - match: { tokens.0.token: sushi } + - match: { tokens.0.token: スシ } --- "Stemming filter": - do: diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticAnalysisBinderProcessor.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticAnalysisBinderProcessor.java deleted file mode 100644 index 45d7634081e..00000000000 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticAnalysisBinderProcessor.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; - -/** - */ -public class PhoneticAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor { - - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - tokenFiltersBindings.processTokenFilter("phonetic", PhoneticTokenFilterFactory.class); - } -} diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java index 05093772647..e661a12db85 100644 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java +++ b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java @@ -32,6 +32,7 @@ import org.apache.lucene.analysis.phonetic.PhoneticFilter; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.phonetic.HaasePhonetik; import org.elasticsearch.index.analysis.phonetic.KoelnerPhonetik; @@ -53,7 +54,7 @@ public class PhoneticTokenFilterFactory extends AbstractTokenFilterFactory { private RuleType ruletype; @Inject - public PhoneticTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public PhoneticTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); this.languageset = null; this.nametype = null; diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/plugin/analysis/AnalysisPhoneticPlugin.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/plugin/analysis/AnalysisPhoneticPlugin.java index 1ef97c62e73..3156a6adfe3 100644 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/plugin/analysis/AnalysisPhoneticPlugin.java +++ b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/plugin/analysis/AnalysisPhoneticPlugin.java @@ -19,8 +19,8 @@ package org.elasticsearch.plugin.analysis; -import org.elasticsearch.index.analysis.AnalysisModule; -import org.elasticsearch.index.analysis.PhoneticAnalysisBinderProcessor; +import org.elasticsearch.index.analysis.PhoneticTokenFilterFactory; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.plugins.Plugin; /** @@ -38,7 +38,7 @@ public class AnalysisPhoneticPlugin extends Plugin { } public void onModule(AnalysisModule module) { - module.addProcessor(new PhoneticAnalysisBinderProcessor()); + module.registerTokenFilter("phonetic", PhoneticTokenFilterFactory::new); } } diff --git a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java index a276e96362d..ce6e993f831 100644 --- a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java +++ b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java @@ -28,18 +28,22 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.plugin.analysis.AnalysisPhoneticPlugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.hamcrest.MatcherAssert; +import java.io.IOException; +import java.util.Collections; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.hamcrest.Matchers.instanceOf; /** */ public class SimplePhoneticAnalysisTests extends ESTestCase { - public void testPhoneticTokenFilterFactory() { + public void testPhoneticTokenFilterFactory() throws IOException { String yaml = "/org/elasticsearch/index/analysis/phonetic-1.yml"; Settings settings = settingsBuilder().loadFromStream(yaml, getClass().getResourceAsStream(yaml)) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) @@ -50,17 +54,13 @@ public class SimplePhoneticAnalysisTests extends ESTestCase { MatcherAssert.assertThat(filterFactory, instanceOf(PhoneticTokenFilterFactory.class)); } - private AnalysisService testSimpleConfiguration(Settings settings) { + private AnalysisService testSimpleConfiguration(Settings settings) throws IOException { Index index = new Index("test"); - + AnalysisModule analysisModule = new AnalysisModule(new Environment(settings)); + new AnalysisPhoneticPlugin().onModule(analysisModule); Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), - new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)) - .addProcessor(new PhoneticAnalysisBinderProcessor())).createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); - return analysisService; + new EnvironmentModule(new Environment(settings)), analysisModule) + .createInjector(); + return parentInjector.getInstance(AnalysisRegistry.class).build(IndexSettingsModule.newIndexSettings(index, settings, Collections.emptyList())); } } diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java deleted file mode 100644 index 4f498f116e5..00000000000 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalysisBinderProcessor.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis; - -/** - */ -public class SmartChineseAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor { - - @Override - public void processAnalyzers(AnalyzersBindings analyzersBindings) { - analyzersBindings.processAnalyzer("smartcn", SmartChineseAnalyzerProvider.class); - } - - @Override - public void processTokenizers(TokenizersBindings tokenizersBindings) { - tokenizersBindings.processTokenizer("smartcn_tokenizer", SmartChineseTokenizerTokenizerFactory.class); - // This is an alias to "smartcn_tokenizer"; it's here for backwards compat - tokenizersBindings.processTokenizer("smartcn_sentence", SmartChineseTokenizerTokenizerFactory.class); - } - - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - // This is a noop token filter; it's here for backwards compat before we had "smartcn_tokenizer" - tokenFiltersBindings.processTokenFilter("smartcn_word", SmartChineseNoOpTokenFilterFactory.class); - } -} diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalyzerProvider.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalyzerProvider.java index 61ef93f5a3d..1daaa4b0a3d 100644 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalyzerProvider.java +++ b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseAnalyzerProvider.java @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; /** @@ -32,7 +33,7 @@ public class SmartChineseAnalyzerProvider extends AbstractIndexAnalyzerProvider< private final SmartChineseAnalyzer analyzer; @Inject - public SmartChineseAnalyzerProvider(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public SmartChineseAnalyzerProvider(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); analyzer = new SmartChineseAnalyzer(SmartChineseAnalyzer.getDefaultStopSet()); diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseNoOpTokenFilterFactory.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseNoOpTokenFilterFactory.java index a4d6b9e45e1..e0f9f556896 100644 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseNoOpTokenFilterFactory.java +++ b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseNoOpTokenFilterFactory.java @@ -23,12 +23,12 @@ import org.apache.lucene.analysis.TokenStream; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; public class SmartChineseNoOpTokenFilterFactory extends AbstractTokenFilterFactory { - @Inject - public SmartChineseNoOpTokenFilterFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public SmartChineseNoOpTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); } diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseTokenizerTokenizerFactory.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseTokenizerTokenizerFactory.java index ee78aa4547c..7dade32f0e8 100644 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseTokenizerTokenizerFactory.java +++ b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/index/analysis/SmartChineseTokenizerTokenizerFactory.java @@ -24,12 +24,12 @@ import org.apache.lucene.analysis.cn.smart.HMMChineseTokenizer; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; public class SmartChineseTokenizerTokenizerFactory extends AbstractTokenizerFactory { - @Inject - public SmartChineseTokenizerTokenizerFactory(IndexSettings indexSettings, @Assisted String name, @Assisted Settings settings) { + public SmartChineseTokenizerTokenizerFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); } diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysis.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysis.java deleted file mode 100644 index 78a9934fc5a..00000000000 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysis.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis.smartcn; - -import org.apache.lucene.analysis.Tokenizer; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.cn.smart.HMMChineseTokenizer; -import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer; -import org.elasticsearch.common.component.AbstractComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.analysis.*; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; - -import java.io.Reader; - -/** - * Registers indices level analysis components so, if not explicitly configured, will be shared - * among all indices. - */ -public class SmartChineseIndicesAnalysis extends AbstractComponent { - - @Inject - public SmartChineseIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) { - super(settings); - - // Register smartcn analyzer - indicesAnalysisService.analyzerProviderFactories().put("smartcn", new PreBuiltAnalyzerProviderFactory("smartcn", AnalyzerScope.INDICES, new SmartChineseAnalyzer())); - - // Register smartcn_tokenizer tokenizer - indicesAnalysisService.tokenizerFactories().put("smartcn_tokenizer", new PreBuiltTokenizerFactoryFactory(new TokenizerFactory() { - @Override - public String name() { - return "smartcn_tokenizer"; - } - - @Override - public Tokenizer create() { - return new HMMChineseTokenizer(); - } - })); - - // Register smartcn_sentence tokenizer -- for backwards compat an alias to smartcn_tokenizer - indicesAnalysisService.tokenizerFactories().put("smartcn_sentence", new PreBuiltTokenizerFactoryFactory(new TokenizerFactory() { - @Override - public String name() { - return "smartcn_sentence"; - } - - @Override - public Tokenizer create() { - return new HMMChineseTokenizer(); - } - })); - - // Register smartcn_word token filter -- noop - indicesAnalysisService.tokenFilterFactories().put("smartcn_word", new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() { - @Override - public String name() { - return "smartcn_word"; - } - - @Override - public TokenStream create(TokenStream tokenStream) { - return tokenStream; - } - })); - } -} diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysisModule.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysisModule.java deleted file mode 100644 index e02ae80dfb5..00000000000 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/indices/analysis/smartcn/SmartChineseIndicesAnalysisModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.indices.analysis.smartcn; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - */ -public class SmartChineseIndicesAnalysisModule extends AbstractModule { - - @Override - protected void configure() { - bind(SmartChineseIndicesAnalysis.class).asEagerSingleton(); - } -} diff --git a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/plugin/analysis/smartcn/AnalysisSmartChinesePlugin.java b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/plugin/analysis/smartcn/AnalysisSmartChinesePlugin.java index 92b933fd725..801c51f8e81 100644 --- a/plugins/analysis-smartcn/src/main/java/org/elasticsearch/plugin/analysis/smartcn/AnalysisSmartChinesePlugin.java +++ b/plugins/analysis-smartcn/src/main/java/org/elasticsearch/plugin/analysis/smartcn/AnalysisSmartChinesePlugin.java @@ -19,15 +19,12 @@ package org.elasticsearch.plugin.analysis.smartcn; -import org.elasticsearch.common.inject.Module; -import org.elasticsearch.index.analysis.AnalysisModule; -import org.elasticsearch.index.analysis.SmartChineseAnalysisBinderProcessor; -import org.elasticsearch.indices.analysis.smartcn.SmartChineseIndicesAnalysisModule; +import org.elasticsearch.index.analysis.SmartChineseAnalyzerProvider; +import org.elasticsearch.index.analysis.SmartChineseNoOpTokenFilterFactory; +import org.elasticsearch.index.analysis.SmartChineseTokenizerTokenizerFactory; +import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.plugins.Plugin; -import java.util.Collection; -import java.util.Collections; - /** * */ @@ -43,12 +40,12 @@ public class AnalysisSmartChinesePlugin extends Plugin { return "Smart Chinese analysis support"; } - @Override - public Collection nodeModules() { - return Collections.singletonList(new SmartChineseIndicesAnalysisModule()); - } - public void onModule(AnalysisModule module) { - module.addProcessor(new SmartChineseAnalysisBinderProcessor()); + module.registerAnalyzer("smartcn", SmartChineseAnalyzerProvider::new); + module.registerTokenizer("smartcn_tokenizer", SmartChineseTokenizerTokenizerFactory::new); + // This is an alias to "smartcn_tokenizer"; it's here for backwards compat + module.registerTokenizer("smartcn_sentence", SmartChineseTokenizerTokenizerFactory::new); + // This is a noop token filter; it's here for backwards compat before we had "smartcn_tokenizer" + module.registerTokenFilter("smartcn_word", SmartChineseNoOpTokenFilterFactory::new); } } diff --git a/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java b/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java index 4456eeaba9c..a899f4aeb7c 100644 --- a/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java +++ b/plugins/analysis-smartcn/src/test/java/org/elasticsearch/index/analysis/SimpleSmartChineseAnalysisTests.java @@ -28,32 +28,33 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.plugin.analysis.smartcn.AnalysisSmartChinesePlugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.hamcrest.MatcherAssert; +import java.io.IOException; +import java.util.Collections; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; -import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS; import static org.hamcrest.Matchers.instanceOf; /** */ public class SimpleSmartChineseAnalysisTests extends ESTestCase { - public void testDefaultsIcuAnalysis() { + public void testDefaultsIcuAnalysis() throws IOException { Index index = new Index("test"); Settings settings = settingsBuilder() .put("path.home", createTempDir()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new SmartChineseAnalysisBinderProcessor())) - .createChildInjector(parentInjector); - - AnalysisService analysisService = injector.getInstance(AnalysisService.class); - + AnalysisModule analysisModule = new AnalysisModule(new Environment(settings)); + new AnalysisSmartChinesePlugin().onModule(analysisModule); + Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), + new EnvironmentModule(new Environment(settings)), analysisModule) + .createInjector(); + final AnalysisService analysisService = parentInjector.getInstance(AnalysisRegistry.class).build(IndexSettingsModule.newIndexSettings(index, settings, Collections.emptyList())); TokenizerFactory tokenizerFactory = analysisService.tokenizer("smartcn_tokenizer"); MatcherAssert.assertThat(tokenizerFactory, instanceOf(SmartChineseTokenizerTokenizerFactory.class)); } diff --git a/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java b/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java deleted file mode 100644 index 408d80cd983..00000000000 --- a/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalysisBinderProcessor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.index.analysis.pl; - -import org.elasticsearch.index.analysis.AnalysisModule; - -/** - */ -public class PolishAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor { - - @Override - public void processAnalyzers(AnalyzersBindings analyzersBindings) { - analyzersBindings.processAnalyzer("polish", PolishAnalyzerProvider.class); - } - @Override - public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) { - tokenFiltersBindings.processTokenFilter("polish_stem", PolishStemTokenFilterFactory.class); - } -} diff --git a/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java b/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java index 4c6ea0188a3..d80939cea04 100644 --- a/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java +++ b/plugins/analysis-stempel/src/main/java/org/elasticsearch/index/analysis/pl/PolishAnalyzerProvider.java @@ -20,9 +20,8 @@ package org.elasticsearch.index.analysis.pl; import org.apache.lucene.analysis.pl.PolishAnalyzer; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.inject.assistedinject.Assisted; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider; @@ -32,8 +31,7 @@ public class PolishAnalyzerProvider extends AbstractIndexAnalyzerProvider nodeModules() { - return Collections.singletonList(new PolishIndicesAnalysisModule()); - } - public void onModule(AnalysisModule module) { - module.addProcessor(new PolishAnalysisBinderProcessor()); + module.registerAnalyzer("polish", PolishAnalyzerProvider::new); + module.registerTokenFilter("polish_stem", PolishStemTokenFilterFactory::new); } } diff --git a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java index 1a0376b721c..91990ef4a56 100644 --- a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java +++ b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/PolishAnalysisTests.java @@ -30,13 +30,16 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.index.analysis.pl.PolishAnalysisBinderProcessor; import org.elasticsearch.index.analysis.pl.PolishStemTokenFilterFactory; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.plugin.analysis.stempel.AnalysisStempelPlugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.hamcrest.MatcherAssert; +import java.io.IOException; +import java.util.Collections; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.settings.Settings.Builder.EMPTY_SETTINGS; import static org.hamcrest.Matchers.instanceOf; @@ -44,21 +47,21 @@ import static org.hamcrest.Matchers.instanceOf; /** */ public class PolishAnalysisTests extends ESTestCase { - public void testDefaultsPolishAnalysis() { + public void testDefaultsPolishAnalysis() throws IOException { Index index = new Index("test"); Settings settings = settingsBuilder() .put("path.home", createTempDir()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new PolishAnalysisBinderProcessor())) - .createChildInjector(parentInjector); - AnalysisService analysisService = injector.getInstance(AnalysisService.class); + AnalysisModule analysisModule = new AnalysisModule(new Environment(settings)); + new AnalysisStempelPlugin().onModule(analysisModule); + Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), + new EnvironmentModule(new Environment(settings)), analysisModule) + .createInjector(); + final AnalysisService analysisService = parentInjector.getInstance(AnalysisRegistry.class).build(IndexSettingsModule.newIndexSettings(index, settings, Collections.emptyList())); TokenFilterFactory tokenizerFactory = analysisService.tokenFilter("polish_stem"); MatcherAssert.assertThat(tokenizerFactory, instanceOf(PolishStemTokenFilterFactory.class)); diff --git a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java index 06be6f67925..a1f178166fd 100644 --- a/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java +++ b/plugins/analysis-stempel/src/test/java/org/elasticsearch/index/analysis/SimplePolishTokenFilterTests.java @@ -33,13 +33,14 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.env.Environment; import org.elasticsearch.env.EnvironmentModule; import org.elasticsearch.index.Index; -import org.elasticsearch.index.analysis.pl.PolishAnalysisBinderProcessor; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.analysis.AnalysisModule; +import org.elasticsearch.plugin.analysis.stempel.AnalysisStempelPlugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import java.io.IOException; import java.io.StringReader; +import java.util.Collections; import static org.hamcrest.Matchers.equalTo; @@ -96,13 +97,12 @@ public class SimplePolishTokenFilterTests extends ESTestCase { } } - private AnalysisService createAnalysisService(Index index, Settings settings) { - Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), new EnvironmentModule(new Environment(settings))).createInjector(); - Injector injector = new ModulesBuilder().add( - new IndexSettingsModule(index, settings), - new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new PolishAnalysisBinderProcessor())) - .createChildInjector(parentInjector); - - return injector.getInstance(AnalysisService.class); + private AnalysisService createAnalysisService(Index index, Settings settings) throws IOException { + AnalysisModule analysisModule = new AnalysisModule(new Environment(settings)); + new AnalysisStempelPlugin().onModule(analysisModule); + Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings), + new EnvironmentModule(new Environment(settings)), analysisModule) + .createInjector(); + return parentInjector.getInstance(AnalysisRegistry.class).build(IndexSettingsModule.newIndexSettings(index, settings, Collections.emptyList())); } } From 5fcc648047700464f5b5bafb546d252b1686159d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Tue, 20 Oct 2015 22:53:26 +0200 Subject: [PATCH 16/37] Tests: Check exception from query parsers for unknown field Most query parsers throw a ParsingException when they trying to parse a field with an unknown name. This adds a generic check for this to the AbstractQueryTestCase so the behaviour gets tested for all query parsers. The test works by first making sure the test query has a `boost` field and then changing this to an unknown field name and checking for an error. There are exceptions to this for WrapperQueryBuilder and QueryFilterBuilder, because here the parser only expects the wrapped `query` element. MatchNoneQueryBuilder and MatchAllQueryBuilder so far had setters for boost() and queryName() but didn't render them, which is added here for consistency. GeoDistance, GeoDistanceRange and GeoHashCellQuery so far treat unknown field names in the json as the target field name of the center point of the query, which so far was handled by overwriting points previously specified in the query. This is changed here so that an attempt to use two different field names to specify the central point of the query throws a ParsingException Relates to #10974 --- .../index/query/GeoDistanceQueryParser.java | 9 ++- .../query/GeoDistanceRangeQueryParser.java | 64 ++++++++++++++----- .../index/query/GeohashCellQuery.java | 27 +++++--- .../index/query/MatchNoneQueryBuilder.java | 6 +- .../index/query/MatchNoneQueryParser.java | 24 +++++-- .../index/query/TypeQueryParser.java | 6 +- .../index/query/WrapperQueryParser.java | 2 +- .../index/query/AbstractQueryTestCase.java | 29 ++++++++- .../query/ConstantScoreQueryBuilderTests.java | 5 ++ .../query/MatchNoneQueryBuilderTests.java | 11 +--- .../query/TemplateQueryBuilderTests.java | 22 +++++-- .../index/query/WrapperQueryBuilderTests.java | 16 +++++ 12 files changed, 168 insertions(+), 53 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java index da9a7c2f07e..3cf4426394e 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoDistanceQueryParser.java @@ -130,8 +130,13 @@ public class GeoDistanceQueryParser implements QueryParser field : { lat : 30, lon : 12 } - fieldName = currentFieldName; - if (point == null) { - point = new GeoPoint(); + if (fieldName == null) { + fieldName = currentFieldName; + if (point == null) { + point = new GeoPoint(); + } + GeoUtils.parseGeoPoint(parser, point); + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + GeoDistanceRangeQueryBuilder.NAME + + "] field name already set to [" + fieldName + "] but found [" + currentFieldName + "]"); } - GeoUtils.parseGeoPoint(parser, point); } else if (token.isValue()) { if (parseContext.parseFieldMatcher().match(currentFieldName, FROM_FIELD)) { if (token == XContentParser.Token.VALUE_NULL) { @@ -162,20 +173,38 @@ public class GeoDistanceRangeQueryParser implements QueryParser 0) { - geohash = GeoUtils.parseGeoPoint(parser).geohash(); + if (fieldName == null) { + fieldName = field; + token = parser.nextToken(); + if (token == Token.VALUE_STRING) { + // A string indicates either a geohash or a + // lat/lon + // string + String location = parser.text(); + if (location.indexOf(",") > 0) { + geohash = GeoUtils.parseGeoPoint(parser).geohash(); + } else { + geohash = location; + } } else { - geohash = location; + geohash = GeoUtils.parseGeoPoint(parser).geohash(); } } else { - geohash = GeoUtils.parseGeoPoint(parser).geohash(); + throw new ParsingException(parser.getTokenLocation(), "[" + NAME + + "] field name already set to [" + fieldName + "] but found [" + field + "]"); } } } else { diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java index 0c466a43d10..4fc96f37f7a 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryBuilder.java @@ -39,6 +39,7 @@ public class MatchNoneQueryBuilder extends AbstractQueryBuilder public MatchNoneQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { XContentParser parser = parseContext.parser(); - XContentParser.Token token = parser.nextToken(); - if (token != XContentParser.Token.END_OBJECT) { - throw new ParsingException(parser.getTokenLocation(), "[match_none] query malformed"); + String currentFieldName = null; + XContentParser.Token token; + String queryName = null; + float boost = AbstractQueryBuilder.DEFAULT_BOOST; + while (((token = parser.nextToken()) != XContentParser.Token.END_OBJECT && token != XContentParser.Token.END_ARRAY)) { + if (token == XContentParser.Token.FIELD_NAME) { + currentFieldName = parser.currentName(); + } else if (token.isValue()) { + if ("_name".equals(currentFieldName)) { + queryName = parser.text(); + } else if ("boost".equals(currentFieldName)) { + boost = parser.floatValue(); + } else { + throw new ParsingException(parser.getTokenLocation(), "["+MatchNoneQueryBuilder.NAME+"] query does not support [" + currentFieldName + "]"); + } + } } - return new MatchNoneQueryBuilder(); + MatchNoneQueryBuilder matchNoneQueryBuilder = new MatchNoneQueryBuilder(); + matchNoneQueryBuilder.boost(boost); + matchNoneQueryBuilder.queryName(queryName); + return matchNoneQueryBuilder; } @Override diff --git a/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java index e2b4e13c65e..10adc0c7390 100644 --- a/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/TypeQueryParser.java @@ -55,14 +55,16 @@ public class TypeQueryParser implements QueryParser { boost = parser.floatValue(); } else if ("value".equals(currentFieldName)) { type = parser.utf8Bytes(); + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + TypeQueryBuilder.NAME + "] filter doesn't support [" + currentFieldName + "]"); } } else { - throw new ParsingException(parser.getTokenLocation(), "[type] filter doesn't support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + TypeQueryBuilder.NAME + "] filter doesn't support [" + currentFieldName + "]"); } } if (type == null) { - throw new ParsingException(parser.getTokenLocation(), "[type] filter needs to be provided with a value for the type"); + throw new ParsingException(parser.getTokenLocation(), "[" + TypeQueryBuilder.NAME + "] filter needs to be provided with a value for the type"); } return new TypeQueryBuilder(type) .boost(boost) diff --git a/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java index 59c570e97f9..ce5cdba883d 100644 --- a/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/WrapperQueryParser.java @@ -44,7 +44,7 @@ public class WrapperQueryParser implements QueryParser { } String fieldName = parser.currentName(); if (!fieldName.equals("query")) { - throw new ParsingException(parser.getTokenLocation(), "[wrapper] query malformed"); + throw new ParsingException(parser.getTokenLocation(), "[wrapper] query malformed, expected `query` but was" + fieldName); } parser.nextToken(); diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java index 677da47a2de..212dd457171 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java @@ -37,6 +37,7 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.ParseFieldMatcher; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.compress.CompressedXContent; @@ -100,6 +101,7 @@ import java.util.concurrent.ExecutionException; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.containsString; public abstract class AbstractQueryTestCase> extends ESTestCase { @@ -321,6 +323,29 @@ public abstract class AbstractQueryTestCase> } } + /** + * Test that unknown field trigger ParsingException. + * To find the right position in the root query, we add a marker as `queryName` which + * all query builders support. The added bogus field after that should trigger the exception. + * Queries that allow arbitrary field names at this level need to override this test. + */ + public void testUnknownField() throws IOException { + String marker = "#marker#"; + QB testQuery; + do { + testQuery = createTestQueryBuilder(); + } while (testQuery.toString().contains(marker)); + testQuery.queryName(marker); // to find root query to add additional bogus field there + String queryAsString = testQuery.toString().replace("\"" + marker + "\"", "\"" + marker + "\", \"bogusField\" : \"someValue\""); + try { + parseQuery(queryAsString); + fail("ParsingException expected."); + } catch (ParsingException e) { + // we'd like to see the offending field name here + assertThat(e.getMessage(), containsString("bogusField")); + } + } + /** * Returns alternate string representation of the query that need to be tested as they are never used as output * of {@link QueryBuilder#toXContent(XContentBuilder, ToXContent.Params)}. By default there are no alternate versions. @@ -361,7 +386,9 @@ public abstract class AbstractQueryTestCase> QueryParseContext context = createParseContext(); context.reset(parser); context.parseFieldMatcher(matcher); - return context.parseInnerQueryBuilder(); + QueryBuilder parseInnerQueryBuilder = context.parseInnerQueryBuilder(); + assertTrue(parser.nextToken() == null); + return parseInnerQueryBuilder; } /** diff --git a/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java index 44bcbee27b2..f2a529cefd3 100644 --- a/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/ConstantScoreQueryBuilderTests.java @@ -71,4 +71,9 @@ public class ConstantScoreQueryBuilderTests extends AbstractQueryTestCase { @Override - protected boolean supportsBoostAndQueryName() { - return false; - } - - @Override - protected AbstractQueryBuilder doCreateTestQueryBuilder() { + protected MatchNoneQueryBuilder doCreateTestQueryBuilder() { return new MatchNoneQueryBuilder(); } @Override - protected void doAssertLuceneQuery(AbstractQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException { + protected void doAssertLuceneQuery(MatchNoneQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException { assertThat(query, instanceOf(BooleanQuery.class)); BooleanQuery booleanQuery = (BooleanQuery) query; assertThat(booleanQuery.clauses().size(), equalTo(0)); diff --git a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java index 3039cc11103..12ac7709bfd 100644 --- a/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/TemplateQueryBuilderTests.java @@ -23,6 +23,7 @@ import org.apache.lucene.search.Query; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.script.Script.ScriptParseException; import org.elasticsearch.script.ScriptService.ScriptType; import org.elasticsearch.script.Template; import org.junit.BeforeClass; @@ -72,6 +73,22 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase vars = new HashMap<>(); vars.put("template", "filled"); @@ -97,11 +114,6 @@ public class TemplateQueryBuilderTests extends AbstractQueryTestCase params = new HashMap<>(); diff --git a/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java index fb9bde7dce7..e09deca5fec 100644 --- a/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/WrapperQueryBuilderTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.query; import org.apache.lucene.search.Query; import org.elasticsearch.action.support.ToXContentToBytes; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentFactory; @@ -102,4 +103,19 @@ public class WrapperQueryBuilderTests extends AbstractQueryTestCase Date: Fri, 30 Oct 2015 11:39:31 -0400 Subject: [PATCH 17/37] Get eclipse working with gradle --- CONTRIBUTING.md | 2 +- build.gradle | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e8e728696c..517cb153859 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,7 +76,7 @@ Contributing to the Elasticsearch codebase **Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch) -Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE by running `gradle eclipse` and then importing the project into their workspace: `File > Import > Existing project into workspace` and make sure to select `Search for nested projects...` option as Elasticsearch is a multi-module maven project. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. +Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE: `File > Import -> Gradle -> Gradle project`. When the `Import Options` dialog is presented, add `-Declipse` to the JVM Options box. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. Please follow these formatting guidelines: diff --git a/build.gradle b/build.gradle index 21090ce901d..3b104702996 100644 --- a/build.gradle +++ b/build.gradle @@ -134,7 +134,11 @@ subprojects { dependencySubstitution { substitute module("org.elasticsearch:rest-api-spec:${version}") with project("${projectsPrefix}:rest-api-spec") substitute module("org.elasticsearch:elasticsearch:${version}") with project("${projectsPrefix}:core") - substitute module("org.elasticsearch:test-framework:${version}") with project("${projectsPrefix}:test-framework") + // easy to type bypass so that eclipse doesn't have circular references + // the downside is, if you hack on test-framework, you have to gradle install + if (System.getProperty("eclipse") == null) { + substitute module("org.elasticsearch:test-framework:${version}") with project("${projectsPrefix}:test-framework") + } substitute module("org.elasticsearch.distribution.zip:elasticsearch:${version}") with project("${projectsPrefix}:distribution:zip") } } From 28633fae21af9469a4cf3819da3c97fb66183ed1 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 18 Sep 2015 10:12:54 -0400 Subject: [PATCH 18/37] [mapping] Remove transform Removes the mapping transform feature which when used made debugging very difficult. Users should transform their documents on the way into Elasticsearch rather than having Elasticsearch do it. Closes #12674 --- .../action/get/GetRequestBuilder.java | 17 -- .../metadata/MetaDataIndexUpgradeService.java | 10 +- .../index/get/ShardGetService.java | 10 +- .../index/mapper/DocumentMapper.java | 69 +------ .../index/mapper/DocumentMapperParser.java | 42 +--- .../index/mapper/DocumentParser.java | 22 --- .../index/mapper/MapperService.java | 7 +- .../elasticsearch/index/mapper/Mapping.java | 31 +-- .../elasticsearch/script/ScriptContext.java | 2 +- .../elasticsearch/script/ScriptService.java | 3 +- .../fetch/source/FetchSourceContext.java | 39 +--- .../index/engine/InternalEngineTests.java | 7 +- .../builder/SearchSourceBuilderTests.java | 2 +- docs/reference/migration/migrate_3_0.asciidoc | 6 + .../expression/MoreExpressionTests.java | 26 --- .../tests/TransformOnIndexMapperTests.java | 180 ------------------ 16 files changed, 38 insertions(+), 435 deletions(-) delete mode 100644 plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java diff --git a/core/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java index 89bacf06c3f..f785a3065ed 100644 --- a/core/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/get/GetRequestBuilder.java @@ -108,23 +108,6 @@ public class GetRequestBuilder extends SingleShardOperationRequestBuilder cursor : indexMetaData.getMappings().values()) { MappingMetaData mappingMetaData = cursor.value; mapperService.merge(mappingMetaData.type(), mappingMetaData.source(), false, false); diff --git a/core/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/core/src/main/java/org/elasticsearch/index/get/ShardGetService.java index 1a4938ed532..32e21be0326 100644 --- a/core/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/core/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -282,14 +282,11 @@ public final class ShardGetService extends AbstractIndexShardComponent { boolean sourceFieldFiltering = sourceFieldMapper.includes().length > 0 || sourceFieldMapper.excludes().length > 0; boolean sourceFetchFiltering = fetchSourceContext.includes().length > 0 || fetchSourceContext.excludes().length > 0; - if (fetchSourceContext.transformSource() || sourceFieldFiltering || sourceFetchFiltering) { + if (sourceFieldFiltering || sourceFetchFiltering) { // TODO: The source might parsed and available in the sourceLookup but that one uses unordered maps so different. Do we care? Tuple> typeMapTuple = XContentHelper.convertToMap(source.source, true); XContentType sourceContentType = typeMapTuple.v1(); Map sourceAsMap = typeMapTuple.v2(); - if (fetchSourceContext.transformSource()) { - sourceAsMap = docMapper.transformSourceAsMap(sourceAsMap); - } if (sourceFieldFiltering) { sourceAsMap = XContentMapValues.filter(sourceAsMap, sourceFieldMapper.includes(), sourceFieldMapper.excludes()); } @@ -397,16 +394,13 @@ public final class ShardGetService extends AbstractIndexShardComponent { if (!fetchSourceContext.fetchSource()) { source = null; - } else if (fetchSourceContext.transformSource() || fetchSourceContext.includes().length > 0 || fetchSourceContext.excludes().length > 0) { + } else if (fetchSourceContext.includes().length > 0 || fetchSourceContext.excludes().length > 0) { Map sourceAsMap; XContentType sourceContentType = null; // TODO: The source might parsed and available in the sourceLookup but that one uses unordered maps so different. Do we care? Tuple> typeMapTuple = XContentHelper.convertToMap(source, true); sourceContentType = typeMapTuple.v1(); sourceAsMap = typeMapTuple.v2(); - if (fetchSourceContext.transformSource()) { - sourceAsMap = docMapper.transformSourceAsMap(sourceAsMap); - } sourceAsMap = XContentMapValues.filter(sourceAsMap, fetchSourceContext.includes(), fetchSourceContext.excludes()); try { source = XContentFactory.contentBuilder(sourceContentType).map(sourceAsMap).bytes(); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java index c6c568c84fb..1be873d3e97 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapper.java @@ -35,7 +35,6 @@ import org.elasticsearch.common.util.concurrent.ReleasableLock; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.index.mapper.Mapping.SourceTransform; import org.elasticsearch.index.mapper.internal.AllFieldMapper; import org.elasticsearch.index.mapper.internal.FieldNamesFieldMapper; import org.elasticsearch.index.mapper.internal.IdFieldMapper; @@ -79,8 +78,6 @@ public class DocumentMapper implements ToXContent { private Map, MetadataFieldMapper> rootMappers = new LinkedHashMap<>(); - private List sourceTransforms = new ArrayList<>(1); - private final Settings indexSettings; private final RootObjectMapper rootObjectMapper; @@ -126,24 +123,9 @@ public class DocumentMapper implements ToXContent { return this; } - public Builder transform(ScriptService scriptService, Script script) { - sourceTransforms.add(new ScriptTransform(scriptService, script)); - return this; - } - - /** - * @deprecated Use {@link #transform(ScriptService, Script)} instead. - */ - @Deprecated - public Builder transform(ScriptService scriptService, String script, ScriptType scriptType, String language, - Map parameters) { - sourceTransforms.add(new ScriptTransform(scriptService, new Script(script, scriptType, language, parameters))); - return this; - } - public DocumentMapper build(MapperService mapperService, DocumentMapperParser docMapperParser) { Objects.requireNonNull(rootObjectMapper, "Mapper builder must have the root object mapper set"); - return new DocumentMapper(mapperService, indexSettings, docMapperParser, rootObjectMapper, meta, rootMappers, sourceTransforms, mapperService.mappingLock); + return new DocumentMapper(mapperService, indexSettings, docMapperParser, rootObjectMapper, meta, rootMappers, mapperService.mappingLock); } } @@ -171,7 +153,6 @@ public class DocumentMapper implements ToXContent { RootObjectMapper rootObjectMapper, Map meta, Map, MetadataFieldMapper> rootMappers, - List sourceTransforms, ReentrantReadWriteLock mappingLock) { this.mapperService = mapperService; this.type = rootObjectMapper.name(); @@ -180,7 +161,6 @@ public class DocumentMapper implements ToXContent { Version.indexCreated(indexSettings), rootObjectMapper, rootMappers.values().toArray(new MetadataFieldMapper[rootMappers.values().size()]), - sourceTransforms.toArray(new SourceTransform[sourceTransforms.size()]), meta); this.documentParser = new DocumentParser(indexSettings, docMapperParser, this, new ReleasableLock(mappingLock.readLock())); @@ -369,15 +349,6 @@ public class DocumentMapper implements ToXContent { } } - /** - * Transform the source when it is expressed as a map. This is public so it can be transformed the source is loaded. - * @param sourceAsMap source to transform. This may be mutated by the script. - * @return transformed version of transformMe. This may actually be the same object as sourceAsMap - */ - public Map transformSourceAsMap(Map sourceAsMap) { - return DocumentParser.transformSourceAsMap(mapping, sourceAsMap); - } - public boolean isParent(String type) { return mapperService.getParentTypes().contains(type); } @@ -430,42 +401,4 @@ public class DocumentMapper implements ToXContent { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { return mapping.toXContent(builder, params); } - - /** - * Script based source transformation. - */ - private static class ScriptTransform implements SourceTransform { - private final ScriptService scriptService; - /** - * The script to transform the source document before indexing. - */ - private final Script script; - - public ScriptTransform(ScriptService scriptService, Script script) { - this.scriptService = scriptService; - this.script = script; - } - - @Override - @SuppressWarnings("unchecked") - public Map transformSourceAsMap(Map sourceAsMap) { - try { - // We use the ctx variable and the _source name to be consistent with the update api. - ExecutableScript executable = scriptService.executable(script, ScriptContext.Standard.MAPPING, null); - Map ctx = new HashMap<>(1); - ctx.put("_source", sourceAsMap); - executable.setNextVar("ctx", ctx); - executable.run(); - ctx = (Map) executable.unwrap(ctx); - return (Map) ctx.get("_source"); - } catch (Exception e) { - throw new IllegalArgumentException("failed to execute script", e); - } - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - return script.toXContent(builder, params); - } - } } diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java index bbe983e8cc0..8714024fa52 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java @@ -42,8 +42,6 @@ import org.elasticsearch.index.mapper.ip.IpFieldMapper; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.elasticsearch.index.mapper.object.RootObjectMapper; import org.elasticsearch.index.similarity.SimilarityService; -import org.elasticsearch.script.Script; -import org.elasticsearch.script.ScriptService; import java.util.*; @@ -58,7 +56,6 @@ public class DocumentMapperParser { final AnalysisService analysisService; private static final ESLogger logger = Loggers.getLogger(DocumentMapperParser.class); private final SimilarityService similarityService; - private final ScriptService scriptService; private final RootObjectMapper.TypeParser rootObjectTypeParser = new RootObjectMapper.TypeParser(); @@ -71,13 +68,12 @@ public class DocumentMapperParser { private volatile SortedMap additionalRootMappers; public DocumentMapperParser(IndexSettings indexSettings, MapperService mapperService, AnalysisService analysisService, - SimilarityService similarityService, ScriptService scriptService) { + SimilarityService similarityService) { this.indexSettings = indexSettings.getSettings(); this.parseFieldMatcher = new ParseFieldMatcher(this.indexSettings); this.mapperService = mapperService; this.analysisService = analysisService; this.similarityService = similarityService; - this.scriptService = scriptService; Map typeParsers = new HashMap<>(); typeParsers.put(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser()); typeParsers.put(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser()); @@ -213,29 +209,13 @@ public class DocumentMapperParser { String fieldName = Strings.toUnderscoreCase(entry.getKey()); Object fieldNode = entry.getValue(); - if ("transform".equals(fieldName)) { - if (fieldNode instanceof Map) { - parseTransform(docBuilder, (Map) fieldNode, parserContext.indexVersionCreated()); - } else if (fieldNode instanceof List) { - for (Object transformItem: (List)fieldNode) { - if (!(transformItem instanceof Map)) { - throw new MapperParsingException("Elements of transform list must be objects but one was: " + fieldNode); - } - parseTransform(docBuilder, (Map) transformItem, parserContext.indexVersionCreated()); - } - } else { - throw new MapperParsingException("Transform must be an object or an array but was: " + fieldNode); - } + Mapper.TypeParser typeParser = rootTypeParsers.get(fieldName); + if (typeParser != null) { iterator.remove(); - } else { - Mapper.TypeParser typeParser = rootTypeParsers.get(fieldName); - if (typeParser != null) { - iterator.remove(); - Map fieldNodeMap = (Map) fieldNode; - docBuilder.put((MetadataFieldMapper.Builder)typeParser.parse(fieldName, fieldNodeMap, parserContext)); - fieldNodeMap.remove("type"); - checkNoRemainingFields(fieldName, fieldNodeMap, parserContext.indexVersionCreated()); - } + Map fieldNodeMap = (Map) fieldNode; + docBuilder.put((MetadataFieldMapper.Builder) typeParser.parse(fieldName, fieldNodeMap, parserContext)); + fieldNodeMap.remove("type"); + checkNoRemainingFields(fieldName, fieldNodeMap, parserContext.indexVersionCreated()); } } @@ -273,14 +253,6 @@ public class DocumentMapperParser { return remainingFields.toString(); } - private void parseTransform(DocumentMapper.Builder docBuilder, Map transformConfig, Version indexVersionCreated) { - Script script = Script.parse(transformConfig, true, parseFieldMatcher); - if (script != null) { - docBuilder.transform(scriptService, script); - } - checkNoRemainingFields(transformConfig, indexVersionCreated, "Transform config has unsupported parameters: "); - } - private Tuple> extractMapping(String type, String source) throws MapperParsingException { Map root; try (XContentParser parser = XContentFactory.xContent(source).createParser(source)) { diff --git a/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java b/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java index 97435e039e1..de4dc387c88 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java @@ -92,9 +92,6 @@ class DocumentParser implements Closeable { if (parser == null) { parser = XContentHelper.createParser(source.source()); } - if (mapping.sourceTransforms.length > 0) { - parser = transform(mapping, parser); - } context.reset(parser, new ParseContext.Document(), source); // will result in START_OBJECT @@ -764,29 +761,10 @@ class DocumentParser implements Closeable { return mapper; } - private static XContentParser transform(Mapping mapping, XContentParser parser) throws IOException { - Map transformed; - try (XContentParser autoCloses = parser) { - transformed = transformSourceAsMap(mapping, parser.mapOrdered()); - } - XContentBuilder builder = XContentFactory.contentBuilder(parser.contentType()).value(transformed); - return parser.contentType().xContent().createParser(builder.bytes()); - } - private static ObjectMapper.Dynamic dynamicOrDefault(ObjectMapper.Dynamic dynamic) { return dynamic == null ? ObjectMapper.Dynamic.TRUE : dynamic; } - static Map transformSourceAsMap(Mapping mapping, Map sourceAsMap) { - if (mapping.sourceTransforms.length == 0) { - return sourceAsMap; - } - for (Mapping.SourceTransform transform : mapping.sourceTransforms) { - sourceAsMap = transform.transformSourceAsMap(sourceAsMap); - } - return sourceAsMap; - } - @Override public void close() { cache.close(); diff --git a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 3adca3a0179..3f046d9a429 100755 --- a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -107,16 +107,15 @@ public class MapperService extends AbstractIndexComponent implements Closeable { @Inject public MapperService(IndexSettings indexSettings, AnalysisService analysisService, - SimilarityService similarityService, - ScriptService scriptService) { + SimilarityService similarityService) { super(indexSettings); this.analysisService = analysisService; this.fieldTypes = new FieldTypeLookup(); - this.documentParser = new DocumentMapperParser(indexSettings, this, analysisService, similarityService, scriptService); + this.documentParser = new DocumentMapperParser(indexSettings, this, analysisService, similarityService); this.indexAnalyzer = new MapperAnalyzerWrapper(analysisService.defaultIndexAnalyzer(), p -> p.indexAnalyzer()); this.searchAnalyzer = new MapperAnalyzerWrapper(analysisService.defaultSearchAnalyzer(), p -> p.searchAnalyzer()); this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(analysisService.defaultSearchQuoteAnalyzer(), p -> p.searchQuoteAnalyzer()); - + this.dynamic = this.indexSettings.getSettings().getAsBoolean("index.mapper.dynamic", true); defaultPercolatorMappingSource = "{\n" + "\"_default_\":{\n" + diff --git a/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java b/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java index 6eeb520f86c..88d9b43e0ab 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/Mapping.java @@ -43,26 +43,13 @@ public final class Mapping implements ToXContent { public static final List LEGACY_INCLUDE_IN_OBJECT = Arrays.asList("_all", "_id", "_parent", "_routing", "_timestamp", "_ttl"); - /** - * Transformations to be applied to the source before indexing and/or after loading. - */ - public interface SourceTransform extends ToXContent { - /** - * Transform the source when it is expressed as a map. This is public so it can be transformed the source is loaded. - * @param sourceAsMap source to transform. This may be mutated by the script. - * @return transformed version of transformMe. This may actually be the same object as sourceAsMap - */ - Map transformSourceAsMap(Map sourceAsMap); - } - final Version indexCreated; final RootObjectMapper root; final MetadataFieldMapper[] metadataMappers; final Map, MetadataFieldMapper> rootMappersMap; - final SourceTransform[] sourceTransforms; volatile Map meta; - public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper, MetadataFieldMapper[] metadataMappers, SourceTransform[] sourceTransforms, Map meta) { + public Mapping(Version indexCreated, RootObjectMapper rootObjectMapper, MetadataFieldMapper[] metadataMappers, Map meta) { this.indexCreated = indexCreated; this.root = rootObjectMapper; this.metadataMappers = metadataMappers; @@ -81,7 +68,6 @@ public final class Mapping implements ToXContent { } }); this.rootMappersMap = unmodifiableMap(rootMappersMap); - this.sourceTransforms = sourceTransforms; this.meta = meta; } @@ -94,7 +80,7 @@ public final class Mapping implements ToXContent { * Generate a mapping update for the given root object mapper. */ public Mapping mappingUpdate(Mapper rootObjectMapper) { - return new Mapping(indexCreated, (RootObjectMapper) rootObjectMapper, metadataMappers, sourceTransforms, meta); + return new Mapping(indexCreated, (RootObjectMapper) rootObjectMapper, metadataMappers, meta); } /** Get the root mapper with the given class. */ @@ -126,19 +112,6 @@ public final class Mapping implements ToXContent { root.toXContent(builder, params, new ToXContent() { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - if (sourceTransforms.length > 0) { - if (sourceTransforms.length == 1) { - builder.field("transform"); - sourceTransforms[0].toXContent(builder, params); - } else { - builder.startArray("transform"); - for (SourceTransform transform: sourceTransforms) { - transform.toXContent(builder, params); - } - builder.endArray(); - } - } - if (meta != null && !meta.isEmpty()) { builder.field("_meta", meta); } diff --git a/core/src/main/java/org/elasticsearch/script/ScriptContext.java b/core/src/main/java/org/elasticsearch/script/ScriptContext.java index a12fc85a53c..4b1b6de63f2 100644 --- a/core/src/main/java/org/elasticsearch/script/ScriptContext.java +++ b/core/src/main/java/org/elasticsearch/script/ScriptContext.java @@ -37,7 +37,7 @@ public interface ScriptContext { */ enum Standard implements ScriptContext { - AGGS("aggs"), MAPPING("mapping"), SEARCH("search"), UPDATE("update"); + AGGS("aggs"), SEARCH("search"), UPDATE("update"); private final String key; diff --git a/core/src/main/java/org/elasticsearch/script/ScriptService.java b/core/src/main/java/org/elasticsearch/script/ScriptService.java index 87a5a9a506d..3b91f2d3110 100644 --- a/core/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/core/src/main/java/org/elasticsearch/script/ScriptService.java @@ -246,8 +246,7 @@ public class ScriptService extends AbstractComponent implements Closeable { // TODO: fix this through some API or something, thats wrong // special exception to prevent expressions from compiling as update or mapping scripts boolean expression = "expression".equals(script.getLang()); - boolean notSupported = scriptContext.getKey().equals(ScriptContext.Standard.UPDATE.getKey()) || - scriptContext.getKey().equals(ScriptContext.Standard.MAPPING.getKey()); + boolean notSupported = scriptContext.getKey().equals(ScriptContext.Standard.UPDATE.getKey()); if (expression && notSupported) { throw new ScriptException("scripts of type [" + script.getType() + "]," + " operation [" + scriptContext.getKey() + "] and lang [" + lang + "] are not supported"); diff --git a/core/src/main/java/org/elasticsearch/search/fetch/source/FetchSourceContext.java b/core/src/main/java/org/elasticsearch/search/fetch/source/FetchSourceContext.java index ae0a71d8c5c..c14e2882d39 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/source/FetchSourceContext.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/source/FetchSourceContext.java @@ -47,7 +47,6 @@ public class FetchSourceContext implements Streamable, ToXContent { public static final FetchSourceContext FETCH_SOURCE = new FetchSourceContext(true); public static final FetchSourceContext DO_NOT_FETCH_SOURCE = new FetchSourceContext(false); private boolean fetchSource; - private boolean transformSource; private String[] includes; private String[] excludes; @@ -62,7 +61,7 @@ public class FetchSourceContext implements Streamable, ToXContent { } public FetchSourceContext(boolean fetchSource) { - this(fetchSource, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY, false); + this(fetchSource, Strings.EMPTY_ARRAY, Strings.EMPTY_ARRAY); } public FetchSourceContext(String include) { @@ -72,23 +71,21 @@ public class FetchSourceContext implements Streamable, ToXContent { public FetchSourceContext(String include, String exclude) { this(true, include == null ? Strings.EMPTY_ARRAY : new String[]{include}, - exclude == null ? Strings.EMPTY_ARRAY : new String[]{exclude}, - false); + exclude == null ? Strings.EMPTY_ARRAY : new String[]{exclude}); } public FetchSourceContext(String[] includes) { - this(true, includes, Strings.EMPTY_ARRAY, false); + this(true, includes, Strings.EMPTY_ARRAY); } public FetchSourceContext(String[] includes, String[] excludes) { - this(true, includes, excludes, false); + this(true, includes, excludes); } - public FetchSourceContext(boolean fetchSource, String[] includes, String[] excludes, boolean transform) { + public FetchSourceContext(boolean fetchSource, String[] includes, String[] excludes) { this.fetchSource = fetchSource; this.includes = includes == null ? Strings.EMPTY_ARRAY : includes; this.excludes = excludes == null ? Strings.EMPTY_ARRAY : excludes; - this.transformSource = transform; } public boolean fetchSource() { @@ -100,22 +97,6 @@ public class FetchSourceContext implements Streamable, ToXContent { return this; } - /** - * Should the document be transformed after the source is loaded? - */ - public boolean transformSource() { - return this.transformSource; - } - - /** - * Should the document be transformed after the source is loaded? - * @return this for chaining - */ - public FetchSourceContext transformSource(boolean transformSource) { - this.transformSource = transformSource; - return this; - } - public String[] includes() { return this.includes; } @@ -179,10 +160,8 @@ public class FetchSourceContext implements Streamable, ToXContent { source_excludes = Strings.splitStringByCommaToArray(sExcludes); } - boolean transform = request.paramAsBoolean("_source_transform", false); - - if (fetchSource != null || source_includes != null || source_excludes != null || transform) { - return new FetchSourceContext(fetchSource == null ? true : fetchSource, source_includes, source_excludes, transform); + if (fetchSource != null || source_includes != null || source_excludes != null) { + return new FetchSourceContext(fetchSource == null ? true : fetchSource, source_includes, source_excludes); } return null; } @@ -272,7 +251,7 @@ public class FetchSourceContext implements Streamable, ToXContent { fetchSource = in.readBoolean(); includes = in.readStringArray(); excludes = in.readStringArray(); - transformSource = in.readBoolean(); + in.readBoolean(); // Used to be transformSource but that was dropped in 2.1 } @Override @@ -280,7 +259,7 @@ public class FetchSourceContext implements Streamable, ToXContent { out.writeBoolean(fetchSource); out.writeStringArray(includes); out.writeStringArray(excludes); - out.writeBoolean(transformSource); + out.writeBoolean(false); // Used to be transformSource but that was dropped in 2.1 } @Override diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 88278727ae2..2d4948da3a4 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -1724,7 +1724,7 @@ public class InternalEngineTests extends ESTestCase { private Mapping dynamicUpdate() { BuilderContext context = new BuilderContext(Settings.EMPTY, new ContentPath()); final RootObjectMapper root = MapperBuilders.rootObject("some_type").build(context); - return new Mapping(Version.CURRENT, root, new MetadataFieldMapper[0], new Mapping.SourceTransform[0], emptyMap()); + return new Mapping(Version.CURRENT, root, new MetadataFieldMapper[0], emptyMap()); } public void testUpgradeOldIndex() throws IOException { @@ -1922,11 +1922,10 @@ public class InternalEngineTests extends ESTestCase { IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings, Collections.EMPTY_LIST); AnalysisService analysisService = new AnalysisService(indexSettings, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP); SimilarityService similarityService = new SimilarityService(indexSettings, Collections.EMPTY_MAP); - MapperService mapperService = new MapperService(indexSettings, analysisService, similarityService, null); + MapperService mapperService = new MapperService(indexSettings, analysisService, similarityService); DocumentMapper.Builder b = new DocumentMapper.Builder(settings, rootBuilder, mapperService); - DocumentMapperParser parser = new DocumentMapperParser(indexSettings, mapperService, analysisService, similarityService, null); + DocumentMapperParser parser = new DocumentMapperParser(indexSettings, mapperService, analysisService, similarityService); this.docMapper = b.build(mapperService, parser); - } @Override diff --git a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java index 64825dac8bb..9437c288051 100644 --- a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java @@ -183,7 +183,7 @@ public class SearchSourceBuilderTests extends ESTestCase { fetchSourceContext = new FetchSourceContext(randomAsciiOfLengthBetween(5, 20), randomAsciiOfLengthBetween(5, 20)); break; case 3: - fetchSourceContext = new FetchSourceContext(true, includes, excludes, randomBoolean()); + fetchSourceContext = new FetchSourceContext(true, includes, excludes); break; case 4: fetchSourceContext = new FetchSourceContext(includes); diff --git a/docs/reference/migration/migrate_3_0.asciidoc b/docs/reference/migration/migrate_3_0.asciidoc index 3f3a2192a66..e0bdff8ddee 100644 --- a/docs/reference/migration/migrate_3_0.asciidoc +++ b/docs/reference/migration/migrate_3_0.asciidoc @@ -158,6 +158,12 @@ Previously, there were three settings for the ping timeout: `discovery.zen.initi the only setting key for the ping timeout is now `discovery.zen.ping_timeout`. The default value for ping timeouts remains at three seconds. +=== Mapping changes === + +==== Transform removed + +The `transform` feature from mappings has been removed. It made issues very hard to debug. + === Plugins Plugins implementing custom queries need to implement the `fromXContent(QueryParseContext)` method in their diff --git a/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java b/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java index baf4ab04a90..4ac4b402c17 100644 --- a/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java +++ b/plugins/lang-expression/src/test/java/org/elasticsearch/script/expression/MoreExpressionTests.java @@ -504,32 +504,6 @@ public class MoreExpressionTests extends ESIntegTestCase { } } - // test to make sure expressions are not allowed to be used as mapping scripts - public void testInvalidMappingScript() throws Exception{ - try { - createIndex("test_index"); - ensureGreen("test_index"); - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - builder.startObject("transform"); - builder.field("script", "1.0"); - builder.field("lang", ExpressionScriptEngineService.NAME); - builder.endObject(); - builder.startObject("properties"); - builder.startObject("double_field"); - builder.field("type", "double"); - builder.endObject(); - builder.endObject(); - builder.endObject(); - client().admin().indices().preparePutMapping("test_index").setType("trans_test").setSource(builder).get(); - client().prepareIndex("test_index", "trans_test", "1").setSource("double_field", 0.0).get(); - fail("Expression scripts should not be allowed to run as mapping scripts."); - } catch (Exception e) { - String message = ExceptionsHelper.detailedMessage(e); - assertThat(message + " should have contained failed to parse", message.contains("failed to parse"), equalTo(true)); - assertThat(message + " should have contained not supported", message.contains("not supported"), equalTo(true)); - } - } - // test to make sure expressions are allowed to be used for reduce in pipeline aggregations public void testPipelineAggregationScript() throws Exception { createIndex("agg_index"); diff --git a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java b/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java deleted file mode 100644 index 20411963abf..00000000000 --- a/plugins/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TransformOnIndexMapperTests.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.messy.tests; - -import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.suggest.SuggestResponse; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.script.groovy.GroovyPlugin; -import org.elasticsearch.script.groovy.GroovyScriptEngineService; -import org.elasticsearch.search.suggest.SuggestBuilders; -import org.elasticsearch.search.suggest.completion.CompletionSuggestion; -import org.elasticsearch.test.ESIntegTestCase; - -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.concurrent.ExecutionException; - -import static java.util.Collections.singletonMap; -import static org.elasticsearch.index.query.QueryBuilders.termQuery; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHits; -import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestion; -import static org.hamcrest.Matchers.both; -import static org.hamcrest.Matchers.hasEntry; -import static org.hamcrest.Matchers.hasKey; -import static org.hamcrest.Matchers.not; - -/** - * Tests for transforming the source document before indexing. - */ -@SuppressCodecs("*") // requires custom completion format -public class TransformOnIndexMapperTests extends ESIntegTestCase { - @Override - protected Collection> nodePlugins() { - return Collections.singleton(GroovyPlugin.class); - } - - public void testSearchOnTransformed() throws Exception { - setup(true); - - // Searching by the field created in the transport finds the entry - SearchResponse response = client().prepareSearch("test").setQuery(termQuery("destination", "findme")).get(); - assertSearchHits(response, "righttitle"); - // The field built in the transform isn't in the source but source is, - // even though we didn't index it! - assertRightTitleSourceUntransformed(response.getHits().getAt(0).sourceAsMap()); - - // Can't find by a field removed from the document by the transform - response = client().prepareSearch("test").setQuery(termQuery("content", "findme")).get(); - assertHitCount(response, 0); - } - - public void testGetTransformed() throws Exception { - setup(getRandom().nextBoolean()); - GetResponse response = client().prepareGet("test", "test", "righttitle").get(); - assertExists(response); - assertRightTitleSourceUntransformed(response.getSource()); - - response = client().prepareGet("test", "test", "righttitle").setTransformSource(true).get(); - assertExists(response); - assertRightTitleSourceTransformed(response.getSource()); - } - - // TODO: the completion suggester currently returns payloads with no reencoding so this test - // exists to make sure that _source transformation and completion work well together. If we - // ever fix the completion suggester to reencode the payloads then we can remove this test. - public void testContextSuggestPayloadTransformed() throws Exception { - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - builder.startObject("properties"); - builder.startObject("suggest").field("type", "completion").field("payloads", true).endObject(); - builder.endObject(); - builder.startObject("transform"); - builder.field("script", "ctx._source.suggest = ['input': ctx._source.text];ctx._source.suggest.payload = ['display': ctx._source.text, 'display_detail': 'on the fly']"); - builder.field("lang", GroovyScriptEngineService.NAME); - builder.endObject(); - assertAcked(client().admin().indices().prepareCreate("test").addMapping("test", builder)); - // Payload is stored using original source format (json, smile, yaml, whatever) - XContentType type = XContentType.values()[between(0, XContentType.values().length - 1)]; - XContentBuilder source = XContentFactory.contentBuilder(type); - source.startObject().field("text", "findme").endObject(); - indexRandom(true, client().prepareIndex("test", "test", "findme").setSource(source)); - SuggestResponse response = client().prepareSuggest("test").addSuggestion( - SuggestBuilders.completionSuggestion("test").field("suggest").text("findme")).get(); - assertSuggestion(response.getSuggest(), 0, 0, "test", "findme"); - CompletionSuggestion.Entry.Option option = (CompletionSuggestion.Entry.Option)response.getSuggest().getSuggestion("test").getEntries().get(0).getOptions().get(0); - // And it comes back in exactly that way. - XContentBuilder expected = XContentFactory.contentBuilder(type); - expected.startObject().field("display", "findme").field("display_detail", "on the fly").endObject(); - assertEquals(expected.string(), option.getPayloadAsString()); - } - - /** - * Setup an index with some source transforms. Randomly picks the number of - * transforms but all but one of the transforms is a noop. The other is a - * script that fills the 'destination' field with the 'content' field only - * if the 'title' field starts with 't' and then always removes the - * 'content' field regarless of the contents of 't'. The actual script - * randomly uses parameters or not. - * - * @param forceRefresh - * should the data be flushed to disk? Set to false to test real - * time fetching - */ - private void setup(boolean forceRefresh) throws IOException, InterruptedException, ExecutionException { - XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); - builder.field("transform"); - if (getRandom().nextBoolean()) { - // Single transform - builder.startObject(); - buildTransformScript(builder); - builder.field("lang", randomFrom(null, GroovyScriptEngineService.NAME)); - builder.endObject(); - } else { - // Multiple transforms - int total = between(1, 10); - int actual = between(0, total - 1); - builder.startArray(); - for (int s = 0; s < total; s++) { - builder.startObject(); - if (s == actual) { - buildTransformScript(builder); - } else { - builder.field("script", "true"); - } - builder.field("lang", randomFrom(null, GroovyScriptEngineService.NAME)); - builder.endObject(); - } - builder.endArray(); - } - assertAcked(client().admin().indices().prepareCreate("test").addMapping("test", builder)); - - indexRandom(forceRefresh, client().prepareIndex("test", "test", "notitle").setSource("content", "findme"), - client().prepareIndex("test", "test", "badtitle").setSource("content", "findme", "title", "cat"), - client().prepareIndex("test", "test", "righttitle").setSource("content", "findme", "title", "table")); - } - - private void buildTransformScript(XContentBuilder builder) throws IOException { - String script = "if (ctx._source['title']?.startsWith('t')) { ctx._source['destination'] = ctx._source[sourceField] }; ctx._source.remove(sourceField);"; - if (getRandom().nextBoolean()) { - script = script.replace("sourceField", "'content'"); - } else { - builder.field("params", singletonMap("sourceField", "content")); - } - builder.field("script", script); - } - - private void assertRightTitleSourceUntransformed(Map source) { - assertThat(source, both(hasEntry("content", (Object) "findme")).and(not(hasKey("destination")))); - } - - private void assertRightTitleSourceTransformed(Map source) { - assertThat(source, both(hasEntry("destination", (Object) "findme")).and(not(hasKey("content")))); - } -} From 4bbea60c40f02525b06cc5f53d27b348dad5eb4e Mon Sep 17 00:00:00 2001 From: David Pilato Date: Fri, 30 Oct 2015 17:15:39 +0100 Subject: [PATCH 19/37] Add FSCrawler --- docs/plugins/integrations.asciidoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/plugins/integrations.asciidoc b/docs/plugins/integrations.asciidoc index bbfb0132b70..4737d07ee3a 100644 --- a/docs/plugins/integrations.asciidoc +++ b/docs/plugins/integrations.asciidoc @@ -36,7 +36,7 @@ NOTE: Rivers were used to import data from external systems into Elasticsearch p releases 2.0 and later do not support rivers. [float] -==== Supported by the community: +==== Supported by Elasticsearch: * https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html[Logstash output to Elasticsearch]: The Logstash `elasticsearch` output plugin. @@ -66,6 +66,9 @@ releases 2.0 and later do not support rivers. * https://github.com/salyh/elasticsearch-imap[IMAP/POP3/Mail importer]: The Mail importer allows to fetch data from IMAP and POP3 servers for indexing into Elasticsearch (by Hendrik Saly) +* https://github.com/dadoonet/fscrawler[FS Crawler]: + The File System (FS) crawler allows to index documents (PDF, Open Office...) from your local file system and over SSH. (by David Pilato) + [float] [[deployment]] === Deployment From 7ea5a7ea806f604ec98716353aeefadbe6139424 Mon Sep 17 00:00:00 2001 From: Brady Vidovic Date: Fri, 30 Oct 2015 12:17:40 -0500 Subject: [PATCH 20/37] Update mapping PUT should use /_mapping Instead of /mapping --- docs/reference/indices/put-mapping.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/indices/put-mapping.asciidoc b/docs/reference/indices/put-mapping.asciidoc index 7d6e6587786..7dd2389e824 100644 --- a/docs/reference/indices/put-mapping.asciidoc +++ b/docs/reference/indices/put-mapping.asciidoc @@ -99,7 +99,7 @@ PUT my_index <1> } } -PUT my_index/mapping/user +PUT my_index/_mapping/user { "properties": { "name": { From 10d4f17aa89ecda6eabc93a1dbc3af40863011c8 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 30 Oct 2015 14:21:06 -0400 Subject: [PATCH 21/37] make eclipse work without specifying a sysprop --- CONTRIBUTING.md | 2 +- build.gradle | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 517cb153859..969a7ffeeb6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,7 +76,7 @@ Contributing to the Elasticsearch codebase **Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch) -Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE: `File > Import -> Gradle -> Gradle project`. When the `Import Options` dialog is presented, add `-Declipse` to the JVM Options box. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. +Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE: `File > Import -> Gradle -> Gradle project`. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. Please follow these formatting guidelines: diff --git a/build.gradle b/build.gradle index 3b104702996..171a9e227b8 100644 --- a/build.gradle +++ b/build.gradle @@ -134,9 +134,10 @@ subprojects { dependencySubstitution { substitute module("org.elasticsearch:rest-api-spec:${version}") with project("${projectsPrefix}:rest-api-spec") substitute module("org.elasticsearch:elasticsearch:${version}") with project("${projectsPrefix}:core") - // easy to type bypass so that eclipse doesn't have circular references + // so that eclipse doesn't have circular references // the downside is, if you hack on test-framework, you have to gradle install - if (System.getProperty("eclipse") == null) { + // the first prop detects eclipse itself, the second detects eclipse from commandline + if (System.getProperty("eclipse.launcher") == null && gradle.startParameter.taskNames.contains('eclipse') == false) { substitute module("org.elasticsearch:test-framework:${version}") with project("${projectsPrefix}:test-framework") } substitute module("org.elasticsearch.distribution.zip:elasticsearch:${version}") with project("${projectsPrefix}:distribution:zip") From 13b60e1b9249d7211c799a23a1119de39cbbecde Mon Sep 17 00:00:00 2001 From: Areek Zillur Date: Fri, 30 Oct 2015 01:34:45 -0400 Subject: [PATCH 22/37] update to lucene-5.4.x-snapshot-1711508 --- .../main/resources/org/elasticsearch/bootstrap/security.policy | 2 +- .../resources/org/elasticsearch/bootstrap/test-framework.policy | 2 +- .../lucene-analyzers-common-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-analyzers-common-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../lucene-backward-codecs-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-backward-codecs-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-core-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-core-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-grouping-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-grouping-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-highlighter-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-highlighter-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-join-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-join-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-memory-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-memory-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-misc-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-misc-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-queries-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-queries-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-queryparser-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-queryparser-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-sandbox-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-sandbox-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-spatial-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-spatial-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-spatial3d-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-spatial3d-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-suggest-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-suggest-5.4.0-snapshot-1711508.jar.sha1 | 1 + distribution/licenses/spatial4j-0.5-tests.jar.sha1 | 1 - gradle.properties | 2 +- .../lucene-analyzers-icu-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-analyzers-icu-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../lucene-analyzers-kuromoji-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-analyzers-kuromoji-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../lucene-analyzers-phonetic-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-analyzers-phonetic-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../lucene-analyzers-smartcn-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-analyzers-smartcn-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../lucene-analyzers-stempel-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../lucene-analyzers-stempel-5.4.0-snapshot-1711508.jar.sha1 | 1 + .../licenses/lucene-expressions-5.4.0-snapshot-1710880.jar.sha1 | 1 - .../licenses/lucene-expressions-5.4.0-snapshot-1711508.jar.sha1 | 1 + pom.xml | 2 +- 45 files changed, 24 insertions(+), 25 deletions(-) delete mode 100644 distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-core-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-core-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-grouping-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-grouping-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-highlighter-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-highlighter-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-join-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-join-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-memory-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-memory-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-misc-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-misc-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-queries-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-queries-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-queryparser-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-queryparser-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-sandbox-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-sandbox-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-spatial-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-spatial-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/lucene-suggest-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 distribution/licenses/lucene-suggest-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 distribution/licenses/spatial4j-0.5-tests.jar.sha1 delete mode 100644 plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1711508.jar.sha1 delete mode 100644 plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1710880.jar.sha1 create mode 100644 plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1711508.jar.sha1 diff --git a/core/src/main/resources/org/elasticsearch/bootstrap/security.policy b/core/src/main/resources/org/elasticsearch/bootstrap/security.policy index e65886ad793..e31c022f7f6 100644 --- a/core/src/main/resources/org/elasticsearch/bootstrap/security.policy +++ b/core/src/main/resources/org/elasticsearch/bootstrap/security.policy @@ -38,7 +38,7 @@ grant codeBase "${codebase.securesm-1.0.jar}" { //// Very special jar permissions: //// These are dangerous permissions that we don't want to grant to everything. -grant codeBase "${codebase.lucene-core-5.4.0-snapshot-1710880.jar}" { +grant codeBase "${codebase.lucene-core-5.4.0-snapshot-1711508.jar}" { // needed to allow MMapDirectory's "unmap hack" permission java.lang.RuntimePermission "accessClassInPackage.sun.misc"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; diff --git a/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy b/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy index af60fcaf853..e1494357030 100644 --- a/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy +++ b/core/src/main/resources/org/elasticsearch/bootstrap/test-framework.policy @@ -30,7 +30,7 @@ grant codeBase "${codebase.securemock-1.1.jar}" { permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; }; -grant codeBase "${codebase.lucene-test-framework-5.4.0-snapshot-1710880.jar}" { +grant codeBase "${codebase.lucene-test-framework-5.4.0-snapshot-1711508.jar}" { // needed by RamUsageTester permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; }; diff --git a/distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 1dff1091f02..00000000000 --- a/distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -584673fa6187890af89deab81df6a8651651fa2a diff --git a/distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..7ba588ce118 --- /dev/null +++ b/distribution/licenses/lucene-analyzers-common-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +1ce5d6dab63f88bd997c2e465ec47efc2891ba5d \ No newline at end of file diff --git a/distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index f737f98bd2a..00000000000 --- a/distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f3b0911633d657e49d7a00df0eb5da5a7f65f61b diff --git a/distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..f741492749d --- /dev/null +++ b/distribution/licenses/lucene-backward-codecs-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +8640d74259f60aa4dada4912c9c3ebe772c9818e \ No newline at end of file diff --git a/distribution/licenses/lucene-core-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-core-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 89720a70e22..00000000000 --- a/distribution/licenses/lucene-core-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d4ac9f13091eabf5cc0b13bd995dc2c161771139 diff --git a/distribution/licenses/lucene-core-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-core-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..f48292917c5 --- /dev/null +++ b/distribution/licenses/lucene-core-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +6641f07bcfd6a3d046b83e631e366b706f035c2e \ No newline at end of file diff --git a/distribution/licenses/lucene-grouping-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-grouping-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index ac14c1412ed..00000000000 --- a/distribution/licenses/lucene-grouping-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9499d90d3db187210f9991ab0a92d48423ba3d4e diff --git a/distribution/licenses/lucene-grouping-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-grouping-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..856e03e684a --- /dev/null +++ b/distribution/licenses/lucene-grouping-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +b4e39e2b74aea6675b3c4717fa767b84f781d890 \ No newline at end of file diff --git a/distribution/licenses/lucene-highlighter-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-highlighter-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index d87ebcc05a1..00000000000 --- a/distribution/licenses/lucene-highlighter-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -7daf49e720499e43d9b44b588526eb750ea2e83a diff --git a/distribution/licenses/lucene-highlighter-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-highlighter-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..b5626bee99e --- /dev/null +++ b/distribution/licenses/lucene-highlighter-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +92aaae41d7f2a7feaa821ce6ad02abc4f8734bc2 \ No newline at end of file diff --git a/distribution/licenses/lucene-join-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-join-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 23b7f1816a5..00000000000 --- a/distribution/licenses/lucene-join-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e1a36360e967bf3116a4271d4b04aa5bdcc235ca diff --git a/distribution/licenses/lucene-join-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-join-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..2dee65504ba --- /dev/null +++ b/distribution/licenses/lucene-join-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +e4c5402e04b4875bbe033077de9f6dea16418cb2 \ No newline at end of file diff --git a/distribution/licenses/lucene-memory-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-memory-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index e915f6a8201..00000000000 --- a/distribution/licenses/lucene-memory-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -78b2fe81fe90c2d45ace3f21c7915319fe92119b diff --git a/distribution/licenses/lucene-memory-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-memory-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..d093ade101a --- /dev/null +++ b/distribution/licenses/lucene-memory-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +9ead1255154fde92384e9f454999ad37e1261e3d \ No newline at end of file diff --git a/distribution/licenses/lucene-misc-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-misc-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 82ee83a3370..00000000000 --- a/distribution/licenses/lucene-misc-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8c7734673fbdfa7ae251b29a7bee7842b6450606 diff --git a/distribution/licenses/lucene-misc-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-misc-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..16d59356d36 --- /dev/null +++ b/distribution/licenses/lucene-misc-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +a03e432df9037631a5e9238822927ee4a2167d8d \ No newline at end of file diff --git a/distribution/licenses/lucene-queries-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-queries-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 54b54e2f168..00000000000 --- a/distribution/licenses/lucene-queries-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f2ce93847617b42c98fc44a979697ba8f6e3f693 diff --git a/distribution/licenses/lucene-queries-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-queries-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..87503961b39 --- /dev/null +++ b/distribution/licenses/lucene-queries-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +159331ae15424664f70da76f1fb136c1e84ad095 \ No newline at end of file diff --git a/distribution/licenses/lucene-queryparser-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-queryparser-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 96e3bac9f19..00000000000 --- a/distribution/licenses/lucene-queryparser-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bf99b0920e7d5cdddeddb0181ffad7df9e557ebb diff --git a/distribution/licenses/lucene-queryparser-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-queryparser-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..70e78527f21 --- /dev/null +++ b/distribution/licenses/lucene-queryparser-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +9f6e02d1d54db4e7b39f2a9ff337285088ddb0e2 \ No newline at end of file diff --git a/distribution/licenses/lucene-sandbox-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-sandbox-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 3e20f766ece..00000000000 --- a/distribution/licenses/lucene-sandbox-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -89cd7591008f10ceeb88fe87c52ea5f96754ad94 diff --git a/distribution/licenses/lucene-sandbox-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-sandbox-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..4d551f223bb --- /dev/null +++ b/distribution/licenses/lucene-sandbox-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +f5e9fb1b996609e18ab7e4aae9ca9438ee66b437 \ No newline at end of file diff --git a/distribution/licenses/lucene-spatial-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-spatial-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 3c7db1eac3b..00000000000 --- a/distribution/licenses/lucene-spatial-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -55817ab7fc4b2980429aa6ced151affe7740eb44 diff --git a/distribution/licenses/lucene-spatial-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-spatial-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..d0b7d27d162 --- /dev/null +++ b/distribution/licenses/lucene-spatial-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +c4d8c788084feceac969a2ecea547d42bf0b2715 \ No newline at end of file diff --git a/distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index b933d7a64ef..00000000000 --- a/distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -ef817826ffec2b506672ba5038f4e396a7bfcdc7 diff --git a/distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..6a98328bb11 --- /dev/null +++ b/distribution/licenses/lucene-spatial3d-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +04c4ead54ca6546ec7447f7f1916077c4767eb3d \ No newline at end of file diff --git a/distribution/licenses/lucene-suggest-5.4.0-snapshot-1710880.jar.sha1 b/distribution/licenses/lucene-suggest-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index b448901cd51..00000000000 --- a/distribution/licenses/lucene-suggest-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5b39ae55fa40709cc45d5925ad80d09cb0cdc4ba diff --git a/distribution/licenses/lucene-suggest-5.4.0-snapshot-1711508.jar.sha1 b/distribution/licenses/lucene-suggest-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..b6113edf88c --- /dev/null +++ b/distribution/licenses/lucene-suggest-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +10d9a389e44de137651d2c87ae401c9d29230bce \ No newline at end of file diff --git a/distribution/licenses/spatial4j-0.5-tests.jar.sha1 b/distribution/licenses/spatial4j-0.5-tests.jar.sha1 deleted file mode 100644 index 0c514f8835e..00000000000 --- a/distribution/licenses/spatial4j-0.5-tests.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -bdcdf20a723516a233b5bcc0ca7d4decaa88b6ed diff --git a/gradle.properties b/gradle.properties index 58dc97027e9..95510ac3653 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=org.elasticsearch version=3.0.0-SNAPSHOT -luceneVersion=5.4.0-snapshot-1710880 +luceneVersion=5.4.0-snapshot-1711508 diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1710880.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 25f0322e755..00000000000 --- a/plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -43979949bebc071fc0353513fffe11684690f23e diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1711508.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..8c09ac37be1 --- /dev/null +++ b/plugins/analysis-icu/licenses/lucene-analyzers-icu-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +8843675db98498fd858c071644238420cb8d270a \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1710880.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 973cab1d2d6..00000000000 --- a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d621f00b5ce0f9fde87a713e932d888c3ddd1a78 diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1711508.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..ad36332c96c --- /dev/null +++ b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +b2a0b8143e660826b8605cf58de818a6ce423f47 \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1710880.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 8034c3c8fdc..00000000000 --- a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d46a1cd06ae642581e566844b1e42e14e0eeffe6 diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1711508.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..308e1edff4e --- /dev/null +++ b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +414bc537c247f07eb1b34ff943fc0ce4c80aab8c \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1710880.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 3855bcfe769..00000000000 --- a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8e6058a95f38637c1d4b7a1ebcc6c8ce85c80b20 diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1711508.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..96ca2605575 --- /dev/null +++ b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +f2c2e3907a66825e042eb8f664f210d949f05108 \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1710880.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index c1e15a2e832..00000000000 --- a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -4c69ca398b34c7a58482b09cdc06d0e2bab89cc4 diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1711508.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..98240f9b732 --- /dev/null +++ b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +7059da88bf88df123c62d917aeed4c144d62665f \ No newline at end of file diff --git a/plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1710880.jar.sha1 b/plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1710880.jar.sha1 deleted file mode 100644 index 6f2d485fdb1..00000000000 --- a/plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1710880.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -431504b7bad8ffc1a03707b9a1531d95f33e10b9 diff --git a/plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1711508.jar.sha1 b/plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1711508.jar.sha1 new file mode 100644 index 00000000000..7ac4891745d --- /dev/null +++ b/plugins/lang-expression/licenses/lucene-expressions-5.4.0-snapshot-1711508.jar.sha1 @@ -0,0 +1 @@ +627b73ddbbbd03746123751b36a674d81308a046 \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9cb61ca1a88..32425a87502 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 5.4.0 - 1710880 + 1711159 5.4.0-snapshot-${lucene.snapshot.revision} 2.2.0 1.1 From 5eb2dce03c7e3f7a036b4ba69a5ead06e4099d35 Mon Sep 17 00:00:00 2001 From: Areek Zillur Date: Fri, 30 Oct 2015 15:50:34 -0400 Subject: [PATCH 23/37] revert updating lucene snapshot version in pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 32425a87502..9cb61ca1a88 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 5.4.0 - 1711159 + 1710880 5.4.0-snapshot-${lucene.snapshot.revision} 2.2.0 1.1 From c1e3c4a78e28743ca87e3324256ba74b8c4d1ace Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 30 Oct 2015 13:05:46 -0700 Subject: [PATCH 24/37] Build: Add back -Dtests.output support This change fixes the test logging for randomized testing to support tests.output like maven/ant do. --- .../RandomizedTestingTask.groovy | 4 +--- .../TestLoggingConfiguration.groovy | 18 +++++++++++++++ .../randomizedtesting/TestReportLogger.groovy | 23 ++++--------------- .../elasticsearch/gradle/BuildPlugin.groovy | 1 + 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy index 4b91fe213c8..9ce9f51fd50 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy @@ -20,8 +20,6 @@ import javax.inject.Inject class RandomizedTestingTask extends DefaultTask { - PatternFilterable patternSet = new PatternSet() - // TODO: change to "executable" to match gradle test params? @Optional @Input @@ -64,6 +62,7 @@ class RandomizedTestingTask extends DefaultTask { List jvmArgs = new ArrayList<>() Map systemProperties = new HashMap<>() + PatternFilterable patternSet = new PatternSet() RandomizedTestingTask() { outputs.upToDateWhen {false} // randomized tests are never up to date @@ -166,7 +165,6 @@ class RandomizedTestingTask extends DefaultTask { } // TODO: add leaveTemporary - // TODO: add jvmOutputAction? // TODO: add ifNoTests! @TaskAction diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy index 32933a38c1e..d844893cbda 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy @@ -3,6 +3,20 @@ package com.carrotsearch.gradle.randomizedtesting import org.gradle.util.ConfigureUtil class TestLoggingConfiguration { + /** Display mode for output streams. */ + static enum OutputMode { + /** Always display the output emitted from tests. */ + ALWAYS, + /** + * Display the output only if a test/ suite failed. This requires internal buffering + * so the output will be shown only after a test completes. + */ + ONERROR, + /** Don't display the output, even on test failures. */ + NEVER + } + + OutputMode outputMode = OutputMode.ONERROR SlowTestsConfiguration slowTests = new SlowTestsConfiguration() StackTraceFiltersConfiguration stackTraceFilters = new StackTraceFiltersConfiguration() @@ -13,4 +27,8 @@ class TestLoggingConfiguration { void stackTraceFilters(Closure closure) { ConfigureUtil.configure(closure, stackTraceFilters) } + + void outputMode(String mode) { + outputMode = mode.toUpperCase() as OutputMode + } } diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy index 81def8a5f0c..c4c253bc734 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy @@ -18,6 +18,7 @@ import org.junit.runner.Description import java.util.concurrent.atomic.AtomicInteger import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.* +import static com.carrotsearch.gradle.randomizedtesting.TestLoggingConfiguration.OutputMode class TestReportLogger extends TestsSummaryEventListener implements AggregatedEventListener { @@ -54,20 +55,6 @@ class TestReportLogger extends TestsSummaryEventListener implements AggregatedEv LoggingOutputStream outStream LoggingOutputStream errStream - /** Display mode for output streams. */ - static enum OutputMode { - /** Always display the output emitted from tests. */ - ALWAYS, - /** - * Display the output only if a test/ suite failed. This requires internal buffering - * so the output will be shown only after a test completes. - */ - ONERROR, - /** Don't display the output, even on test failures. */ - NEVER - } - OutputMode outputMode = OutputMode.ONERROR - /** A list of failed tests, if to be displayed at the end. */ List failedTests = new ArrayList<>() @@ -238,7 +225,7 @@ class TestReportLogger extends TestsSummaryEventListener implements AggregatedEv } void emitBufferedEvents(LogLevel level, AggregatedSuiteResultEvent e) throws IOException { - if (outputMode == OutputMode.NEVER) { + if (config.outputMode == OutputMode.NEVER) { return } @@ -247,8 +234,8 @@ class TestReportLogger extends TestsSummaryEventListener implements AggregatedEv eventMap.put(tre.getTestFinishedEvent(), tre) } - final boolean emitOutput = outputMode == OutputMode.ALWAYS && isPassthrough() == false || - outputMode == OutputMode.ONERROR && e.isSuccessful() == false + final boolean emitOutput = config.outputMode == OutputMode.ALWAYS && isPassthrough() == false || + config.outputMode == OutputMode.ONERROR && e.isSuccessful() == false for (IEvent event : e.getEventStream()) { switch (event.getType()) { @@ -363,7 +350,7 @@ class TestReportLogger extends TestsSummaryEventListener implements AggregatedEv /** Returns true if output should be logged immediately. Only relevant when running with INFO log level. */ boolean isPassthrough() { - return forkedJvmCount == 1 && outputMode == OutputMode.ALWAYS && logger.isInfoEnabled() + return forkedJvmCount == 1 && config.outputMode == OutputMode.ALWAYS && logger.isInfoEnabled() } @Override diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index ee666771319..2b7aaa9cc0b 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -151,6 +151,7 @@ class BuildPlugin implements Plugin { regex(/^(\s+at )(org\.apache\.lucene\.util\.TestRule)/) regex(/^(\s+at )(org\.apache\.lucene\.util\.AbstractBeforeAfterRule)/) } + outputMode System.getProperty('tests.output', 'onerror') } balancers { From 197ed57ea49cbf453160233db2a16bf35f8b4756 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 30 Oct 2015 13:22:59 -0700 Subject: [PATCH 25/37] Build: Move RR gradle plugin files to match external repo paths The RR gradle plugin is at https://github.com/randomizedtesting/gradle-randomized-testing-plugin. However, we currently have a copy of this, since the plugin is still in heavy development. This change moves the files around so they can be copied directly from the elasticsearch fork to that repo, for ease of syncing. --- .../BalancersConfiguration.groovy | 2 +- .../ListenersConfiguration.groovy | 2 +- .../{randomizedtesting => junit4}/LoggingOutputStream.groovy | 2 +- .../RandomizedTestingPlugin.groovy | 2 +- .../RandomizedTestingTask.groovy | 2 +- .../SlowTestsConfiguration.groovy | 2 +- .../StackTraceFiltersConfiguration.groovy | 2 +- .../TestLoggingConfiguration.groovy | 2 +- .../{randomizedtesting => junit4}/TestProgressLogger.groovy | 2 +- .../{randomizedtesting => junit4}/TestReportLogger.groovy | 4 ++-- .../main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 2 +- .../org/elasticsearch/gradle/test/RestIntegTestTask.groovy | 2 +- .../org/elasticsearch/gradle/test/RestTestPlugin.groovy | 4 ++-- .../gradle-plugins/carrotsearch.randomized-testing.properties | 1 + .../gradle-plugins/carrotsearch.randomizedtesting.properties | 1 - core/build.gradle | 2 +- 16 files changed, 17 insertions(+), 17 deletions(-) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/BalancersConfiguration.groovy (97%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/ListenersConfiguration.groovy (94%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/LoggingOutputStream.groovy (97%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/RandomizedTestingPlugin.groovy (96%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/RandomizedTestingTask.groovy (99%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/SlowTestsConfiguration.groovy (82%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/StackTraceFiltersConfiguration.groovy (84%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/TestLoggingConfiguration.groovy (95%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/TestProgressLogger.groovy (98%) rename buildSrc/src/main/groovy/com/carrotsearch/gradle/{randomizedtesting => junit4}/TestReportLogger.groovy (98%) create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomized-testing.properties delete mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomizedtesting.properties diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/BalancersConfiguration.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/BalancersConfiguration.groovy similarity index 97% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/BalancersConfiguration.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/BalancersConfiguration.groovy index 2f92d58a78e..91355bf2494 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/BalancersConfiguration.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/BalancersConfiguration.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import com.carrotsearch.ant.tasks.junit4.SuiteBalancer import com.carrotsearch.ant.tasks.junit4.balancers.ExecutionTimeBalancer diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/ListenersConfiguration.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/ListenersConfiguration.groovy similarity index 94% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/ListenersConfiguration.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/ListenersConfiguration.groovy index 634a68e37f4..5fa5baa8ffb 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/ListenersConfiguration.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/ListenersConfiguration.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener import com.carrotsearch.ant.tasks.junit4.listeners.antxml.AntXmlReport diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/LoggingOutputStream.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/LoggingOutputStream.groovy similarity index 97% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/LoggingOutputStream.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/LoggingOutputStream.groovy index bf19d43824f..ce0995a5a8c 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/LoggingOutputStream.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/LoggingOutputStream.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import org.gradle.api.logging.LogLevel import org.gradle.api.logging.Logger diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingPlugin.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy similarity index 96% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingPlugin.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy index f7b677704c0..e2230b116c7 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingPlugin.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingPlugin.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import com.carrotsearch.ant.tasks.junit4.JUnit4 import org.gradle.api.AntBuilder diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy similarity index 99% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy index 9ce9f51fd50..723f67f0298 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/RandomizedTestingTask.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/RandomizedTestingTask.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import com.carrotsearch.ant.tasks.junit4.ListenersList import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/SlowTestsConfiguration.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/SlowTestsConfiguration.groovy similarity index 82% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/SlowTestsConfiguration.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/SlowTestsConfiguration.groovy index 00c4493a39b..2705fdeaacb 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/SlowTestsConfiguration.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/SlowTestsConfiguration.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 class SlowTestsConfiguration { int heartbeat = 0 diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/StackTraceFiltersConfiguration.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/StackTraceFiltersConfiguration.groovy similarity index 84% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/StackTraceFiltersConfiguration.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/StackTraceFiltersConfiguration.groovy index 7450a5a9f62..5e5610ab68e 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/StackTraceFiltersConfiguration.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/StackTraceFiltersConfiguration.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 class StackTraceFiltersConfiguration { List patterns = new ArrayList<>() diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestLoggingConfiguration.groovy similarity index 95% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestLoggingConfiguration.groovy index d844893cbda..d18ac3fbd5a 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestLoggingConfiguration.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestLoggingConfiguration.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import org.gradle.util.ConfigureUtil diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestProgressLogger.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy similarity index 98% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestProgressLogger.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy index 7321ef53d1c..1a8884f3d29 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestProgressLogger.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy @@ -17,7 +17,7 @@ * under the License. */ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import com.carrotsearch.ant.tasks.junit4.JUnit4 import com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.eventbus.Subscribe diff --git a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestReportLogger.groovy similarity index 98% rename from buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy rename to buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestReportLogger.groovy index c4c253bc734..36d83a19865 100644 --- a/buildSrc/src/main/groovy/com/carrotsearch/gradle/randomizedtesting/TestReportLogger.groovy +++ b/buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestReportLogger.groovy @@ -1,4 +1,4 @@ -package com.carrotsearch.gradle.randomizedtesting +package com.carrotsearch.gradle.junit4 import com.carrotsearch.ant.tasks.junit4.JUnit4 import com.carrotsearch.ant.tasks.junit4.Pluralize @@ -18,7 +18,7 @@ import org.junit.runner.Description import java.util.concurrent.atomic.AtomicInteger import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.* -import static com.carrotsearch.gradle.randomizedtesting.TestLoggingConfiguration.OutputMode +import static com.carrotsearch.gradle.junit4.TestLoggingConfiguration.OutputMode class TestReportLogger extends TestsSummaryEventListener implements AggregatedEventListener { diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 2b7aaa9cc0b..6ed1553dceb 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -37,7 +37,7 @@ class BuildPlugin implements Plugin { void apply(Project project) { globalBuildInfo(project) project.pluginManager.apply('java') - project.pluginManager.apply('carrotsearch.randomizedtesting') + project.pluginManager.apply('carrotsearch.randomized-testing') // these plugins add lots of info to our jars project.pluginManager.apply('nebula.info-broker') project.pluginManager.apply('nebula.info-basic') diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy index 80fe6556a85..262826a5c23 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestIntegTestTask.groovy @@ -18,7 +18,7 @@ */ package org.elasticsearch.gradle.test -import com.carrotsearch.gradle.randomizedtesting.RandomizedTestingTask +import com.carrotsearch.gradle.junit4.RandomizedTestingTask import org.elasticsearch.gradle.BuildPlugin import org.gradle.api.Project import org.gradle.api.Task diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy index c8411c80f98..24e21160331 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy @@ -18,7 +18,7 @@ */ package org.elasticsearch.gradle.test -import com.carrotsearch.gradle.randomizedtesting.RandomizedTestingTask +import com.carrotsearch.gradle.junit4.RandomizedTestingTask import org.elasticsearch.gradle.ElasticsearchProperties import org.gradle.api.Plugin import org.gradle.api.Project @@ -29,7 +29,7 @@ class RestTestPlugin implements Plugin { @Override void apply(Project project) { project.pluginManager.apply('java-base') - project.pluginManager.apply('carrotsearch.randomizedtesting') + project.pluginManager.apply('carrotsearch.randomized-testing') project.pluginManager.apply('idea') // remove some unnecessary tasks for a qa test diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomized-testing.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomized-testing.properties new file mode 100644 index 00000000000..e1a1b8297c8 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomized-testing.properties @@ -0,0 +1 @@ +implementation-class=com.carrotsearch.gradle.junit4.RandomizedTestingPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomizedtesting.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomizedtesting.properties deleted file mode 100644 index 5e0627f688e..00000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/carrotsearch.randomizedtesting.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=com.carrotsearch.gradle.randomizedtesting.RandomizedTestingPlugin diff --git a/core/build.gradle b/core/build.gradle index 3bc0168e077..01134f372bd 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -17,7 +17,7 @@ * under the License. */ -import com.carrotsearch.gradle.randomizedtesting.RandomizedTestingTask +import com.carrotsearch.gradle.junit4.RandomizedTestingTask import org.elasticsearch.gradle.BuildPlugin import org.elasticsearch.gradle.test.RestSpecHack From f726e11da6283d2074ab3ab06777f7e1782b6686 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 30 Oct 2015 14:56:11 -0600 Subject: [PATCH 26/37] Move logging for the amount of free disk to TRACE Since this can potentially be logged for every `canRemain`, it's nicer to put it in TRACE rather than DEBUG. Resolves #12843 --- .../routing/allocation/decider/DiskThresholdDecider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java index f21ced8cc0a..a02c72c5745 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDecider.java @@ -466,8 +466,8 @@ public class DiskThresholdDecider extends AllocationDecider { // If this node is already above the high threshold, the shard cannot remain (get it off!) final double freeDiskPercentage = usage.getFreeDiskAsPercentage(); final long freeBytes = usage.getFreeBytes(); - if (logger.isDebugEnabled()) { - logger.debug("node [{}] has {}% free disk ({} bytes)", node.nodeId(), freeDiskPercentage, freeBytes); + if (logger.isTraceEnabled()) { + logger.trace("node [{}] has {}% free disk ({} bytes)", node.nodeId(), freeDiskPercentage, freeBytes); } if (dataPath == null || usage.getPath().equals(dataPath) == false) { return allocation.decision(Decision.YES, NAME, "shard is not allocated on the most utilized disk"); From 373dee4b5e5d6da15a4eadbc0a39db404ddd3c20 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 30 Oct 2015 23:00:05 -0400 Subject: [PATCH 27/37] make gradle eclipse always run cleanEclipse Otherwise the 'merging' gets really trappy. it basically never works without a clean. See 38.4.1.1. Disabling merging with a complete rewrite: https://docs.gradle.org/current/userguide/eclipse_plugin.html --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 171a9e227b8..c28dde53069 100644 --- a/build.gradle +++ b/build.gradle @@ -158,6 +158,8 @@ allprojects { defaultOutputDir = new File(project.buildDir, 'eclipse') } } + // otherwise the eclipse merging is *super confusing* + tasks.eclipse.dependsOn(cleanEclipse) } idea { From 77b030d08816f043083607e38661366c8d125c86 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 30 Oct 2015 23:07:40 -0400 Subject: [PATCH 28/37] add equivalent gradle commands --- GRADLE.CHEATSHEET | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 GRADLE.CHEATSHEET diff --git a/GRADLE.CHEATSHEET b/GRADLE.CHEATSHEET new file mode 100644 index 00000000000..3362b8571e7 --- /dev/null +++ b/GRADLE.CHEATSHEET @@ -0,0 +1,7 @@ +As a quick helper, below are the equivalent commands from maven to gradle (TESTING.md has also been updated). You can also run "gradle tasks" to see all tasks that are available to run. +clean -> clean +test -> test +verify -> check +verify -Dskip.unit.tests -> integTest +package -DskipTests -> assemble +install -DskipTests -> install From 0dca49fae4b9571a25dd5b00769594fb15ca1407 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 30 Oct 2015 21:32:16 -0700 Subject: [PATCH 29/37] fix eclipse config for qa projects --- build.gradle | 24 +++++++++++-------- .../gradle/test/RestTestPlugin.groovy | 2 +- distribution/ziphack/build.gradle | 2 -- 3 files changed, 15 insertions(+), 13 deletions(-) delete mode 100644 distribution/ziphack/build.gradle diff --git a/build.gradle b/build.gradle index c28dde53069..c59d765fc24 100644 --- a/build.gradle +++ b/build.gradle @@ -147,9 +147,22 @@ subprojects { } } -// IDE configuration +// intellij configuration allprojects { apply plugin: 'idea' +} + +if (hasProperty('projectsPrefix') == false) { + idea { + project { + languageLevel = sourceCompatibility + vcs = 'Git' + } + } +} + +// ecplise configuration +allprojects { apply plugin: 'eclipse' // TODO: similar for intellij @@ -162,13 +175,4 @@ allprojects { tasks.eclipse.dependsOn(cleanEclipse) } -idea { - if (project != null) { - // could be null, if this project is attached to another... - project { - languageLevel = sourceCompatibility - vcs = 'Git' - } - } -} diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy index 24e21160331..c0c81dc151a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/RestTestPlugin.groovy @@ -30,7 +30,6 @@ class RestTestPlugin implements Plugin { void apply(Project project) { project.pluginManager.apply('java-base') project.pluginManager.apply('carrotsearch.randomized-testing') - project.pluginManager.apply('idea') // remove some unnecessary tasks for a qa test project.tasks.removeAll { it.name in ['assemble', 'buildDependents'] } @@ -53,6 +52,7 @@ class RestTestPlugin implements Plugin { project.eclipse { classpath { sourceSets = [project.sourceSets.test] + plusConfigurations = [project.configurations.testRuntime] } } } diff --git a/distribution/ziphack/build.gradle b/distribution/ziphack/build.gradle deleted file mode 100644 index 5d500fddc28..00000000000 --- a/distribution/ziphack/build.gradle +++ /dev/null @@ -1,2 +0,0 @@ - -confi From 3961c9b58b76c838406eb0adc2a401eed97be847 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sat, 31 Oct 2015 02:39:35 -0400 Subject: [PATCH 30/37] fix eclipse (again) --- CONTRIBUTING.md | 2 +- build.gradle | 17 ++++++++++++----- plugins/delete-by-query/.gitignore | 1 - 3 files changed, 13 insertions(+), 7 deletions(-) delete mode 100644 plugins/delete-by-query/.gitignore diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 969a7ffeeb6..507a27a5912 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,7 +76,7 @@ Contributing to the Elasticsearch codebase **Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch) -Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE: `File > Import -> Gradle -> Gradle project`. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. +Make sure you have [Gradle](http://gradle.org) installed, as Elasticsearch uses it as its build system. Integration with IntelliJ and Eclipse should work out of the box. Eclipse users can automatically configure their IDE: `gradle eclipse` then `File: Import: Existing Projects into Workspace`. Select the option `Search for nested projects`. Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead errors. Please follow these formatting guidelines: diff --git a/build.gradle b/build.gradle index c59d765fc24..621f137eb94 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ */ import com.bmuschko.gradle.nexus.NexusPlugin +import org.gradle.plugins.ide.eclipse.model.SourceFolder buildscript { repositories { @@ -161,14 +162,20 @@ if (hasProperty('projectsPrefix') == false) { } } -// ecplise configuration +// eclipse configuration allprojects { apply plugin: 'eclipse' - // TODO: similar for intellij - eclipse { - classpath { - defaultOutputDir = new File(project.buildDir, 'eclipse') + plugins.withType(JavaBasePlugin) { + eclipse.classpath.defaultOutputDir = new File(project.buildDir, 'eclipse') + eclipse.classpath.file.whenMerged { classpath -> + // give each source folder a unique corresponding output folder + int i = 0; + classpath.entries.findAll { it instanceof SourceFolder }.each { folder -> + i++; + // this is *NOT* a path or a file. + folder.output = "build/eclipse/" + i + } } } // otherwise the eclipse merging is *super confusing* diff --git a/plugins/delete-by-query/.gitignore b/plugins/delete-by-query/.gitignore deleted file mode 100644 index ae3c1726048..00000000000 --- a/plugins/delete-by-query/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ From b56bbf62dd88225d2c396fc023e2bb44cc8698fc Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 28 Oct 2015 19:10:19 +0100 Subject: [PATCH 31/37] Validate query api: move query parsing on the coordinating node Similarly to what we did with the search api, we can now also move query parsing on the coordinating node for the validate query api. Given that the explain api is a single shard operation (compared to search which is instead a broadcast operation), this doesn't change a lot in how the api works internally. The main benefit is that we can simplify the java api by requiring a structured query object to be provided rather than a bytes array that will get parsed on the data node. Previously if you specified a QueryBuilder it would be serialized in json format and would get reparsed on the data node, while now it doesn't go through parsing anymore (as expected), given that after the query-refactoring we are able to properly stream queries natively. Note that the WrapperQueryBuilder can be used from the java api to provide a query as a string, in that case the actual parsing of the inner query will happen on the data node. Relates to #10217 Closes #14384 --- .../query/ShardValidateQueryRequest.java | 14 +-- .../query/TransportValidateQueryAction.java | 6 +- .../validate/query/ValidateQueryRequest.java | 97 +++---------------- .../query/ValidateQueryRequestBuilder.java | 43 +------- .../action/support/QuerySourceBuilder.java | 67 ------------- .../index/query/IndexQueryParserService.java | 24 ----- .../index/query/WrapperQueryBuilder.java | 7 +- .../query/RestValidateQueryAction.java | 76 +++++++++------ .../validate/SimpleValidateQueryIT.java | 10 +- .../test/indices.validate_query/10_basic.yaml | 21 ++++ 10 files changed, 101 insertions(+), 264 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/action/support/QuerySourceBuilder.java diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java index 808d1a5da2f..1242a9087d8 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java @@ -22,9 +22,9 @@ package org.elasticsearch.action.admin.indices.validate.query; import org.elasticsearch.action.support.broadcast.BroadcastShardRequest; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.shard.ShardId; import java.io.IOException; @@ -34,7 +34,7 @@ import java.io.IOException; */ public class ShardValidateQueryRequest extends BroadcastShardRequest { - private BytesReference source; + private QueryBuilder query; private String[] types = Strings.EMPTY_ARRAY; private boolean explain; private boolean rewrite; @@ -49,7 +49,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest { ShardValidateQueryRequest(ShardId shardId, @Nullable String[] filteringAliases, ValidateQueryRequest request) { super(shardId, request); - this.source = request.source(); + this.query = request.query(); this.types = request.types(); this.explain = request.explain(); this.rewrite = request.rewrite(); @@ -57,8 +57,8 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest { this.nowInMillis = request.nowInMillis; } - public BytesReference source() { - return source; + public QueryBuilder query() { + return query; } public String[] types() { @@ -84,7 +84,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - source = in.readBytesReference(); + query = in.readQuery(); int typesSize = in.readVInt(); if (typesSize > 0) { @@ -109,7 +109,7 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeBytesReference(source); + out.writeQuery(query); out.writeVInt(types.length); for (String type : types) { diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index 9cdd8ce2183..262213ab891 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -36,6 +36,7 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; @@ -43,7 +44,6 @@ import org.elasticsearch.index.IndexService; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.QueryShardException; -import org.elasticsearch.common.ParsingException; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.script.ScriptService; @@ -178,9 +178,7 @@ public class TransportValidateQueryAction extends TransportBroadcastAction 0) { - searchContext.parsedQuery(queryParserService.parseTopLevelQuery(request.source())); - } + searchContext.parsedQuery(queryParserService.toQuery(request.query())); searchContext.preProcess(); valid = true; diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java index 7c7869b9ce6..1f15cb6ae79 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java @@ -19,34 +19,27 @@ package org.elasticsearch.action.admin.indices.validate.query; -import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.action.ValidateActions; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.action.support.QuerySourceBuilder; import org.elasticsearch.action.support.broadcast.BroadcastRequest; -import org.elasticsearch.client.Requests; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.common.xcontent.XContentHelper; +import org.elasticsearch.index.query.MatchAllQueryBuilder; +import org.elasticsearch.index.query.QueryBuilder; import java.io.IOException; import java.util.Arrays; -import java.util.Map; /** * A request to validate a specific query. *

- * The request requires the query source to be set either using {@link #source(QuerySourceBuilder)}, - * or {@link #source(byte[])}. + * The request requires the query to be set using {@link #query(QueryBuilder)} */ public class ValidateQueryRequest extends BroadcastRequest { - private BytesReference source; + private QueryBuilder query = new MatchAllQueryBuilder(); private boolean explain; private boolean rewrite; @@ -71,67 +64,21 @@ public class ValidateQueryRequest extends BroadcastRequest @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validate(); + if (query == null) { + validationException = ValidateActions.addValidationError("query cannot be null", validationException); + } return validationException; } /** - * The source to execute. + * The query to validate. */ - public BytesReference source() { - return source; + public QueryBuilder query() { + return query; } - public ValidateQueryRequest source(QuerySourceBuilder sourceBuilder) { - this.source = sourceBuilder.buildAsBytes(Requests.CONTENT_TYPE); - return this; - } - - /** - * The source to execute in the form of a map. - */ - public ValidateQueryRequest source(Map source) { - try { - XContentBuilder builder = XContentFactory.contentBuilder(Requests.CONTENT_TYPE); - builder.map(source); - return source(builder); - } catch (IOException e) { - throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); - } - } - - public ValidateQueryRequest source(XContentBuilder builder) { - this.source = builder.bytes(); - return this; - } - - /** - * The query source to validate. It is preferable to use either {@link #source(byte[])} - * or {@link #source(QuerySourceBuilder)}. - */ - public ValidateQueryRequest source(String source) { - this.source = new BytesArray(source); - return this; - } - - /** - * The source to validate. - */ - public ValidateQueryRequest source(byte[] source) { - return source(source, 0, source.length); - } - - /** - * The source to validate. - */ - public ValidateQueryRequest source(byte[] source, int offset, int length) { - return source(new BytesArray(source, offset, length)); - } - - /** - * The source to validate. - */ - public ValidateQueryRequest source(BytesReference source) { - this.source = source; + public ValidateQueryRequest query(QueryBuilder query) { + this.query = query; return this; } @@ -181,9 +128,7 @@ public class ValidateQueryRequest extends BroadcastRequest @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - - source = in.readBytesReference(); - + query = in.readQuery(); int typesSize = in.readVInt(); if (typesSize > 0) { types = new String[typesSize]; @@ -191,7 +136,6 @@ public class ValidateQueryRequest extends BroadcastRequest types[i] = in.readString(); } } - explain = in.readBoolean(); rewrite = in.readBoolean(); } @@ -199,27 +143,18 @@ public class ValidateQueryRequest extends BroadcastRequest @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - - out.writeBytesReference(source); - + out.writeQuery(query); out.writeVInt(types.length); for (String type : types) { out.writeString(type); } - out.writeBoolean(explain); out.writeBoolean(rewrite); } @Override public String toString() { - String sSource = "_na_"; - try { - sSource = XContentHelper.convertToJson(source, false); - } catch (Exception e) { - // ignore - } - return "[" + Arrays.toString(indices) + "]" + Arrays.toString(types) + ", source[" + sSource + "], explain:" + explain + + return "[" + Arrays.toString(indices) + "]" + Arrays.toString(types) + ", query[" + query + "], explain:" + explain + ", rewrite:" + rewrite; } } diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java index 515ecd1ba1e..bfee7ec6b99 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequestBuilder.java @@ -19,10 +19,8 @@ package org.elasticsearch.action.admin.indices.validate.query; -import org.elasticsearch.action.support.QuerySourceBuilder; import org.elasticsearch.action.support.broadcast.BroadcastOperationRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.index.query.QueryBuilder; /** @@ -30,8 +28,6 @@ import org.elasticsearch.index.query.QueryBuilder; */ public class ValidateQueryRequestBuilder extends BroadcastOperationRequestBuilder { - private QuerySourceBuilder sourceBuilder; - public ValidateQueryRequestBuilder(ElasticsearchClient client, ValidateQueryAction action) { super(client, action, new ValidateQueryRequest()); } @@ -45,32 +41,12 @@ public class ValidateQueryRequestBuilder extends BroadcastOperationRequestBuilde } /** - * The query source to validate. + * The query to validate. * * @see org.elasticsearch.index.query.QueryBuilders */ public ValidateQueryRequestBuilder setQuery(QueryBuilder queryBuilder) { - sourceBuilder().setQuery(queryBuilder); - return this; - } - - /** - * The source to validate. - * - * @see org.elasticsearch.index.query.QueryBuilders - */ - public ValidateQueryRequestBuilder setSource(BytesReference source) { - request().source(source); - return this; - } - - /** - * The source to validate. - * - * @see org.elasticsearch.index.query.QueryBuilders - */ - public ValidateQueryRequestBuilder setSource(byte[] source) { - request.source(source); + request.query(queryBuilder); return this; } @@ -91,19 +67,4 @@ public class ValidateQueryRequestBuilder extends BroadcastOperationRequestBuilde request.rewrite(rewrite); return this; } - - @Override - protected ValidateQueryRequest beforeExecute(ValidateQueryRequest request) { - if (sourceBuilder != null) { - request.source(sourceBuilder); - } - return request; - } - - private QuerySourceBuilder sourceBuilder() { - if (sourceBuilder == null) { - sourceBuilder = new QuerySourceBuilder(); - } - return sourceBuilder; - } } diff --git a/core/src/main/java/org/elasticsearch/action/support/QuerySourceBuilder.java b/core/src/main/java/org/elasticsearch/action/support/QuerySourceBuilder.java deleted file mode 100644 index 9266310a48b..00000000000 --- a/core/src/main/java/org/elasticsearch/action/support/QuerySourceBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.action.support; - -import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.index.query.QueryBuilder; - -import java.io.IOException; - -public class QuerySourceBuilder extends ToXContentToBytes { - - private QueryBuilder queryBuilder; - - private BytesReference queryBinary; - - public QuerySourceBuilder setQuery(QueryBuilder query) { - this.queryBuilder = query; - return this; - } - - public QuerySourceBuilder setQuery(BytesReference queryBinary) { - this.queryBinary = queryBinary; - return this; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - innerToXContent(builder, params); - builder.endObject(); - return builder; - } - - public void innerToXContent(XContentBuilder builder, Params params) throws IOException { - if (queryBuilder != null) { - builder.field("query"); - queryBuilder.toXContent(builder, params); - } - - if (queryBinary != null) { - if (XContentFactory.xContentType(queryBinary) == builder.contentType()) { - builder.rawField("query", queryBinary); - } else { - builder.field("query_binary", queryBinary); - } - } - } -} diff --git a/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java b/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java index 8793de10367..77294177696 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java +++ b/core/src/main/java/org/elasticsearch/index/query/IndexQueryParserService.java @@ -209,30 +209,6 @@ public class IndexQueryParserService extends AbstractIndexComponent { return indexSettings.getIndexVersionCreated(); } - /** - * Selectively parses a query from a top level query or query_binary json field from the specified source. - */ - public ParsedQuery parseTopLevelQuery(BytesReference source) { - XContentParser parser = null; - try { - parser = XContentFactory.xContent(source).createParser(source); - QueryShardContext queryShardContext = cache.get(); - queryShardContext.reset(parser); - queryShardContext.parseFieldMatcher(parseFieldMatcher); - try { - QueryBuilder queryBuilder = queryShardContext.parseContext().parseTopLevelQueryBuilder(); - Query query = toQuery(queryBuilder, queryShardContext); - return new ParsedQuery(query, queryShardContext.copyNamedQueries()); - } finally { - queryShardContext.reset(null); - } - } catch (ParsingException | QueryShardException e) { - throw e; - } catch (Throwable e) { - throw new ParsingException(parser == null ? null : parser.getTokenLocation(), "Failed to parse", e); - } - } - private ParsedQuery innerParse(QueryShardContext context, XContentParser parser) throws IOException, QueryShardException { context.reset(parser); try { diff --git a/core/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java index 7c736125954..a7b7eb05bdb 100644 --- a/core/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/WrapperQueryBuilder.java @@ -20,9 +20,6 @@ package org.elasticsearch.index.query; import org.apache.lucene.search.Query; - -import java.nio.charset.StandardCharsets; - import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; @@ -32,6 +29,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; /** @@ -110,7 +108,8 @@ public class WrapperQueryBuilder extends AbstractQueryBuilder result = contextCopy.parseContext().parseInnerQueryBuilder(); context.combineNamedQueries(contextCopy); return result.toQuery(context); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java index 85d6c57d1ad..0a4592f387f 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/validate/query/RestValidateQueryAction.java @@ -23,22 +23,21 @@ import org.elasticsearch.action.admin.indices.validate.query.QueryExplanation; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest; import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse; import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.action.support.QuerySourceBuilder; import org.elasticsearch.client.Client; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentBuilderString; import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.rest.BaseRestHandler; -import org.elasticsearch.rest.BytesRestResponse; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestResponse; +import org.elasticsearch.indices.query.IndicesQueriesRegistry; +import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.support.RestActions; import org.elasticsearch.rest.action.support.RestBuilderListener; +import java.io.IOException; + import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.POST; import static org.elasticsearch.rest.RestStatus.OK; @@ -49,8 +48,10 @@ import static org.elasticsearch.rest.action.support.RestActions.buildBroadcastSh */ public class RestValidateQueryAction extends BaseRestHandler { + private final IndicesQueriesRegistry indicesQueriesRegistry; + @Inject - public RestValidateQueryAction(Settings settings, RestController controller, Client client) { + public RestValidateQueryAction(Settings settings, RestController controller, Client client, IndicesQueriesRegistry indicesQueriesRegistry) { super(settings, controller, client); controller.registerHandler(GET, "/_validate/query", this); controller.registerHandler(POST, "/_validate/query", this); @@ -58,55 +59,52 @@ public class RestValidateQueryAction extends BaseRestHandler { controller.registerHandler(POST, "/{index}/_validate/query", this); controller.registerHandler(GET, "/{index}/{type}/_validate/query", this); controller.registerHandler(POST, "/{index}/{type}/_validate/query", this); + this.indicesQueriesRegistry = indicesQueriesRegistry; } @Override - public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { + public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception { ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(Strings.splitStringByCommaToArray(request.param("index"))); validateQueryRequest.indicesOptions(IndicesOptions.fromRequest(request, validateQueryRequest.indicesOptions())); + validateQueryRequest.explain(request.paramAsBoolean("explain", false)); if (RestActions.hasBodyContent(request)) { - validateQueryRequest.source(RestActions.getRestContent(request)); + try { + validateQueryRequest.query(RestActions.getQueryContent(RestActions.getRestContent(request), indicesQueriesRegistry, parseFieldMatcher)); + } catch(ParsingException e) { + channel.sendResponse(buildErrorResponse(channel.newBuilder(), e.getDetailedMessage(), validateQueryRequest.explain())); + return; + } catch(Exception e) { + channel.sendResponse(buildErrorResponse(channel.newBuilder(), e.getMessage(), validateQueryRequest.explain())); + return; + } } else { QueryBuilder queryBuilder = RestActions.urlParamsToQueryBuilder(request); if (queryBuilder != null) { - QuerySourceBuilder querySourceBuilder = new QuerySourceBuilder(); - querySourceBuilder.setQuery(queryBuilder); - validateQueryRequest.source(querySourceBuilder); + validateQueryRequest.query(queryBuilder); } } validateQueryRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); - if (request.paramAsBoolean("explain", false)) { - validateQueryRequest.explain(true); - } else { - validateQueryRequest.explain(false); - } - if (request.paramAsBoolean("rewrite", false)) { - validateQueryRequest.rewrite(true); - } else { - validateQueryRequest.rewrite(false); - } + validateQueryRequest.rewrite(request.paramAsBoolean("rewrite", false)); client.admin().indices().validateQuery(validateQueryRequest, new RestBuilderListener(channel) { @Override public RestResponse buildResponse(ValidateQueryResponse response, XContentBuilder builder) throws Exception { builder.startObject(); - builder.field("valid", response.isValid()); - + builder.field(VALID_FIELD, response.isValid()); buildBroadcastShardsHeader(builder, request, response); - if (response.getQueryExplanation() != null && !response.getQueryExplanation().isEmpty()) { - builder.startArray("explanations"); + builder.startArray(EXPLANATIONS_FIELD); for (QueryExplanation explanation : response.getQueryExplanation()) { builder.startObject(); if (explanation.getIndex() != null) { - builder.field("index", explanation.getIndex(), XContentBuilder.FieldCaseConversion.NONE); + builder.field(INDEX_FIELD, explanation.getIndex(), XContentBuilder.FieldCaseConversion.NONE); } - builder.field("valid", explanation.isValid()); + builder.field(VALID_FIELD, explanation.isValid()); if (explanation.getError() != null) { - builder.field("error", explanation.getError()); + builder.field(ERROR_FIELD, explanation.getError()); } if (explanation.getExplanation() != null) { - builder.field("explanation", explanation.getExplanation()); + builder.field(EXPLANATION_FIELD, explanation.getExplanation()); } builder.endObject(); } @@ -117,4 +115,20 @@ public class RestValidateQueryAction extends BaseRestHandler { } }); } + + private static BytesRestResponse buildErrorResponse(XContentBuilder builder, String error, boolean explain) throws IOException { + builder.startObject(); + builder.field(VALID_FIELD, false); + if (explain) { + builder.field(ERROR_FIELD, error); + } + builder.endObject(); + return new BytesRestResponse(OK, builder); + } + + private static final XContentBuilderString INDEX_FIELD = new XContentBuilderString("index"); + private static final XContentBuilderString VALID_FIELD = new XContentBuilderString("valid"); + private static final XContentBuilderString EXPLANATIONS_FIELD = new XContentBuilderString("explanations"); + private static final XContentBuilderString ERROR_FIELD = new XContentBuilderString("error"); + private static final XContentBuilderString EXPLANATION_FIELD = new XContentBuilderString("explanation"); } diff --git a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java index 81aaa5d6832..d3df8d133e0 100644 --- a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java +++ b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java @@ -66,7 +66,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { refresh(); - assertThat(client().admin().indices().prepareValidateQuery("test").setSource("foo".getBytes(StandardCharsets.UTF_8)).execute().actionGet().isValid(), equalTo(false)); + assertThat(client().admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.wrapperQuery("foo".getBytes(StandardCharsets.UTF_8))).execute().actionGet().isValid(), equalTo(false)); assertThat(client().admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryStringQuery("_id:1")).execute().actionGet().isValid(), equalTo(true)); assertThat(client().admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.queryStringQuery("_i:d:1")).execute().actionGet().isValid(), equalTo(false)); @@ -94,12 +94,12 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { for (Client client : internalCluster()) { ValidateQueryResponse response = client.admin().indices().prepareValidateQuery("test") - .setSource("foo".getBytes(StandardCharsets.UTF_8)) + .setQuery(QueryBuilders.wrapperQuery("foo".getBytes(StandardCharsets.UTF_8))) .setExplain(true) .execute().actionGet(); assertThat(response.isValid(), equalTo(false)); assertThat(response.getQueryExplanation().size(), equalTo(1)); - assertThat(response.getQueryExplanation().get(0).getError(), containsString("Failed to parse")); + assertThat(response.getQueryExplanation().get(0).getError(), containsString("Failed to derive xcontent")); assertThat(response.getQueryExplanation().get(0).getExplanation(), nullValue()); } @@ -260,7 +260,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { ensureGreen(); refresh(); - assertThat(client().admin().indices().prepareValidateQuery("test").setSource(new BytesArray("{\"foo\": \"bar\", \"query\": {\"term\" : { \"user\" : \"kimchy\" }}}")).get().isValid(), equalTo(false)); + assertThat(client().admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.wrapperQuery(new BytesArray("{\"foo\": \"bar\", \"query\": {\"term\" : { \"user\" : \"kimchy\" }}}"))).get().isValid(), equalTo(false)); } public void testIrrelevantPropertiesAfterQuery() throws IOException { @@ -268,7 +268,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { ensureGreen(); refresh(); - assertThat(client().admin().indices().prepareValidateQuery("test").setSource(new BytesArray("{\"query\": {\"term\" : { \"user\" : \"kimchy\" }}, \"foo\": \"bar\"}")).get().isValid(), equalTo(false)); + assertThat(client().admin().indices().prepareValidateQuery("test").setQuery(QueryBuilders.wrapperQuery(new BytesArray("{\"query\": {\"term\" : { \"user\" : \"kimchy\" }}, \"foo\": \"bar\"}"))).get().isValid(), equalTo(false)); } private static void assertExplanation(QueryBuilder queryBuilder, Matcher matcher, boolean withRewrite) { diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/10_basic.yaml index 87014a09b33..d8b3bfea385 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.validate_query/10_basic.yaml @@ -25,6 +25,17 @@ setup: invalid_query: {} - is_false: valid + - is_false: error + + - do: + indices.validate_query: + explain: true + body: + query: + invalid_query: {} + + - is_false: valid + - match: {error: 'org.elasticsearch.common.ParsingException: No query registered for [invalid_query]'} - do: indices.validate_query: @@ -43,3 +54,13 @@ setup: match_all: {} - is_false: valid + - is_false: error + + - do: + indices.validate_query: + explain: true + body: + match_all: {} + + - is_false: valid + - match: {error: 'org.elasticsearch.common.ParsingException: request does not support [match_all]'} From 72463768f506f854f0a9706de0a553d49f4b3e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 22 Oct 2015 14:20:34 +0200 Subject: [PATCH 32/37] Query DSL: Parsers should throw exception on unknown object This PR adds a randomized test to the query test base class that mutates an otherwise correct query by adding an additional object into the query hierarchy. Doing so makes the query illegal and should trigger some kind of exception. The new test revelead that some query parsers quietly return queries when called with such an illegal query. Those are also fixed here. Relates to #10974 --- .../termvectors/TermVectorsRequest.java | 5 +-- .../index/query/CommonTermsQueryParser.java | 11 ++++-- .../index/query/ExistsQueryParser.java | 6 ++- .../index/query/GeoShapeQueryParser.java | 10 +++-- .../index/query/IdsQueryParser.java | 8 ++-- .../index/query/MatchAllQueryParser.java | 4 +- .../index/query/MatchNoneQueryParser.java | 2 + .../index/query/MatchQueryParser.java | 8 ++-- .../index/query/MissingQueryParser.java | 4 +- .../index/query/MultiMatchQueryParser.java | 4 +- .../index/query/QueryStringQueryParser.java | 10 +++-- .../index/query/SimpleQueryStringParser.java | 2 + .../index/query/TermsQueryParser.java | 12 ++++-- .../cache/query/terms/TermsLookup.java | 11 ++++-- .../index/query/AbstractQueryTestCase.java | 26 +++++++++++++ .../query/HasChildQueryBuilderTests.java | 39 ++++++++++++++++++- .../query/HasParentQueryBuilderTests.java | 38 ++++++++++++++++++ .../query/SimpleQueryStringBuilderTests.java | 4 +- .../index/query/TermsQueryBuilderTests.java | 13 ++++--- 19 files changed, 178 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java b/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java index ef998922d51..c13e44097bc 100644 --- a/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java +++ b/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.termvectors; -import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.DocumentRequest; @@ -211,7 +210,7 @@ public class TermVectorsRequest extends SingleShardRequest i public String id() { return id; } - + /** * Sets the id of document the term vector is requested for. */ @@ -651,7 +650,7 @@ public class TermVectorsRequest extends SingleShardRequest i if (e.getValue() instanceof String) { mapStrStr.put(e.getKey(), (String) e.getValue()); } else { - throw new ElasticsearchException("expecting the analyzer at [{}] to be a String, but found [{}] instead", e.getKey(), e.getValue().getClass()); + throw new ElasticsearchParseException("expecting the analyzer at [{}] to be a String, but found [{}] instead", e.getKey(), e.getValue().getClass()); } } return mapStrStr; diff --git a/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java index 86de4e31129..3ecbd11320e 100644 --- a/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/CommonTermsQueryParser.java @@ -39,7 +39,7 @@ public class CommonTermsQueryParser implements QueryParser { } else if ("boost".equals(currentFieldName)) { boost = parser.floatValue(); } else { - throw new ParsingException(parser.getTokenLocation(), "[exists] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + ExistsQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + ExistsQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } if (fieldPattern == null) { - throw new ParsingException(parser.getTokenLocation(), "exists must be provided with a [field]"); + throw new ParsingException(parser.getTokenLocation(), "[" + ExistsQueryBuilder.NAME + "] must be provided with a [field]"); } ExistsQueryBuilder builder = new ExistsQueryBuilder(fieldPattern); diff --git a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java index e5198952c13..768600c3b38 100644 --- a/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryParser.java @@ -70,8 +70,10 @@ public class GeoShapeQueryParser implements QueryParser { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); } else if (token == XContentParser.Token.START_OBJECT) { + if (fieldName != null) { + throw new ParsingException(parser.getTokenLocation(), "[" + GeoShapeQueryBuilder.NAME + "] point specified twice. [" + currentFieldName + "]"); + } fieldName = currentFieldName; - while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { currentFieldName = parser.currentName(); @@ -104,10 +106,12 @@ public class GeoShapeQueryParser implements QueryParser { } else if (parseContext.parseFieldMatcher().match(currentFieldName, SHAPE_PATH_FIELD)) { shapePath = parser.text(); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + GeoShapeQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } } else { - throw new ParsingException(parser.getTokenLocation(), "[geo_shape] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + GeoShapeQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } } } @@ -117,7 +121,7 @@ public class GeoShapeQueryParser implements QueryParser { } else if (parseContext.parseFieldMatcher().match(currentFieldName, AbstractQueryBuilder.NAME_FIELD)) { queryName = parser.text(); } else { - throw new ParsingException(parser.getTokenLocation(), "[geo_shape] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + GeoShapeQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } } } diff --git a/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java index 0ffd31644e5..0496a690f5f 100644 --- a/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/IdsQueryParser.java @@ -79,7 +79,7 @@ public class IdsQueryParser implements QueryParser { types.add(value); } } else { - throw new ParsingException(parser.getTokenLocation(), "[ids] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + IdsQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } } else if (token.isValue()) { if ("type".equals(currentFieldName) || "_type".equals(currentFieldName)) { @@ -89,12 +89,14 @@ public class IdsQueryParser implements QueryParser { } else if ("_name".equals(currentFieldName)) { queryName = parser.text(); } else { - throw new ParsingException(parser.getTokenLocation(), "[ids] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + IdsQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + IdsQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } if (!idsProvided) { - throw new ParsingException(parser.getTokenLocation(), "[ids] query, no ids values provided"); + throw new ParsingException(parser.getTokenLocation(), "[" + IdsQueryBuilder.NAME + "] query, no ids values provided"); } IdsQueryBuilder query = new IdsQueryBuilder(types.toArray(new String[types.size()])); diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java index 770f9c3dd67..6cab98838e0 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchAllQueryParser.java @@ -52,8 +52,10 @@ public class MatchAllQueryParser implements QueryParser { } else if ("boost".equals(currentFieldName)) { boost = parser.floatValue(); } else { - throw new ParsingException(parser.getTokenLocation(), "[match_all] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + MatchAllQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + MatchAllQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } MatchAllQueryBuilder queryBuilder = new MatchAllQueryBuilder(); diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java index 96b33f545f8..449824e72c9 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchNoneQueryParser.java @@ -51,6 +51,8 @@ public class MatchNoneQueryParser implements QueryParser } else { throw new ParsingException(parser.getTokenLocation(), "["+MatchNoneQueryBuilder.NAME+"] query does not support [" + currentFieldName + "]"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + MatchNoneQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } diff --git a/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java index afcf25ca2a7..c50256480a0 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java @@ -55,7 +55,7 @@ public class MatchQueryParser implements QueryParser { XContentParser.Token token = parser.nextToken(); if (token != XContentParser.Token.FIELD_NAME) { - throw new ParsingException(parser.getTokenLocation(), "[match] query malformed, no field"); + throw new ParsingException(parser.getTokenLocation(), "[" + MatchQueryBuilder.NAME + "] query malformed, no field"); } String fieldName = parser.currentName(); @@ -93,7 +93,7 @@ public class MatchQueryParser implements QueryParser { } else if ("phrase_prefix".equals(tStr) || "phrasePrefix".equals(currentFieldName)) { type = MatchQuery.Type.PHRASE_PREFIX; } else { - throw new ParsingException(parser.getTokenLocation(), "[match] query does not support type " + tStr); + throw new ParsingException(parser.getTokenLocation(), "[" + MatchQueryBuilder.NAME + "] query does not support type " + tStr); } } else if ("analyzer".equals(currentFieldName)) { analyzer = parser.text(); @@ -131,8 +131,10 @@ public class MatchQueryParser implements QueryParser { } else if ("_name".equals(currentFieldName)) { queryName = parser.text(); } else { - throw new ParsingException(parser.getTokenLocation(), "[match] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + MatchQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + MatchQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } parser.nextToken(); diff --git a/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java index 8d8c5aec01f..3a696dad38f 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MissingQueryParser.java @@ -61,8 +61,10 @@ public class MissingQueryParser implements QueryParser { } else if ("boost".equals(currentFieldName)) { boost = parser.floatValue(); } else { - throw new ParsingException(parser.getTokenLocation(), "[missing] query does not support [" + currentFieldName + "]"); + throw new ParsingException(parser.getTokenLocation(), "[" + MissingQueryBuilder.NAME + "] query does not support [" + currentFieldName + "]"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + MissingQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } diff --git a/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java b/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java index c86d0295577..d52f6707aa1 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java +++ b/core/src/main/java/org/elasticsearch/index/query/MultiMatchQueryParser.java @@ -122,8 +122,10 @@ public class MultiMatchQueryParser implements QueryParser, ToXContent { public TermsLookup(String index, String type, String id, String path) { if (id == null) { - throw new IllegalArgumentException("[terms] query lookup element requires specifying the id."); + throw new IllegalArgumentException("[" + TermsQueryBuilder.NAME + "] query lookup element requires specifying the id."); } if (type == null) { - throw new IllegalArgumentException("[terms] query lookup element requires specifying the type."); + throw new IllegalArgumentException("[" + TermsQueryBuilder.NAME + "] query lookup element requires specifying the type."); } if (path == null) { - throw new IllegalArgumentException("[terms] query lookup element requires specifying the path."); + throw new IllegalArgumentException("[" + TermsQueryBuilder.NAME + "] query lookup element requires specifying the path."); } this.index = index; this.type = type; @@ -122,9 +123,11 @@ public class TermsLookup implements Writeable, ToXContent { path = parser.text(); break; default: - throw new ParsingException(parser.getTokenLocation(), "[terms] query does not support [" + currentFieldName + throw new ParsingException(parser.getTokenLocation(), "[" + TermsQueryBuilder.NAME + "] query does not support [" + currentFieldName + "] within lookup element"); } + } else { + throw new ParsingException(parser.getTokenLocation(), "[" + TermsQueryBuilder.NAME + "] unknown token [" + token + "] after [" + currentFieldName + "]"); } } return new TermsLookup(index, type, id, path).routing(routing); diff --git a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java index 212dd457171..c553e94e29f 100644 --- a/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/AbstractQueryTestCase.java @@ -20,10 +20,12 @@ package org.elasticsearch.index.query; import com.carrotsearch.randomizedtesting.generators.CodepointSetGenerator; +import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.io.JsonStringEncoder; import org.apache.lucene.search.Query; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; import org.elasticsearch.action.get.GetRequest; @@ -76,6 +78,7 @@ import org.elasticsearch.indices.IndicesWarmer; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.script.*; +import org.elasticsearch.script.Script.ScriptParseException; import org.elasticsearch.script.mustache.MustacheScriptEngineService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ESTestCase; @@ -344,6 +347,29 @@ public abstract class AbstractQueryTestCase> // we'd like to see the offending field name here assertThat(e.getMessage(), containsString("bogusField")); } + } + + /** + * Test that adding additional object into otherwise correct query string + * should always trigger some kind of Parsing Exception. + */ + public void testUnknownObjectException() throws IOException { + String validQuery = createTestQueryBuilder().toString(); + assertThat(validQuery, containsString("{")); + for (int insertionPosition = 0; insertionPosition < validQuery.length(); insertionPosition++) { + if (validQuery.charAt(insertionPosition) == '{') { + String testQuery = validQuery.substring(0, insertionPosition) + "{ \"newField\" : " + validQuery.substring(insertionPosition) + "}"; + try { + parseQuery(testQuery); + fail("some parsing exception expected for query: " + testQuery); + } catch (ParsingException | ScriptParseException | ElasticsearchParseException e) { + // different kinds of exception wordings depending on location + // of mutation, so no simple asserts possible here + } catch (JsonParseException e) { + // mutation produced invalid json + } + } + } } /** diff --git a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java index c567ba3a0f3..a6c63f83c96 100644 --- a/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/HasChildQueryBuilderTests.java @@ -20,11 +20,15 @@ package org.elasticsearch.index.query; import com.carrotsearch.randomizedtesting.generators.RandomPicks; +import com.fasterxml.jackson.core.JsonParseException; + import org.apache.lucene.queries.TermsQuery; import org.apache.lucene.search.*; import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.util.BytesRef; +import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -35,6 +39,7 @@ import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.internal.TypeFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.query.support.QueryInnerHits; +import org.elasticsearch.script.Script.ScriptParseException; import org.elasticsearch.search.fetch.innerhits.InnerHitsBuilder; import org.elasticsearch.search.fetch.innerhits.InnerHitsContext; import org.elasticsearch.search.internal.SearchContext; @@ -44,7 +49,8 @@ import org.elasticsearch.test.TestSearchContext; import java.io.IOException; import java.util.Collections; -import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath; +import static org.hamcrest.Matchers.containsString; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; @@ -52,6 +58,7 @@ public class HasChildQueryBuilderTests extends AbstractQueryTestCase { private List randomTerms; @@ -195,9 +198,9 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase Date: Mon, 2 Nov 2015 14:38:03 +0100 Subject: [PATCH 33/37] Adding US-Gov-West for S3 Follow up for #14358 --- .../java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java index 81b7e315b69..4752a3f80b2 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/cloud/aws/InternalAwsS3Service.java @@ -193,6 +193,8 @@ public class InternalAwsS3Service extends AbstractLifecycleComponent Date: Mon, 2 Nov 2015 15:33:36 +0100 Subject: [PATCH 34/37] Fix test for ec2 discovery See #14155 --- .../org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java index 4fc3faef316..6f88be2be5a 100644 --- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java +++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java @@ -251,7 +251,7 @@ public class Ec2DiscoveryTests extends ESTestCase { for (int i=0; i<3; i++) { provider.buildDynamicNodes(); } - assertEquals(provider.fetchCount, is(3)); + assertThat(provider.fetchCount, is(3)); } public void testGetNodeListCached() throws Exception { @@ -268,11 +268,11 @@ public class Ec2DiscoveryTests extends ESTestCase { for (int i=0; i<3; i++) { provider.buildDynamicNodes(); } - assertEquals(provider.fetchCount, is(1)); + assertThat(provider.fetchCount, is(1)); Thread.sleep(1_000L); // wait for cache to expire for (int i=0; i<3; i++) { provider.buildDynamicNodes(); } - assertEquals(provider.fetchCount, is(2)); + assertThat(provider.fetchCount, is(2)); } } From 9056ebb20dfa8219ce8fa581a1e2eef479329433 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 2 Nov 2015 09:39:14 -0500 Subject: [PATCH 35/37] gradle cleanEclipse should completely nuke .settings. Today this will only remove `.settings/org.eclipse.jdt.core.prefs`, leaving a bunch of stale eclipse configuration everywhere. --- .settings/org.eclipse.core.resources.prefs | 6 ------ .settings/org.eclipse.jdt.core.prefs | 18 ------------------ .settings/org.eclipse.jdt.ui.prefs | 6 ------ build.gradle | 5 +++++ 4 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .settings/org.eclipse.jdt.core.prefs delete mode 100644 .settings/org.eclipse.jdt.ui.prefs diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 5731b2f8244..00000000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 -encoding/rest-api-spec=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f1163fdd583..00000000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,18 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nullable=org.elasticsearch.common.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.formatter.lineSplit=140 -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 4a9959fc9fc..00000000000 --- a/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -formatter_settings_version=12 -# Intellij IDEA import order -org.eclipse.jdt.ui.importorder=;com;org;java;javax;\#; -# License header -org.eclipse.jdt.ui.text.custom_code_templates= diff --git a/build.gradle b/build.gradle index 621f137eb94..93406d4965e 100644 --- a/build.gradle +++ b/build.gradle @@ -178,6 +178,11 @@ allprojects { } } } + task cleanEclipseSettings(type: Delete) { + delete '.settings' + } + // otherwise .settings is not nuked entirely + tasks.cleanEclipse.dependsOn(cleanEclipseSettings) // otherwise the eclipse merging is *super confusing* tasks.eclipse.dependsOn(cleanEclipse) } From 4587a94fcf821f9d772eab44e69e8c25f2ae100f Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 2 Nov 2015 10:44:51 -0500 Subject: [PATCH 36/37] generate complete eclipse configuration from 'gradle eclipse' --- build.gradle | 6 ++++++ .../org.eclipse.core.resources.prefs | 6 ++++++ .../org.eclipse.jdt.core.prefs | 19 +++++++++++++++++++ .../eclipse.settings/org.eclipse.jdt.ui.prefs | 6 ++++++ 4 files changed, 37 insertions(+) create mode 100644 buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs create mode 100644 buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs create mode 100644 buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs diff --git a/build.gradle b/build.gradle index 93406d4965e..9adb3aeb0eb 100644 --- a/build.gradle +++ b/build.gradle @@ -181,10 +181,16 @@ allprojects { task cleanEclipseSettings(type: Delete) { delete '.settings' } + task copyEclipseSettings(type: Copy) { + // TODO: "package this up" for external builds + from new File(project.rootDir, 'buildSrc/src/main/resources/eclipse.settings') + into '.settings' + } // otherwise .settings is not nuked entirely tasks.cleanEclipse.dependsOn(cleanEclipseSettings) // otherwise the eclipse merging is *super confusing* tasks.eclipse.dependsOn(cleanEclipse) + tasks.eclipse.dependsOn(copyEclipseSettings) } diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..6fd0a9aab13 --- /dev/null +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 +encoding//src/test/resources=UTF-8 +encoding/=UTF-8 \ No newline at end of file diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..f9b349c46d1 --- /dev/null +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,19 @@ +eclipse.preferences.version=1 + +# previous configuration from maven build +# this is merged with gradle's generated properties during 'gradle eclipse' + +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nullable=org.elasticsearch.common.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.formatter.lineSplit=140 +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..a42667f8698 --- /dev/null +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,6 @@ +eclipse.preferences.version=1 +formatter_settings_version=12 +# Intellij IDEA import order +org.eclipse.jdt.ui.importorder=;com;org;java;javax;\#; +# License header +org.eclipse.jdt.ui.text.custom_code_templates= \ No newline at end of file From 951bc5a4a7c8e56b274f9b0e0e1959c7217ffb45 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 2 Nov 2015 10:55:31 -0500 Subject: [PATCH 37/37] disable null pointer analysis so the IDE is not crashing. --- .../org.eclipse.jdt.core.prefs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs index f9b349c46d1..9bee5e587b0 100644 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.core.prefs @@ -3,17 +3,20 @@ eclipse.preferences.version=1 # previous configuration from maven build # this is merged with gradle's generated properties during 'gradle eclipse' -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nullable=org.elasticsearch.common.Nullable -org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +# NOTE: null pointer analysis etc is not enabled currently, it seems very unstable +# (e.g. crashing eclipse etc) +# org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled +# org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +# org.eclipse.jdt.core.compiler.annotation.nullable=org.elasticsearch.common.Nullable +# org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled +# org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +# org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning +# org.eclipse.jdt.core.compiler.problem.nullReference=warning +# org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning +# org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +# org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning + org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning org.eclipse.jdt.core.formatter.lineSplit=140 org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4