diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.groovy index 190b0150bc4..6809adca946 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/ForbiddenPatternsTask.groovy @@ -61,10 +61,6 @@ public class ForbiddenPatternsTask extends DefaultTask { // add mandatory rules patterns.put('nocommit', /nocommit/) patterns.put('tab', /\t/) - patterns.put('wildcard imports', /^\s*import.*\.\*/) - // We don't use Java serialization so we fail if it looks like we're trying to. - patterns.put('declares serialVersionUID', /serialVersionUID/) - patterns.put('references Serializable', /java\.io\.Serializable/) inputs.property("excludes", filesFilter.excludes) inputs.property("rules", patterns) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy index f99032e1e2d..d4d4d08c393 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy @@ -30,9 +30,9 @@ class PrecommitTasks { /** Adds a precommit task, which depends on non-test verification tasks. */ public static Task create(Project project, boolean includeDependencyLicenses) { - List precommitTasks = [ configureForbiddenApis(project), + configureCheckstyle(project), project.tasks.create('forbiddenPatterns', ForbiddenPatternsTask.class), project.tasks.create('licenseHeaders', LicenseHeadersTask.class), project.tasks.create('jarHell', JarHellTask.class), @@ -83,4 +83,25 @@ class PrecommitTasks { forbiddenApis.group = "" // clear group, so this does not show up under verification tasks return forbiddenApis } + + private static Task configureCheckstyle(Project project) { + Task checkstyleTask = project.tasks.create('checkstyle') + // Apply the checkstyle plugin to create `checkstyleMain` and `checkstyleTest`. It only + // creates them if there is main or test code to check and it makes `check` depend + // on them. But we want `precommit` to depend on `checkstyle` which depends on them so + // we have to swap them. + project.pluginManager.apply('checkstyle') + project.checkstyle { + config = project.resources.text.fromFile( + PrecommitTasks.getResource('/checkstyle.xml'), 'UTF-8') + } + for (String taskName : ['checkstyleMain', 'checkstyleTest']) { + Task task = project.tasks.findByName(taskName) + if (task != null) { + project.tasks['check'].dependsOn.remove(task) + checkstyleTask.dependsOn(task) + } + } + return checkstyleTask + } } diff --git a/buildSrc/src/main/resources/checkstyle.xml b/buildSrc/src/main/resources/checkstyle.xml new file mode 100644 index 00000000000..b44c649a52b --- /dev/null +++ b/buildSrc/src/main/resources/checkstyle.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java index af18ac5db46..847de99f372 100644 --- a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java +++ b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java @@ -139,24 +139,24 @@ public class SimulatePipelineRequest extends ActionRequest config, boolean verbose, PipelineStore pipelineStore) throws Exception { - Map pipelineConfig = ConfigurationUtils.readMap(config, Fields.PIPELINE); + Map pipelineConfig = ConfigurationUtils.readMap(null, null, config, Fields.PIPELINE); Pipeline pipeline = PIPELINE_FACTORY.create(SIMULATED_PIPELINE_ID, pipelineConfig, pipelineStore.getProcessorFactoryRegistry()); List ingestDocumentList = parseDocs(config); return new Parsed(pipeline, ingestDocumentList, verbose); } private static List parseDocs(Map config) { - List> docs = ConfigurationUtils.readList(config, Fields.DOCS); + List> docs = ConfigurationUtils.readList(null, null, config, Fields.DOCS); List ingestDocumentList = new ArrayList<>(); for (Map dataMap : docs) { - Map document = ConfigurationUtils.readMap(dataMap, Fields.SOURCE); - IngestDocument ingestDocument = new IngestDocument(ConfigurationUtils.readStringProperty(dataMap, MetaData.INDEX.getFieldName(), "_index"), - ConfigurationUtils.readStringProperty(dataMap, MetaData.TYPE.getFieldName(), "_type"), - ConfigurationUtils.readStringProperty(dataMap, MetaData.ID.getFieldName(), "_id"), - ConfigurationUtils.readOptionalStringProperty(dataMap, MetaData.ROUTING.getFieldName()), - ConfigurationUtils.readOptionalStringProperty(dataMap, MetaData.PARENT.getFieldName()), - ConfigurationUtils.readOptionalStringProperty(dataMap, MetaData.TIMESTAMP.getFieldName()), - ConfigurationUtils.readOptionalStringProperty(dataMap, MetaData.TTL.getFieldName()), + Map document = ConfigurationUtils.readMap(null, null, dataMap, Fields.SOURCE); + IngestDocument ingestDocument = new IngestDocument(ConfigurationUtils.readStringProperty(null, null, dataMap, MetaData.INDEX.getFieldName(), "_index"), + ConfigurationUtils.readStringProperty(null, null, dataMap, MetaData.TYPE.getFieldName(), "_type"), + ConfigurationUtils.readStringProperty(null, null, dataMap, MetaData.ID.getFieldName(), "_id"), + ConfigurationUtils.readOptionalStringProperty(null, null, dataMap, MetaData.ROUTING.getFieldName()), + ConfigurationUtils.readOptionalStringProperty(null, null, dataMap, MetaData.PARENT.getFieldName()), + ConfigurationUtils.readOptionalStringProperty(null, null, dataMap, MetaData.TIMESTAMP.getFieldName()), + ConfigurationUtils.readOptionalStringProperty(null, null, dataMap, MetaData.TTL.getFieldName()), document); ingestDocumentList.add(ingestDocument); } diff --git a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java index c7c0822f04a..4337d0ee165 100644 --- a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java +++ b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineResponse.java @@ -22,24 +22,31 @@ package org.elasticsearch.action.ingest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.StatusToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; +import org.elasticsearch.ingest.core.PipelineFactoryError; +import org.elasticsearch.rest.RestStatus; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class SimulatePipelineResponse extends ActionResponse implements ToXContent { +public class SimulatePipelineResponse extends ActionResponse implements StatusToXContent { private String pipelineId; private boolean verbose; private List results; + private PipelineFactoryError error; public SimulatePipelineResponse() { } + public SimulatePipelineResponse(PipelineFactoryError error) { + this.error = error; + } + public SimulatePipelineResponse(String pipelineId, boolean verbose, List responses) { this.pipelineId = pipelineId; this.verbose = verbose; @@ -58,42 +65,69 @@ public class SimulatePipelineResponse extends ActionResponse implements ToXConte return verbose; } + public boolean isError() { + return error != null; + } + + @Override + public RestStatus status() { + if (isError()) { + return RestStatus.BAD_REQUEST; + } + return RestStatus.OK; + } + @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - out.writeString(pipelineId); - out.writeBoolean(verbose); - out.writeVInt(results.size()); - for (SimulateDocumentResult response : results) { - response.writeTo(out); + out.writeBoolean(isError()); + if (isError()) { + error.writeTo(out); + } else { + out.writeString(pipelineId); + out.writeBoolean(verbose); + out.writeVInt(results.size()); + for (SimulateDocumentResult response : results) { + response.writeTo(out); + } } } @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - this.pipelineId = in.readString(); - boolean verbose = in.readBoolean(); - int responsesLength = in.readVInt(); - results = new ArrayList<>(); - for (int i = 0; i < responsesLength; i++) { - SimulateDocumentResult simulateDocumentResult; - if (verbose) { - simulateDocumentResult = SimulateDocumentVerboseResult.readSimulateDocumentVerboseResultFrom(in); - } else { - simulateDocumentResult = SimulateDocumentBaseResult.readSimulateDocumentSimpleResult(in); + boolean isError = in.readBoolean(); + if (isError) { + error = new PipelineFactoryError(); + error.readFrom(in); + } else { + this.pipelineId = in.readString(); + boolean verbose = in.readBoolean(); + int responsesLength = in.readVInt(); + results = new ArrayList<>(); + for (int i = 0; i < responsesLength; i++) { + SimulateDocumentResult simulateDocumentResult; + if (verbose) { + simulateDocumentResult = SimulateDocumentVerboseResult.readSimulateDocumentVerboseResultFrom(in); + } else { + simulateDocumentResult = SimulateDocumentBaseResult.readSimulateDocumentSimpleResult(in); + } + results.add(simulateDocumentResult); } - results.add(simulateDocumentResult); } } @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startArray(Fields.DOCUMENTS); - for (SimulateDocumentResult response : results) { - response.toXContent(builder, params); + if (isError()) { + error.toXContent(builder, params); + } else { + builder.startArray(Fields.DOCUMENTS); + for (SimulateDocumentResult response : results) { + response.toXContent(builder, params); + } + builder.endArray(); } - builder.endArray(); return builder; } diff --git a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineTransportAction.java b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineTransportAction.java index 5640d7c1c8c..3d6586315ad 100644 --- a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineTransportAction.java +++ b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineTransportAction.java @@ -27,6 +27,8 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.ingest.PipelineStore; +import org.elasticsearch.ingest.core.PipelineFactoryError; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -56,6 +58,9 @@ public class SimulatePipelineTransportAction extends HandledTransportAction { + + public WritePipelineResponseRestListener(RestChannel channel) { + super(channel); + } + + @Override + protected void addCustomFields(XContentBuilder builder, WritePipelineResponse response) throws IOException { + if (!response.isAcknowledged()) { + response.getError().toXContent(builder, null); + } + } +} + diff --git a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index a5977a42146..c40d3fb579a 100644 --- a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -320,7 +320,6 @@ public abstract class TransportReplicationAction TYPE_SETTING = new Setting<>("cache.recycler.page.type", Type.CONCURRENT.name(), Type::parse, false, Setting.Scope.CLUSTER); + public static final Setting LIMIT_HEAP_SETTING = Setting.byteSizeSetting("cache.recycler.page.limit.heap", "10%", false, Setting.Scope.CLUSTER); + public static final Setting WEIGHT_BYTES_SETTING = Setting.doubleSetting("cache.recycler.page.weight.bytes", 1d, 0d, false, Setting.Scope.CLUSTER); + public static final Setting WEIGHT_LONG_SETTING = Setting.doubleSetting("cache.recycler.page.weight.longs", 1d, 0d, false, Setting.Scope.CLUSTER); + public static final Setting WEIGHT_INT_SETTING = Setting.doubleSetting("cache.recycler.page.weight.ints", 1d, 0d, false, Setting.Scope.CLUSTER); + // object pages are less useful to us so we give them a lower weight by default + public static final Setting WEIGHT_OBJECTS_SETTING = Setting.doubleSetting("cache.recycler.page.weight.objects", 0.1d, 0d, false, Setting.Scope.CLUSTER); private final Recycler bytePage; private final Recycler intPage; private final Recycler longPage; private final Recycler objectPage; + @Override public void close() { bytePage.close(); intPage.close(); @@ -71,8 +79,8 @@ public class PageCacheRecycler extends AbstractComponent { @Inject public PageCacheRecycler(Settings settings, ThreadPool threadPool) { super(settings); - final Type type = Type.parse(settings.get(TYPE)); - final long limit = settings.getAsMemory(LIMIT_HEAP, "10%").bytes(); + final Type type = TYPE_SETTING .get(settings); + final long limit = LIMIT_HEAP_SETTING .get(settings).bytes(); final int availableProcessors = EsExecutors.boundedNumberOfProcessors(settings); final int searchThreadPoolSize = maximumSearchThreadPoolSize(threadPool, settings); @@ -89,11 +97,10 @@ public class PageCacheRecycler extends AbstractComponent { // to direct ByteBuffers or sun.misc.Unsafe on a byte[] but this would have other issues // that would need to be addressed such as garbage collection of native memory or safety // of Unsafe writes. - final double bytesWeight = settings.getAsDouble(WEIGHT + ".bytes", 1d); - final double intsWeight = settings.getAsDouble(WEIGHT + ".ints", 1d); - final double longsWeight = settings.getAsDouble(WEIGHT + ".longs", 1d); - // object pages are less useful to us so we give them a lower weight by default - final double objectsWeight = settings.getAsDouble(WEIGHT + ".objects", 0.1d); + final double bytesWeight = WEIGHT_BYTES_SETTING .get(settings); + final double intsWeight = WEIGHT_INT_SETTING .get(settings); + final double longsWeight = WEIGHT_LONG_SETTING .get(settings); + final double objectsWeight = WEIGHT_OBJECTS_SETTING .get(settings); final double totalWeight = bytesWeight + intsWeight + longsWeight + objectsWeight; final int maxPageCount = (int) Math.min(Integer.MAX_VALUE, limit / BigArrays.PAGE_SIZE_IN_BYTES); @@ -188,7 +195,7 @@ public class PageCacheRecycler extends AbstractComponent { return recycler; } - public static enum Type { + public enum Type { QUEUE { @Override Recycler build(Recycler.C c, int limit, int estimatedThreadPoolSize, int availableProcessors) { @@ -209,9 +216,6 @@ public class PageCacheRecycler extends AbstractComponent { }; public static Type parse(String type) { - if (Strings.isNullOrEmpty(type)) { - return CONCURRENT; - } try { return Type.valueOf(type.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java index 295562324e1..ecbf3eb9614 100644 --- a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -112,7 +112,7 @@ public class TransportClient extends AbstractClient { final Settings.Builder settingsBuilder = settingsBuilder() .put(NettyTransport.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval .put(InternalSettingsPreparer.prepareSettings(settings)) - .put(NettyTransport.NETWORK_SERVER.getKey(), false) + .put(NetworkService.NETWORK_SERVER.getKey(), false) .put(Node.NODE_CLIENT_SETTING.getKey(), true) .put(CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE); return new PluginsService(settingsBuilder.build(), null, null, pluginClasses); diff --git a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java index 4fdd11c4dd4..f8822ceb281 100644 --- a/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java +++ b/core/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java @@ -302,7 +302,7 @@ public class IndexMetaData implements Diffable, FromXContentBuild } public long getCreationDate() { - return settings.getAsLong(SETTING_CREATION_DATE, -1l); + return settings.getAsLong(SETTING_CREATION_DATE, -1L); } public State getState() { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java b/core/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java index 68f210fc144..714c1e4913a 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java @@ -106,7 +106,7 @@ public class UnassignedInfo implements ToXContent, Writeable { private final Reason reason; private final long unassignedTimeMillis; // used for display and log messages, in milliseconds private final long unassignedTimeNanos; // in nanoseconds, used to calculate delay for delayed shard allocation - private volatile long lastComputedLeftDelayNanos = 0l; // how long to delay shard allocation, not serialized (always positive, 0 means no delay) + private volatile long lastComputedLeftDelayNanos = 0L; // how long to delay shard allocation, not serialized (always positive, 0 means no delay) private final String message; private final Throwable failure; @@ -217,7 +217,7 @@ public class UnassignedInfo implements ToXContent, Writeable { return 0; } TimeValue delayTimeout = INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(indexSettings, settings); - return Math.max(0l, delayTimeout.nanos()); + return Math.max(0L, delayTimeout.nanos()); } /** @@ -236,8 +236,8 @@ public class UnassignedInfo implements ToXContent, Writeable { public long updateDelay(long nanoTimeNow, Settings settings, Settings indexSettings) { long delayTimeoutNanos = getAllocationDelayTimeoutSettingNanos(settings, indexSettings); final long newComputedLeftDelayNanos; - if (delayTimeoutNanos == 0l) { - newComputedLeftDelayNanos = 0l; + if (delayTimeoutNanos == 0L) { + newComputedLeftDelayNanos = 0L; } else { assert nanoTimeNow >= unassignedTimeNanos; newComputedLeftDelayNanos = Math.max(0L, delayTimeoutNanos - (nanoTimeNow - unassignedTimeNanos)); @@ -277,7 +277,7 @@ public class UnassignedInfo implements ToXContent, Writeable { } } } - return minDelaySetting == Long.MAX_VALUE ? 0l : minDelaySetting; + return minDelaySetting == Long.MAX_VALUE ? 0L : minDelaySetting; } @@ -294,7 +294,7 @@ public class UnassignedInfo implements ToXContent, Writeable { } } } - return nextDelay == Long.MAX_VALUE ? 0l : nextDelay; + return nextDelay == Long.MAX_VALUE ? 0L : nextDelay; } public String shortSummary() { diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java index b1be2a6fce4..11fce397b26 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ClusterRebalanceAllocationDecider.java @@ -90,7 +90,7 @@ public class ClusterRebalanceAllocationDecider extends AllocationDecider { logger.warn("[{}] has a wrong value {}, defaulting to 'indices_all_active'", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getRaw(settings)); type = ClusterRebalanceType.INDICES_ALL_ACTIVE; } - logger.debug("using [{}] with [{}]", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, type.toString().toLowerCase(Locale.ROOT)); + logger.debug("using [{}] with [{}]", CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), type.toString().toLowerCase(Locale.ROOT)); clusterSettings.addSettingsUpdateConsumer(CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, this::setType); } diff --git a/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java b/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java index cec805e7a80..c5c36b5b0c2 100644 --- a/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java +++ b/core/src/main/java/org/elasticsearch/common/geo/GeoUtils.java @@ -179,7 +179,7 @@ public class GeoUtils { final double width = Math.sqrt((meters*meters)/(ratio*ratio)); // convert to cell width final long part = Math.round(Math.ceil(EARTH_EQUATOR / width)); final int level = Long.SIZE - Long.numberOfLeadingZeros(part)-1; // (log_2) - return (part<=(1l< releasables, boolean ignoreException) { - Throwable th = null; - for (Releasable releasable : releasables) { - if (releasable != null) { - try { - releasable.close(); - } catch (Throwable t) { - if (th == null) { - th = t; - } - } + try { + // this does the right thing with respect to add suppressed and not wrapping errors etc. + IOUtils.close(releasables); + } catch (Throwable t) { + if (ignoreException == false) { + IOUtils.reThrowUnchecked(t); } } - if (th != null && !ignoreException) { - rethrow(th); - } } /** Release the provided {@link Releasable}s. */ @@ -99,25 +85,11 @@ public enum Releasables { * */ public static Releasable wrap(final Iterable releasables) { - return new Releasable() { - - @Override - public void close() { - Releasables.close(releasables); - } - - }; + return () -> close(releasables); } /** @see #wrap(Iterable) */ public static Releasable wrap(final Releasable... releasables) { - return new Releasable() { - - @Override - public void close() { - Releasables.close(releasables); - } - - }; + return () -> close(releasables); } } diff --git a/core/src/main/java/org/elasticsearch/common/network/NetworkService.java b/core/src/main/java/org/elasticsearch/common/network/NetworkService.java index a1286aaec55..1debc6960af 100644 --- a/core/src/main/java/org/elasticsearch/common/network/NetworkService.java +++ b/core/src/main/java/org/elasticsearch/common/network/NetworkService.java @@ -49,6 +49,7 @@ public class NetworkService extends AbstractComponent { s -> s, false, Setting.Scope.CLUSTER); public static final Setting> GLOBAL_NETWORK_PUBLISHHOST_SETTING = Setting.listSetting("network.publish_host", GLOBAL_NETWORK_HOST_SETTING, s -> s, false, Setting.Scope.CLUSTER); + public static final Setting NETWORK_SERVER = Setting.boolSetting("network.server", true, false, Setting.Scope.CLUSTER); public static final class TcpSettings { public static final Setting TCP_NO_DELAY = Setting.boolSetting("network.tcp.no_delay", true, false, Setting.Scope.CLUSTER); @@ -149,7 +150,7 @@ public class NetworkService extends AbstractComponent { */ // TODO: needs to be InetAddress[] public InetAddress resolvePublishHostAddresses(String publishHosts[]) throws IOException { - if (publishHosts == null) { + if (publishHosts == null || publishHosts.length == 0) { if (GLOBAL_NETWORK_PUBLISHHOST_SETTING.exists(settings) || GLOBAL_NETWORK_HOST_SETTING.exists(settings)) { // if we have settings use them (we have a fallback to GLOBAL_NETWORK_HOST_SETTING inline publishHosts = GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); diff --git a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index 519fc259840..ea16c6aabd6 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; import org.elasticsearch.action.support.AutoCreateIndex; import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.master.TransportMasterNodeReadAction; +import org.elasticsearch.cache.recycler.PageCacheRecycler; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClientNodesService; import org.elasticsearch.cluster.ClusterModule; @@ -56,6 +57,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.gateway.PrimaryShardAllocator; +import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.http.netty.NettyHttpServerTransport; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.store.IndexStoreConfig; @@ -67,6 +69,11 @@ import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache; import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.indices.store.IndicesStore; import org.elasticsearch.indices.ttl.IndicesTTLService; +import org.elasticsearch.monitor.fs.FsService; +import org.elasticsearch.monitor.jvm.JvmGcMonitorService; +import org.elasticsearch.monitor.jvm.JvmService; +import org.elasticsearch.monitor.os.OsService; +import org.elasticsearch.monitor.process.ProcessService; import org.elasticsearch.node.Node; import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.repositories.fs.FsRepository; @@ -79,6 +86,7 @@ import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.transport.netty.NettyTransport; +import org.elasticsearch.tribe.TribeService; import java.util.Arrays; import java.util.Collections; @@ -106,9 +114,9 @@ public final class ClusterSettings extends AbstractScopedSettings { @Override public boolean hasChanged(Settings current, Settings previous) { return current.filter(loggerPredicate).getAsMap().equals(previous.filter(loggerPredicate).getAsMap()) == false; - } + } - @Override + @Override public Settings getValue(Settings current, Settings previous) { Settings.Builder builder = Settings.builder(); builder.put(current.filter(loggerPredicate).getAsMap()); @@ -124,7 +132,7 @@ public final class ClusterSettings extends AbstractScopedSettings { return builder.build(); } - @Override + @Override public void apply(Settings value, Settings current, Settings previous) { for (String key : value.getAsMap().keySet()) { assert loggerPredicate.test(key); @@ -135,91 +143,109 @@ public final class ClusterSettings extends AbstractScopedSettings { } else { ESLoggerFactory.getLogger(component).setLevel(value.get(key)); } - } - } + } + } }; public static Set> BUILT_IN_CLUSTER_SETTINGS = Collections.unmodifiableSet(new HashSet<>( Arrays.asList(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING, - TransportClientNodesService.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL, // TODO these transport client settings are kind of odd here and should only be valid if we are a transport client - TransportClientNodesService.CLIENT_TRANSPORT_PING_TIMEOUT, - TransportClientNodesService.CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME, - AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING, - BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, - BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING, - BalancedShardsAllocator.THRESHOLD_SETTING, - ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, - ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING, - EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING, - EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING, - ZenDiscovery.REJOIN_ON_MASTER_GONE_SETTING, - FilterAllocationDecider.CLUSTER_ROUTING_INCLUDE_GROUP_SETTING, - FilterAllocationDecider.CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING, - FilterAllocationDecider.CLUSTER_ROUTING_REQUIRE_GROUP_SETTING, - FsRepository.REPOSITORIES_CHUNK_SIZE_SETTING, - FsRepository.REPOSITORIES_COMPRESS_SETTING, - FsRepository.REPOSITORIES_LOCATION_SETTING, - IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_SETTING, - IndexStoreConfig.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, + TransportClientNodesService.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL, // TODO these transport client settings are kind of odd here and should only be valid if we are a transport client + TransportClientNodesService.CLIENT_TRANSPORT_PING_TIMEOUT, + TransportClientNodesService.CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME, + AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING, + BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING, + BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING, + BalancedShardsAllocator.THRESHOLD_SETTING, + ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING, + ConcurrentRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CLUSTER_CONCURRENT_REBALANCE_SETTING, + EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING, + EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING, + ZenDiscovery.REJOIN_ON_MASTER_GONE_SETTING, + FilterAllocationDecider.CLUSTER_ROUTING_INCLUDE_GROUP_SETTING, + FilterAllocationDecider.CLUSTER_ROUTING_EXCLUDE_GROUP_SETTING, + FilterAllocationDecider.CLUSTER_ROUTING_REQUIRE_GROUP_SETTING, + FsRepository.REPOSITORIES_CHUNK_SIZE_SETTING, + FsRepository.REPOSITORIES_COMPRESS_SETTING, + FsRepository.REPOSITORIES_LOCATION_SETTING, + IndexStoreConfig.INDICES_STORE_THROTTLE_TYPE_SETTING, + IndexStoreConfig.INDICES_STORE_THROTTLE_MAX_BYTES_PER_SEC_SETTING, IndicesQueryCache.INDICES_CACHE_QUERY_SIZE_SETTING, IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING, - IndicesTTLService.INDICES_TTL_INTERVAL_SETTING, - MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING, - MetaData.SETTING_READ_ONLY_SETTING, - RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING, - RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC_SETTING, - RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK_SETTING, - RecoverySettings.INDICES_RECOVERY_ACTIVITY_TIMEOUT_SETTING, - RecoverySettings.INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT_SETTING, - RecoverySettings.INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT_SETTING, - ThreadPool.THREADPOOL_GROUP_SETTING, - ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING, - ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING, - ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING, - ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING, - DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, - DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, - DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, - DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, - DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, - InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING, - InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, - SnapshotInProgressAllocationDecider.CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED_SETTING, - DestructiveOperations.REQUIRES_NAME_SETTING, - DiscoverySettings.PUBLISH_TIMEOUT_SETTING, - DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING, - DiscoverySettings.COMMIT_TIMEOUT_SETTING, - DiscoverySettings.NO_MASTER_BLOCK_SETTING, - GatewayService.EXPECTED_DATA_NODES_SETTING, - GatewayService.EXPECTED_MASTER_NODES_SETTING, - GatewayService.EXPECTED_NODES_SETTING, - GatewayService.RECOVER_AFTER_DATA_NODES_SETTING, - GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING, - GatewayService.RECOVER_AFTER_NODES_SETTING, - GatewayService.RECOVER_AFTER_TIME_SETTING, - NetworkModule.HTTP_ENABLED, - NettyHttpServerTransport.SETTING_CORS_ALLOW_CREDENTIALS, - NettyHttpServerTransport.SETTING_CORS_ENABLED, - NettyHttpServerTransport.SETTING_CORS_MAX_AGE, - NettyHttpServerTransport.SETTING_HTTP_DETAILED_ERRORS_ENABLED, - NettyHttpServerTransport.SETTING_PIPELINING, - HierarchyCircuitBreakerService.TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, - HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, - HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, - HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, - HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, - InternalClusterService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, - SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING, - ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING, - TransportService.TRACE_LOG_EXCLUDE_SETTING, - TransportService.TRACE_LOG_INCLUDE_SETTING, - TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING, - ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, - InternalClusterService.CLUSTER_SERVICE_RECONNECT_INTERVAL_SETTING, - HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING, - HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING, - Transport.TRANSPORT_TCP_COMPRESS, + IndicesTTLService.INDICES_TTL_INTERVAL_SETTING, + MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING, + MetaData.SETTING_READ_ONLY_SETTING, + RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING, + RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_STATE_SYNC_SETTING, + RecoverySettings.INDICES_RECOVERY_RETRY_DELAY_NETWORK_SETTING, + RecoverySettings.INDICES_RECOVERY_ACTIVITY_TIMEOUT_SETTING, + RecoverySettings.INDICES_RECOVERY_INTERNAL_ACTION_TIMEOUT_SETTING, + RecoverySettings.INDICES_RECOVERY_INTERNAL_LONG_ACTION_TIMEOUT_SETTING, + ThreadPool.THREADPOOL_GROUP_SETTING, + ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING, + ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING, + ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING, + ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING, + DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING, + DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING, + DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING, + DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING, + DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_REROUTE_INTERVAL_SETTING, + InternalClusterInfoService.INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING, + InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, + SnapshotInProgressAllocationDecider.CLUSTER_ROUTING_ALLOCATION_SNAPSHOT_RELOCATION_ENABLED_SETTING, + DestructiveOperations.REQUIRES_NAME_SETTING, + DiscoverySettings.PUBLISH_TIMEOUT_SETTING, + DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING, + DiscoverySettings.COMMIT_TIMEOUT_SETTING, + DiscoverySettings.NO_MASTER_BLOCK_SETTING, + GatewayService.EXPECTED_DATA_NODES_SETTING, + GatewayService.EXPECTED_MASTER_NODES_SETTING, + GatewayService.EXPECTED_NODES_SETTING, + GatewayService.RECOVER_AFTER_DATA_NODES_SETTING, + GatewayService.RECOVER_AFTER_MASTER_NODES_SETTING, + GatewayService.RECOVER_AFTER_NODES_SETTING, + GatewayService.RECOVER_AFTER_TIME_SETTING, + NetworkModule.HTTP_ENABLED, + HttpTransportSettings.SETTING_CORS_ALLOW_CREDENTIALS, + HttpTransportSettings.SETTING_CORS_ENABLED, + HttpTransportSettings.SETTING_CORS_MAX_AGE, + HttpTransportSettings.SETTING_HTTP_DETAILED_ERRORS_ENABLED, + HttpTransportSettings.SETTING_PIPELINING, + HttpTransportSettings.SETTING_CORS_ALLOW_ORIGIN, + HttpTransportSettings.SETTING_HTTP_PORT, + HttpTransportSettings.SETTING_HTTP_PUBLISH_PORT, + HttpTransportSettings.SETTING_PIPELINING_MAX_EVENTS, + HttpTransportSettings.SETTING_HTTP_COMPRESSION, + HttpTransportSettings.SETTING_HTTP_COMPRESSION_LEVEL, + HttpTransportSettings.SETTING_CORS_ALLOW_METHODS, + HttpTransportSettings.SETTING_CORS_ALLOW_HEADERS, + HttpTransportSettings.SETTING_HTTP_DETAILED_ERRORS_ENABLED, + HttpTransportSettings.SETTING_HTTP_MAX_CONTENT_LENGTH, + HttpTransportSettings.SETTING_HTTP_MAX_CHUNK_SIZE, + HttpTransportSettings.SETTING_HTTP_MAX_HEADER_SIZE, + HttpTransportSettings.SETTING_HTTP_MAX_INITIAL_LINE_LENGTH, + HttpTransportSettings.SETTING_HTTP_RESET_COOKIES, + HierarchyCircuitBreakerService.TOTAL_CIRCUIT_BREAKER_LIMIT_SETTING, + HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING, + HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING, + HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, + HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_OVERHEAD_SETTING, + InternalClusterService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING, + ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING, + TransportService.TRACE_LOG_EXCLUDE_SETTING, + TransportService.TRACE_LOG_INCLUDE_SETTING, + TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING, + ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, + InternalClusterService.CLUSTER_SERVICE_RECONNECT_INTERVAL_SETTING, + HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING, + HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING, + Transport.TRANSPORT_TCP_COMPRESS, TransportSettings.TRANSPORT_PROFILES_SETTING, + TransportSettings.HOST, + TransportSettings.PUBLISH_HOST, + TransportSettings.BIND_HOST, + TransportSettings.PUBLISH_PORT, TransportSettings.PORT, NettyTransport.WORKER_COUNT, NettyTransport.CONNECTIONS_PER_NODE_RECOVERY, @@ -235,74 +261,80 @@ public final class ClusterSettings extends AbstractScopedSettings { NettyTransport.NETTY_RECEIVE_PREDICTOR_SIZE, NettyTransport.NETTY_RECEIVE_PREDICTOR_MIN, NettyTransport.NETTY_RECEIVE_PREDICTOR_MAX, - NettyTransport.NETWORK_SERVER, + NetworkService.NETWORK_SERVER, NettyTransport.NETTY_BOSS_COUNT, - NetworkService.GLOBAL_NETWORK_HOST_SETTING, - NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING, - NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING, - NetworkService.TcpSettings.TCP_NO_DELAY, - NetworkService.TcpSettings.TCP_KEEP_ALIVE, - NetworkService.TcpSettings.TCP_REUSE_ADDRESS, - NetworkService.TcpSettings.TCP_SEND_BUFFER_SIZE, - NetworkService.TcpSettings.TCP_RECEIVE_BUFFER_SIZE, - NetworkService.TcpSettings.TCP_BLOCKING, - NetworkService.TcpSettings.TCP_BLOCKING_SERVER, - NetworkService.TcpSettings.TCP_BLOCKING_CLIENT, - NetworkService.TcpSettings.TCP_CONNECT_TIMEOUT, - IndexSettings.QUERY_STRING_ANALYZE_WILDCARD, - IndexSettings.QUERY_STRING_ALLOW_LEADING_WILDCARD, - PrimaryShardAllocator.NODE_INITIAL_SHARDS_SETTING, - ScriptService.SCRIPT_CACHE_SIZE_SETTING, - IndicesFieldDataCache.INDICES_FIELDDATA_CLEAN_INTERVAL_SETTING, - IndicesFieldDataCache.INDICES_FIELDDATA_CACHE_SIZE_KEY, - IndicesRequestCache.INDICES_CACHE_QUERY_SIZE, - IndicesRequestCache.INDICES_CACHE_QUERY_EXPIRE, + NettyTransport.TCP_NO_DELAY, + NettyTransport.TCP_KEEP_ALIVE, + NettyTransport.TCP_REUSE_ADDRESS, + NettyTransport.TCP_SEND_BUFFER_SIZE, + NettyTransport.TCP_RECEIVE_BUFFER_SIZE, + NettyTransport.TCP_BLOCKING_SERVER, + NetworkService.GLOBAL_NETWORK_HOST_SETTING, + NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING, + NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING, + NetworkService.TcpSettings.TCP_NO_DELAY, + NetworkService.TcpSettings.TCP_KEEP_ALIVE, + NetworkService.TcpSettings.TCP_REUSE_ADDRESS, + NetworkService.TcpSettings.TCP_SEND_BUFFER_SIZE, + NetworkService.TcpSettings.TCP_RECEIVE_BUFFER_SIZE, + NetworkService.TcpSettings.TCP_BLOCKING, + NetworkService.TcpSettings.TCP_BLOCKING_SERVER, + NetworkService.TcpSettings.TCP_BLOCKING_CLIENT, + NetworkService.TcpSettings.TCP_CONNECT_TIMEOUT, + IndexSettings.QUERY_STRING_ANALYZE_WILDCARD, + IndexSettings.QUERY_STRING_ALLOW_LEADING_WILDCARD, + PrimaryShardAllocator.NODE_INITIAL_SHARDS_SETTING, + ScriptService.SCRIPT_CACHE_SIZE_SETTING, + IndicesFieldDataCache.INDICES_FIELDDATA_CLEAN_INTERVAL_SETTING, + IndicesFieldDataCache.INDICES_FIELDDATA_CACHE_SIZE_KEY, + IndicesRequestCache.INDICES_CACHE_QUERY_SIZE, + IndicesRequestCache.INDICES_CACHE_QUERY_EXPIRE, IndicesRequestCache.INDICES_CACHE_REQUEST_CLEAN_INTERVAL, - HunspellService.HUNSPELL_LAZY_LOAD, - HunspellService.HUNSPELL_IGNORE_CASE, - HunspellService.HUNSPELL_DICTIONARY_OPTIONS, - IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT, - Environment.PATH_CONF_SETTING, - Environment.PATH_DATA_SETTING, - Environment.PATH_HOME_SETTING, - Environment.PATH_LOGS_SETTING, - Environment.PATH_PLUGINS_SETTING, - Environment.PATH_REPO_SETTING, - Environment.PATH_SCRIPTS_SETTING, - Environment.PATH_SHARED_DATA_SETTING, - Environment.PIDFILE_SETTING, - DiscoveryService.DISCOVERY_SEED_SETTING, - DiscoveryService.INITIAL_STATE_TIMEOUT_SETTING, - DiscoveryModule.DISCOVERY_TYPE_SETTING, - DiscoveryModule.ZEN_MASTER_SERVICE_TYPE_SETTING, - FaultDetection.PING_RETRIES_SETTING, - FaultDetection.PING_TIMEOUT_SETTING, - FaultDetection.REGISTER_CONNECTION_LISTENER_SETTING, - FaultDetection.PING_INTERVAL_SETTING, - FaultDetection.CONNECT_ON_NETWORK_DISCONNECT_SETTING, - ZenDiscovery.PING_TIMEOUT_SETTING, - ZenDiscovery.JOIN_TIMEOUT_SETTING, - ZenDiscovery.JOIN_RETRY_ATTEMPTS_SETTING, - ZenDiscovery.JOIN_RETRY_DELAY_SETTING, - ZenDiscovery.MAX_PINGS_FROM_ANOTHER_MASTER_SETTING, - ZenDiscovery.SEND_LEAVE_REQUEST_SETTING, - ZenDiscovery.MASTER_ELECTION_FILTER_CLIENT_SETTING, - ZenDiscovery.MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING, - ZenDiscovery.MASTER_ELECTION_FILTER_DATA_SETTING, - UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, - UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING, - SearchService.DEFAULT_KEEPALIVE_SETTING, - SearchService.KEEPALIVE_INTERVAL_SETTING, - Node.WRITE_PORTS_FIELD_SETTING, + HunspellService.HUNSPELL_LAZY_LOAD, + HunspellService.HUNSPELL_IGNORE_CASE, + HunspellService.HUNSPELL_DICTIONARY_OPTIONS, + IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT, + Environment.PATH_CONF_SETTING, + Environment.PATH_DATA_SETTING, + Environment.PATH_HOME_SETTING, + Environment.PATH_LOGS_SETTING, + Environment.PATH_PLUGINS_SETTING, + Environment.PATH_REPO_SETTING, + Environment.PATH_SCRIPTS_SETTING, + Environment.PATH_SHARED_DATA_SETTING, + Environment.PIDFILE_SETTING, + DiscoveryService.DISCOVERY_SEED_SETTING, + DiscoveryService.INITIAL_STATE_TIMEOUT_SETTING, + DiscoveryModule.DISCOVERY_TYPE_SETTING, + DiscoveryModule.ZEN_MASTER_SERVICE_TYPE_SETTING, + FaultDetection.PING_RETRIES_SETTING, + FaultDetection.PING_TIMEOUT_SETTING, + FaultDetection.REGISTER_CONNECTION_LISTENER_SETTING, + FaultDetection.PING_INTERVAL_SETTING, + FaultDetection.CONNECT_ON_NETWORK_DISCONNECT_SETTING, + ZenDiscovery.PING_TIMEOUT_SETTING, + ZenDiscovery.JOIN_TIMEOUT_SETTING, + ZenDiscovery.JOIN_RETRY_ATTEMPTS_SETTING, + ZenDiscovery.JOIN_RETRY_DELAY_SETTING, + ZenDiscovery.MAX_PINGS_FROM_ANOTHER_MASTER_SETTING, + ZenDiscovery.SEND_LEAVE_REQUEST_SETTING, + ZenDiscovery.MASTER_ELECTION_FILTER_CLIENT_SETTING, + ZenDiscovery.MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING, + ZenDiscovery.MASTER_ELECTION_FILTER_DATA_SETTING, + UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, + UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING, + SearchService.DEFAULT_KEEPALIVE_SETTING, + SearchService.KEEPALIVE_INTERVAL_SETTING, + Node.WRITE_PORTS_FIELD_SETTING, Node.NODE_CLIENT_SETTING, Node.NODE_DATA_SETTING, Node.NODE_MASTER_SETTING, Node.NODE_LOCAL_SETTING, Node.NODE_MODE_SETTING, Node.NODE_INGEST_SETTING, - URLRepository.ALLOWED_URLS_SETTING, - URLRepository.REPOSITORIES_LIST_DIRECTORIES_SETTING, - URLRepository.REPOSITORIES_URL_SETTING, + URLRepository.ALLOWED_URLS_SETTING, + URLRepository.REPOSITORIES_LIST_DIRECTORIES_SETTING, + URLRepository.REPOSITORIES_URL_SETTING, URLRepository.SUPPORTED_PROTOCOLS_SETTING, TransportMasterNodeReadAction.FORCE_LOCAL_SETTING, AutoCreateIndex.AUTO_CREATE_INDEX_SETTING, @@ -315,7 +347,27 @@ public final class ClusterSettings extends AbstractScopedSettings { ThreadContext.DEFAULT_HEADERS_SETTING, ESLoggerFactory.LOG_DEFAULT_LEVEL_SETTING, ESLoggerFactory.LOG_LEVEL_SETTING, + TribeService.BLOCKS_METADATA_SETTING, + TribeService.BLOCKS_WRITE_SETTING, + TribeService.BLOCKS_WRITE_INDICES_SETTING, + TribeService.BLOCKS_READ_INDICES_SETTING, + TribeService.BLOCKS_METADATA_INDICES_SETTING, + TribeService.ON_CONFLICT_SETTING, NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING, NodeEnvironment.ENABLE_LUCENE_SEGMENT_INFOS_TRACE_SETTING, - NodeEnvironment.ADD_NODE_ID_TO_CUSTOM_PATH))); + NodeEnvironment.ADD_NODE_ID_TO_CUSTOM_PATH, + OsService.REFRESH_INTERVAL_SETTING, + ProcessService.REFRESH_INTERVAL_SETTING, + JvmService.REFRESH_INTERVAL_SETTING, + FsService.REFRESH_INTERVAL_SETTING, + JvmGcMonitorService.ENABLED_SETTING, + JvmGcMonitorService.REFRESH_INTERVAL_SETTING, + JvmGcMonitorService.GC_SETTING, + PageCacheRecycler.LIMIT_HEAP_SETTING, + PageCacheRecycler.WEIGHT_BYTES_SETTING, + PageCacheRecycler.WEIGHT_INT_SETTING, + PageCacheRecycler.WEIGHT_LONG_SETTING, + PageCacheRecycler.WEIGHT_OBJECTS_SETTING, + PageCacheRecycler.TYPE_SETTING + ))); } diff --git a/core/src/main/java/org/elasticsearch/common/settings/Settings.java b/core/src/main/java/org/elasticsearch/common/settings/Settings.java index 601ec7a4bf6..8be01a624cd 100644 --- a/core/src/main/java/org/elasticsearch/common/settings/Settings.java +++ b/core/src/main/java/org/elasticsearch/common/settings/Settings.java @@ -939,6 +939,14 @@ public final class Settings implements ToXContent { return this; } + /** + * Sets the setting with the provided setting key and an array of values. + * + * @param setting The setting key + * @param values The values + * @return The builder + */ + /** * Sets the setting with the provided setting key and an array of values. * @@ -947,6 +955,17 @@ public final class Settings implements ToXContent { * @return The builder */ public Builder putArray(String setting, String... values) { + return putArray(setting, Arrays.asList(values)); + } + + /** + * Sets the setting with the provided setting key and a list of values. + * + * @param setting The setting key + * @param values The values + * @return The builder + */ + public Builder putArray(String setting, List values) { remove(setting); int counter = 0; while (true) { @@ -955,8 +974,8 @@ public final class Settings implements ToXContent { break; } } - for (int i = 0; i < values.length; i++) { - put(setting + "." + i, values[i]); + for (int i = 0; i < values.size(); i++) { + put(setting + "." + i, values.get(i)); } return this; } diff --git a/core/src/main/java/org/elasticsearch/common/transport/PortsRange.java b/core/src/main/java/org/elasticsearch/common/transport/PortsRange.java index e1e4571eda4..4f5a3966d43 100644 --- a/core/src/main/java/org/elasticsearch/common/transport/PortsRange.java +++ b/core/src/main/java/org/elasticsearch/common/transport/PortsRange.java @@ -35,6 +35,10 @@ public class PortsRange { this.portRange = portRange; } + public String getPortRangeString() { + return portRange; + } + public int[] ports() throws NumberFormatException { final IntArrayList ports = new IntArrayList(); iterate(new PortCallback() { diff --git a/core/src/main/java/org/elasticsearch/discovery/DiscoveryService.java b/core/src/main/java/org/elasticsearch/discovery/DiscoveryService.java index 22f68a738c7..bef1c8fe5ec 100644 --- a/core/src/main/java/org/elasticsearch/discovery/DiscoveryService.java +++ b/core/src/main/java/org/elasticsearch/discovery/DiscoveryService.java @@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit; public class DiscoveryService extends AbstractLifecycleComponent { public static final Setting INITIAL_STATE_TIMEOUT_SETTING = Setting.positiveTimeSetting("discovery.initial_state_timeout", TimeValue.timeValueSeconds(30), false, Setting.Scope.CLUSTER); - public static final Setting DISCOVERY_SEED_SETTING = Setting.longSetting("discovery.id.seed", 0l, Long.MIN_VALUE, false, Setting.Scope.CLUSTER); + public static final Setting DISCOVERY_SEED_SETTING = Setting.longSetting("discovery.id.seed", 0L, Long.MIN_VALUE, false, Setting.Scope.CLUSTER); private static class InitialStateListener implements InitialStateDiscoveryListener { diff --git a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java index 4a3771c8e5a..03a14fe9cf8 100644 --- a/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/local/LocalDiscovery.java @@ -19,7 +19,6 @@ package org.elasticsearch.discovery.local; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterService; @@ -29,7 +28,6 @@ import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.IncompatibleClusterStateVersionException; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.cluster.node.DiscoveryNodeService; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.routing.RoutingService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; @@ -44,12 +42,10 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.discovery.AckClusterStatePublishResponseHandler; import org.elasticsearch.discovery.BlockingClusterStatePublishResponseHandler; import org.elasticsearch.discovery.Discovery; -import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.discovery.DiscoverySettings; import org.elasticsearch.discovery.DiscoveryStats; import org.elasticsearch.discovery.InitialStateDiscoveryListener; import org.elasticsearch.node.service.NodeService; -import org.elasticsearch.transport.TransportService; import java.util.HashSet; import java.util.Queue; @@ -67,17 +63,12 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem private static final LocalDiscovery[] NO_MEMBERS = new LocalDiscovery[0]; - private final TransportService transportService; private final ClusterService clusterService; - private final DiscoveryNodeService discoveryNodeService; private RoutingService routingService; private final ClusterName clusterName; - private final Version version; private final DiscoverySettings discoverySettings; - private DiscoveryNode localNode; - private volatile boolean master = false; private final AtomicBoolean initialStateSent = new AtomicBoolean(); @@ -89,14 +80,11 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem private volatile ClusterState lastProcessedClusterState; @Inject - public LocalDiscovery(Settings settings, ClusterName clusterName, TransportService transportService, ClusterService clusterService, - DiscoveryNodeService discoveryNodeService, Version version, DiscoverySettings discoverySettings) { + public LocalDiscovery(Settings settings, ClusterName clusterName, ClusterService clusterService, + DiscoverySettings discoverySettings) { super(settings); this.clusterName = clusterName; this.clusterService = clusterService; - this.transportService = transportService; - this.discoveryNodeService = discoveryNodeService; - this.version = version; this.discoverySettings = discoverySettings; } @@ -119,8 +107,6 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem clusterGroups.put(clusterName, clusterGroup); } logger.debug("Connected to cluster [{}]", clusterName); - this.localNode = new DiscoveryNode(settings.get("name"), DiscoveryService.generateNodeId(settings), transportService.boundAddress().publishAddress(), - discoveryNodeService.buildAttributes(), version); clusterGroup.members().add(this); @@ -147,7 +133,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(); for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) { - nodesBuilder.put(discovery.localNode); + nodesBuilder.put(discovery.localNode()); } nodesBuilder.localNodeId(master.localNode().id()).masterNodeId(master.localNode().id()); // remove the NO_MASTER block in this case @@ -166,30 +152,9 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem } }); } else if (firstMaster != null) { - // update as fast as we can the local node state with the new metadata (so we create indices for example) - final ClusterState masterState = firstMaster.clusterService.state(); - clusterService.submitStateUpdateTask("local-disco(detected_master)", new ClusterStateUpdateTask() { - @Override - public boolean runOnlyOnMaster() { - return false; - } - - @Override - public ClusterState execute(ClusterState currentState) { - // make sure we have the local node id set, we might need it as a result of the new metadata - DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentState.nodes()).put(localNode).localNodeId(localNode.id()); - return ClusterState.builder(currentState).metaData(masterState.metaData()).nodes(nodesBuilder).build(); - } - - @Override - public void onFailure(String source, Throwable t) { - logger.error("unexpected failure during [{}]", t, source); - } - }); - // tell the master to send the fact that we are here final LocalDiscovery master = firstMaster; - firstMaster.clusterService.submitStateUpdateTask("local-disco-receive(from node[" + localNode + "])", new ClusterStateUpdateTask() { + firstMaster.clusterService.submitStateUpdateTask("local-disco-receive(from node[" + localNode() + "])", new ClusterStateUpdateTask() { @Override public boolean runOnlyOnMaster() { return false; @@ -199,7 +164,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem public ClusterState execute(ClusterState currentState) { DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(); for (LocalDiscovery discovery : clusterGroups.get(clusterName).members()) { - nodesBuilder.put(discovery.localNode); + nodesBuilder.put(discovery.localNode()); } nodesBuilder.localNodeId(master.localNode().id()).masterNodeId(master.localNode().id()); return ClusterState.builder(currentState).nodes(nodesBuilder).build(); @@ -254,7 +219,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem final Set newMembers = new HashSet<>(); for (LocalDiscovery discovery : clusterGroup.members()) { - newMembers.add(discovery.localNode.id()); + newMembers.add(discovery.localNode().id()); } final LocalDiscovery master = firstMaster; @@ -266,7 +231,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem @Override public ClusterState execute(ClusterState currentState) { - DiscoveryNodes newNodes = currentState.nodes().removeDeadMembers(newMembers, master.localNode.id()); + DiscoveryNodes newNodes = currentState.nodes().removeDeadMembers(newMembers, master.localNode().id()); DiscoveryNodes.Delta delta = newNodes.delta(currentState.nodes()); if (delta.added()) { logger.warn("No new nodes should be created when a new discovery view is accepted"); @@ -293,7 +258,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem @Override public DiscoveryNode localNode() { - return localNode; + return clusterService.localNode(); } @Override @@ -308,7 +273,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem @Override public String nodeDescription() { - return clusterName.value() + "/" + localNode.id(); + return clusterName.value() + "/" + localNode().id(); } @Override @@ -323,7 +288,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem if (localDiscovery.master) { continue; } - nodesToPublishTo.add(localDiscovery.localNode); + nodesToPublishTo.add(localDiscovery.localNode()); } publish(members, clusterChangedEvent, new AckClusterStatePublishResponseHandler(nodesToPublishTo, ackListener)); } @@ -359,7 +324,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem synchronized (this) { // we do the marshaling intentionally, to check it works well... // check if we publsihed cluster state at least once and node was in the cluster when we published cluster state the last time - if (discovery.lastProcessedClusterState != null && clusterChangedEvent.previousState().nodes().nodeExists(discovery.localNode.id())) { + if (discovery.lastProcessedClusterState != null && clusterChangedEvent.previousState().nodes().nodeExists(discovery.localNode().id())) { // both conditions are true - which means we can try sending cluster state as diffs if (clusterStateDiffBytes == null) { Diff diff = clusterState.diff(clusterChangedEvent.previousState()); @@ -369,7 +334,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem } try { newNodeSpecificClusterState = discovery.lastProcessedClusterState.readDiffFrom(StreamInput.wrap(clusterStateDiffBytes)).apply(discovery.lastProcessedClusterState); - logger.trace("sending diff cluster state version [{}] with size {} to [{}]", clusterState.version(), clusterStateDiffBytes.length, discovery.localNode.getName()); + logger.trace("sending diff cluster state version [{}] with size {} to [{}]", clusterState.version(), clusterStateDiffBytes.length, discovery.localNode().getName()); } catch (IncompatibleClusterStateVersionException ex) { logger.warn("incompatible cluster state version [{}] - resending complete cluster state", ex, clusterState.version()); } @@ -378,7 +343,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem if (clusterStateBytes == null) { clusterStateBytes = Builder.toBytes(clusterState); } - newNodeSpecificClusterState = ClusterState.Builder.fromBytes(clusterStateBytes, discovery.localNode); + newNodeSpecificClusterState = ClusterState.Builder.fromBytes(clusterStateBytes, discovery.localNode()); } discovery.lastProcessedClusterState = newNodeSpecificClusterState; } @@ -423,17 +388,17 @@ public class LocalDiscovery extends AbstractLifecycleComponent implem @Override public void onFailure(String source, Throwable t) { logger.error("unexpected failure during [{}]", t, source); - publishResponseHandler.onFailure(discovery.localNode, t); + publishResponseHandler.onFailure(discovery.localNode(), t); } @Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { sendInitialStateEventIfNeeded(); - publishResponseHandler.onResponse(discovery.localNode); + publishResponseHandler.onResponse(discovery.localNode()); } }); } else { - publishResponseHandler.onResponse(discovery.localNode); + publishResponseHandler.onResponse(discovery.localNode()); } } diff --git a/core/src/main/java/org/elasticsearch/gateway/PriorityComparator.java b/core/src/main/java/org/elasticsearch/gateway/PriorityComparator.java index c491b804069..04f438c70fe 100644 --- a/core/src/main/java/org/elasticsearch/gateway/PriorityComparator.java +++ b/core/src/main/java/org/elasticsearch/gateway/PriorityComparator.java @@ -60,7 +60,7 @@ public abstract class PriorityComparator implements Comparator { } private long timeCreated(Settings settings) { - return settings.getAsLong(IndexMetaData.SETTING_CREATION_DATE, -1l); + return settings.getAsLong(IndexMetaData.SETTING_CREATION_DATE, -1L); } protected abstract Settings getIndexSettings(String index); diff --git a/core/src/main/java/org/elasticsearch/http/HttpTransportSettings.java b/core/src/main/java/org/elasticsearch/http/HttpTransportSettings.java new file mode 100644 index 00000000000..c5a1844f7ff --- /dev/null +++ b/core/src/main/java/org/elasticsearch/http/HttpTransportSettings.java @@ -0,0 +1,53 @@ +/* + * 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.http; + +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Setting.Scope; +import org.elasticsearch.common.transport.PortsRange; +import org.elasticsearch.common.unit.ByteSizeUnit; +import org.elasticsearch.common.unit.ByteSizeValue; + +public final class HttpTransportSettings { + + public static final Setting SETTING_CORS_ENABLED = Setting.boolSetting("http.cors.enabled", false, false, Scope.CLUSTER); + public static final Setting SETTING_CORS_ALLOW_ORIGIN = new Setting("http.cors.allow-origin", "", (value) -> value, false, Scope.CLUSTER); + public static final Setting SETTING_CORS_MAX_AGE = Setting.intSetting("http.cors.max-age", 1728000, false, Scope.CLUSTER); + public static final Setting SETTING_CORS_ALLOW_METHODS = new Setting("http.cors.allow-methods", "OPTIONS, HEAD, GET, POST, PUT, DELETE", (value) -> value, false, Scope.CLUSTER); + public static final Setting SETTING_CORS_ALLOW_HEADERS = new Setting("http.cors.allow-headers", "X-Requested-With, Content-Type, Content-Length", (value) -> value, false, Scope.CLUSTER); + public static final Setting SETTING_CORS_ALLOW_CREDENTIALS = Setting.boolSetting("http.cors.allow-credentials", false, false, Scope.CLUSTER); + public static final Setting SETTING_PIPELINING = Setting.boolSetting("http.pipelining", true, false, Scope.CLUSTER); + public static final Setting SETTING_PIPELINING_MAX_EVENTS = Setting.intSetting("http.pipelining.max_events", 10000, false, Scope.CLUSTER); + public static final Setting SETTING_HTTP_COMPRESSION = Setting.boolSetting("http.compression", false, false, Scope.CLUSTER); + public static final Setting SETTING_HTTP_COMPRESSION_LEVEL = Setting.intSetting("http.compression_level", 6, false, Scope.CLUSTER); + public static final Setting SETTING_HTTP_PORT = new Setting("http.port", "9200-9300", PortsRange::new, false, Scope.CLUSTER); + public static final Setting SETTING_HTTP_PUBLISH_PORT = Setting.intSetting("http.publish_port", 0, 0, false, Scope.CLUSTER); + public static final Setting SETTING_HTTP_DETAILED_ERRORS_ENABLED = Setting.boolSetting("http.detailed_errors.enabled", true, false, Scope.CLUSTER); + public static final Setting SETTING_HTTP_MAX_CONTENT_LENGTH = Setting.byteSizeSetting("http.max_content_length", new ByteSizeValue(100, ByteSizeUnit.MB), false, Scope.CLUSTER) ; + public static final Setting SETTING_HTTP_MAX_CHUNK_SIZE = Setting.byteSizeSetting("http.max_chunk_size", new ByteSizeValue(8, ByteSizeUnit.KB), false, Scope.CLUSTER) ; + public static final Setting SETTING_HTTP_MAX_HEADER_SIZE = Setting.byteSizeSetting("http.max_header_size", new ByteSizeValue(8, ByteSizeUnit.KB), false, Scope.CLUSTER) ; + public static final Setting SETTING_HTTP_MAX_INITIAL_LINE_LENGTH = Setting.byteSizeSetting("http.max_initial_line_length", new ByteSizeValue(4, ByteSizeUnit.KB), false, Scope.CLUSTER) ; + // don't reset cookies by default, since I don't think we really need to + // note, parsing cookies was fixed in netty 3.5.1 regarding stack allocation, but still, currently, we don't need cookies + public static final Setting SETTING_HTTP_RESET_COOKIES = Setting.boolSetting("http.reset_cookies", false, false, Scope.CLUSTER); + + private HttpTransportSettings() { + } +} diff --git a/core/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java b/core/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java index 71d63d8d1dc..17e14fe83f1 100644 --- a/core/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java +++ b/core/src/main/java/org/elasticsearch/http/netty/HttpRequestHandler.java @@ -20,6 +20,7 @@ package org.elasticsearch.http.netty; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.http.netty.pipelining.OrderedUpstreamMessageEvent; import org.elasticsearch.rest.support.RestUtils; import org.jboss.netty.channel.ChannelHandler; @@ -46,7 +47,8 @@ public class HttpRequestHandler extends SimpleChannelUpstreamHandler { public HttpRequestHandler(NettyHttpServerTransport serverTransport, boolean detailedErrorsEnabled, ThreadContext threadContext) { this.serverTransport = serverTransport; - this.corsPattern = RestUtils.checkCorsSettingForRegex(serverTransport.settings().get(NettyHttpServerTransport.SETTING_CORS_ALLOW_ORIGIN)); + this.corsPattern = RestUtils + .checkCorsSettingForRegex(HttpTransportSettings.SETTING_CORS_ALLOW_ORIGIN.get(serverTransport.settings())); this.httpPipeliningEnabled = serverTransport.pipelining; this.detailedErrorsEnabled = detailedErrorsEnabled; this.threadContext = threadContext; diff --git a/core/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java b/core/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java index 316799dd062..1d3a2966e34 100644 --- a/core/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java +++ b/core/src/main/java/org/elasticsearch/http/netty/NettyHttpChannel.java @@ -49,12 +49,12 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_CREDENTIALS; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_HEADERS; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_METHODS; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_ORIGIN; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ENABLED; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_MAX_AGE; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ALLOW_CREDENTIALS; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ALLOW_HEADERS; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ALLOW_METHODS; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ALLOW_ORIGIN; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ENABLED; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_MAX_AGE; import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS; import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS; import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS; @@ -117,7 +117,7 @@ public class NettyHttpChannel extends HttpChannel { String originHeader = request.header(ORIGIN); if (!Strings.isNullOrEmpty(originHeader)) { if (corsPattern == null) { - String allowedOrigins = transport.settings().get(SETTING_CORS_ALLOW_ORIGIN, null); + String allowedOrigins = SETTING_CORS_ALLOW_ORIGIN.get(transport.settings()); if (!Strings.isNullOrEmpty(allowedOrigins)) { resp.headers().add(ACCESS_CONTROL_ALLOW_ORIGIN, allowedOrigins); } @@ -128,8 +128,8 @@ public class NettyHttpChannel extends HttpChannel { if (nettyRequest.getMethod() == HttpMethod.OPTIONS) { // Allow Ajax requests based on the CORS "preflight" request resp.headers().add(ACCESS_CONTROL_MAX_AGE, SETTING_CORS_MAX_AGE.get(transport.settings())); - resp.headers().add(ACCESS_CONTROL_ALLOW_METHODS, transport.settings().get(SETTING_CORS_ALLOW_METHODS, "OPTIONS, HEAD, GET, POST, PUT, DELETE")); - resp.headers().add(ACCESS_CONTROL_ALLOW_HEADERS, transport.settings().get(SETTING_CORS_ALLOW_HEADERS, "X-Requested-With, Content-Type, Content-Length")); + resp.headers().add(ACCESS_CONTROL_ALLOW_METHODS, SETTING_CORS_ALLOW_METHODS.get(transport.settings())); + resp.headers().add(ACCESS_CONTROL_ALLOW_HEADERS, SETTING_CORS_ALLOW_HEADERS.get(transport.settings())); } if (SETTING_CORS_ALLOW_CREDENTIALS.get(transport.settings())) { diff --git a/core/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java b/core/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java index 00b3c0f8afa..83e6823f6f0 100644 --- a/core/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java +++ b/core/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java @@ -26,8 +26,6 @@ import org.elasticsearch.common.netty.NettyUtils; import org.elasticsearch.common.netty.OpenChannelsHandler; import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.common.network.NetworkService; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Setting.Scope; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.InetSocketTransportAddress; @@ -46,6 +44,7 @@ import org.elasticsearch.http.HttpRequest; import org.elasticsearch.http.HttpServerAdapter; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.http.HttpStats; +import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.http.netty.pipelining.HttpPipeliningHandler; import org.elasticsearch.monitor.jvm.JvmInfo; import org.elasticsearch.threadpool.ThreadPool; @@ -75,7 +74,6 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicReference; - import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_BLOCKING; import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_KEEP_ALIVE; import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_NO_DELAY; @@ -93,22 +91,6 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent SETTING_CORS_ENABLED = Setting.boolSetting("http.cors.enabled", false, false, Scope.CLUSTER); - public static final String SETTING_CORS_ALLOW_ORIGIN = "http.cors.allow-origin"; - public static final Setting SETTING_CORS_MAX_AGE = Setting.intSetting("http.cors.max-age", 1728000, false, Scope.CLUSTER); - public static final String SETTING_CORS_ALLOW_METHODS = "http.cors.allow-methods"; - public static final String SETTING_CORS_ALLOW_HEADERS = "http.cors.allow-headers"; - public static final Setting SETTING_CORS_ALLOW_CREDENTIALS = Setting.boolSetting("http.cors.allow-credentials", false, false, Scope.CLUSTER); - - public static final Setting SETTING_PIPELINING = Setting.boolSetting("http.pipelining", true, false, Scope.CLUSTER); - public static final String SETTING_PIPELINING_MAX_EVENTS = "http.pipelining.max_events"; - public static final String SETTING_HTTP_COMPRESSION = "http.compression"; - public static final String SETTING_HTTP_COMPRESSION_LEVEL = "http.compression_level"; - public static final Setting SETTING_HTTP_DETAILED_ERRORS_ENABLED = Setting.boolSetting("http.detailed_errors.enabled", true, false, Scope.CLUSTER); - - public static final int DEFAULT_SETTING_PIPELINING_MAX_EVENTS = 10000; - public static final String DEFAULT_PORT_RANGE = "9200-9300"; - protected final NetworkService networkService; protected final BigArrays bigArrays; @@ -131,7 +113,7 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent 0) { @@ -215,10 +194,10 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent Integer.MAX_VALUE) { @@ -312,10 +291,9 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent lastException = new AtomicReference<>(); final AtomicReference boundSocket = new AtomicReference<>(); - boolean success = portsRange.iterate(new PortsRange.PortCallback() { + boolean success = port.iterate(new PortsRange.PortCallback() { @Override public boolean onPortNumber(int portNumber) { try { diff --git a/core/src/main/java/org/elasticsearch/index/IndexService.java b/core/src/main/java/org/elasticsearch/index/IndexService.java index 4c91fe7b568..8c87b2b5606 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexService.java +++ b/core/src/main/java/org/elasticsearch/index/IndexService.java @@ -456,7 +456,7 @@ public final class IndexService extends AbstractIndexComponent implements IndexC if (shardId != null) { final IndexShard shard = indexService.getShardOrNull(shardId.id()); if (shard != null) { - long ramBytesUsed = accountable != null ? accountable.ramBytesUsed() : 0l; + long ramBytesUsed = accountable != null ? accountable.ramBytesUsed() : 0L; shard.shardBitsetFilterCache().onCached(ramBytesUsed); } } @@ -467,7 +467,7 @@ public final class IndexService extends AbstractIndexComponent implements IndexC if (shardId != null) { final IndexShard shard = indexService.getShardOrNull(shardId.id()); if (shard != null) { - long ramBytesUsed = accountable != null ? accountable.ramBytesUsed() : 0l; + long ramBytesUsed = accountable != null ? accountable.ramBytesUsed() : 0L; shard.shardBitsetFilterCache().onRemoval(ramBytesUsed); } } diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java b/core/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java index da120657806..9e0d0fcc40d 100644 --- a/core/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java +++ b/core/src/main/java/org/elasticsearch/index/fielddata/ScriptDocValues.java @@ -121,7 +121,7 @@ public interface ScriptDocValues extends List { public long getValue() { int numValues = values.count(); if (numValues == 0) { - return 0l; + return 0L; } return values.valueAt(0); } 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 8b754b8bc29..b25f5f6a02d 100755 --- a/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -81,7 +81,7 @@ public class MapperService extends AbstractIndexComponent implements Closeable { } public static final String DEFAULT_MAPPING = "_default_"; - public static final Setting INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING = Setting.longSetting("index.mapping.nested_fields.limit", 50l, 0, true, Setting.Scope.INDEX); + public static final Setting INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING = Setting.longSetting("index.mapping.nested_fields.limit", 50L, 0, true, Setting.Scope.INDEX); public static final boolean INDEX_MAPPER_DYNAMIC_DEFAULT = true; public static final Setting INDEX_MAPPER_DYNAMIC_SETTING = Setting.boolSetting("index.mapper.dynamic", INDEX_MAPPER_DYNAMIC_DEFAULT, false, Setting.Scope.INDEX); private static ObjectHashSet META_FIELDS = ObjectHashSet.from( diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java index c83428d2239..fc9660d5c1d 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java @@ -66,7 +66,7 @@ import static org.elasticsearch.index.mapper.core.TypeParsers.parseNumberField; public class IpFieldMapper extends NumberFieldMapper { public static final String CONTENT_TYPE = "ip"; - public static final long MAX_IP = 4294967296l; + public static final long MAX_IP = 4294967296L; public static String longToIp(long longIp) { int octet3 = (int) ((longIp >> 24) % 256); diff --git a/core/src/main/java/org/elasticsearch/index/store/Store.java b/core/src/main/java/org/elasticsearch/index/store/Store.java index ec643154fed..c7377a4ab6b 100644 --- a/core/src/main/java/org/elasticsearch/index/store/Store.java +++ b/core/src/main/java/org/elasticsearch/index/store/Store.java @@ -930,7 +930,7 @@ public class Store extends AbstractIndexShardComponent implements Closeable, Ref return new Tuple<>(indexInput.readStringStringMap(), lastFound); } } - return new Tuple<>(new HashMap<>(), -1l); + return new Tuple<>(new HashMap<>(), -1L); } } diff --git a/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java b/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java index 06d4c219208..144f8b7f775 100644 --- a/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java +++ b/core/src/main/java/org/elasticsearch/indices/fielddata/cache/IndicesFieldDataCache.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.cache.RemovalListener; import org.elasticsearch.common.cache.RemovalNotification; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader; import org.elasticsearch.common.settings.Setting; @@ -52,7 +53,7 @@ import java.util.function.ToLongBiFunction; /** */ -public class IndicesFieldDataCache extends AbstractComponent implements RemovalListener { +public class IndicesFieldDataCache extends AbstractComponent implements RemovalListener, Releasable{ public static final Setting INDICES_FIELDDATA_CLEAN_INTERVAL_SETTING = Setting.positiveTimeSetting("indices.fielddata.cache.cleanup_interval", TimeValue.timeValueMinutes(1), false, Setting.Scope.CLUSTER); public static final Setting INDICES_FIELDDATA_CACHE_SIZE_KEY = Setting.byteSizeSetting("indices.fielddata.cache.size", new ByteSizeValue(-1), false, Setting.Scope.CLUSTER); @@ -84,6 +85,7 @@ public class IndicesFieldDataCache extends AbstractComponent implements RemovalL new FieldDataCacheCleaner(this.cache, this.logger, this.threadPool, this.cleanInterval)); } + @Override public void close() { cache.invalidateAll(); this.closed = true; diff --git a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java index ec390d3b23e..8cbdfca0221 100644 --- a/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java +++ b/core/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java @@ -252,60 +252,58 @@ public class RecoverySourceHandler { final AtomicLong bytesSinceLastPause = new AtomicLong(); final Function outputStreamFactories = (md) -> new BufferedOutputStream(new RecoveryOutputStream(md, bytesSinceLastPause, translogView), chunkSizeInBytes); sendFiles(store, phase1Files.toArray(new StoreFileMetaData[phase1Files.size()]), outputStreamFactories); - cancellableThreads.execute(() -> { - // Send the CLEAN_FILES request, which takes all of the files that - // were transferred and renames them from their temporary file - // names to the actual file names. It also writes checksums for - // the files after they have been renamed. - // - // Once the files have been renamed, any other files that are not - // related to this recovery (out of date segments, for example) - // are deleted - try { + // Send the CLEAN_FILES request, which takes all of the files that + // were transferred and renames them from their temporary file + // names to the actual file names. It also writes checksums for + // the files after they have been renamed. + // + // Once the files have been renamed, any other files that are not + // related to this recovery (out of date segments, for example) + // are deleted + try { + cancellableThreads.execute(() -> { transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.CLEAN_FILES, - new RecoveryCleanFilesRequest(request.recoveryId(), shard.shardId(), recoverySourceMetadata, translogView.totalOperations()), - TransportRequestOptions.builder().withTimeout(recoverySettings.internalActionTimeout()).build(), - EmptyTransportResponseHandler.INSTANCE_SAME).txGet(); - } catch (RemoteTransportException remoteException) { - final IOException corruptIndexException; - // we realized that after the index was copied and we wanted to finalize the recovery - // the index was corrupted: - // - maybe due to a broken segments file on an empty index (transferred with no checksum) - // - maybe due to old segments without checksums or length only checks - if ((corruptIndexException = ExceptionsHelper.unwrapCorruption(remoteException)) != null) { - try { - final Store.MetadataSnapshot recoverySourceMetadata1 = store.getMetadata(snapshot); - StoreFileMetaData[] metadata = - StreamSupport.stream(recoverySourceMetadata1.spliterator(), false).toArray(size -> new StoreFileMetaData[size]); - ArrayUtil.timSort(metadata, new Comparator() { - @Override - public int compare(StoreFileMetaData o1, StoreFileMetaData o2) { - return Long.compare(o1.length(), o2.length()); // check small files first - } - }); - for (StoreFileMetaData md : metadata) { - logger.debug("{} checking integrity for file {} after remove corruption exception", shard.shardId(), md); - if (store.checkIntegrityNoException(md) == false) { // we are corrupted on the primary -- fail! - shard.failShard("recovery", corruptIndexException); - logger.warn("{} Corrupted file detected {} checksum mismatch", shard.shardId(), md); - throw corruptIndexException; - } + new RecoveryCleanFilesRequest(request.recoveryId(), shard.shardId(), recoverySourceMetadata, translogView.totalOperations()), + TransportRequestOptions.builder().withTimeout(recoverySettings.internalActionTimeout()).build(), + EmptyTransportResponseHandler.INSTANCE_SAME).txGet(); + }); + } catch (RemoteTransportException remoteException) { + final IOException corruptIndexException; + // we realized that after the index was copied and we wanted to finalize the recovery + // the index was corrupted: + // - maybe due to a broken segments file on an empty index (transferred with no checksum) + // - maybe due to old segments without checksums or length only checks + if ((corruptIndexException = ExceptionsHelper.unwrapCorruption(remoteException)) != null) { + try { + final Store.MetadataSnapshot recoverySourceMetadata1 = store.getMetadata(snapshot); + StoreFileMetaData[] metadata = + StreamSupport.stream(recoverySourceMetadata1.spliterator(), false).toArray(size -> new StoreFileMetaData[size]); + ArrayUtil.timSort(metadata, (o1, o2) -> { + return Long.compare(o1.length(), o2.length()); // check small files first + }); + for (StoreFileMetaData md : metadata) { + cancellableThreads.checkForCancel(); + logger.debug("{} checking integrity for file {} after remove corruption exception", shard.shardId(), md); + if (store.checkIntegrityNoException(md) == false) { // we are corrupted on the primary -- fail! + shard.failShard("recovery", corruptIndexException); + logger.warn("{} Corrupted file detected {} checksum mismatch", shard.shardId(), md); + throw corruptIndexException; } - } catch (IOException ex) { - remoteException.addSuppressed(ex); - throw remoteException; } - // corruption has happened on the way to replica - RemoteTransportException exception = new RemoteTransportException("File corruption occurred on recovery but checksums are ok", null); - exception.addSuppressed(remoteException); - logger.warn("{} Remote file corruption during finalization on node {}, recovering {}. local checksum OK", - corruptIndexException, shard.shardId(), request.targetNode()); - throw exception; - } else { + } catch (IOException ex) { + remoteException.addSuppressed(ex); throw remoteException; } + // corruption has happened on the way to replica + RemoteTransportException exception = new RemoteTransportException("File corruption occurred on recovery but checksums are ok", null); + exception.addSuppressed(remoteException); + logger.warn("{} Remote file corruption during finalization on node {}, recovering {}. local checksum OK", + corruptIndexException, shard.shardId(), request.targetNode()); + throw exception; + } else { + throw remoteException; } - }); + } } prepareTargetForTranslog(translogView.totalOperations()); diff --git a/core/src/main/java/org/elasticsearch/ingest/PipelineStore.java b/core/src/main/java/org/elasticsearch/ingest/PipelineStore.java index 805f1e417ec..21128a94b65 100644 --- a/core/src/main/java/org/elasticsearch/ingest/PipelineStore.java +++ b/core/src/main/java/org/elasticsearch/ingest/PipelineStore.java @@ -36,8 +36,10 @@ import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.ingest.core.Pipeline; +import org.elasticsearch.ingest.core.PipelineFactoryError; import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.ingest.core.TemplateService; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import org.elasticsearch.script.ScriptService; import java.io.Closeable; @@ -101,7 +103,7 @@ public class PipelineStore extends AbstractComponent implements Closeable, Clust Map pipelines = new HashMap<>(); for (PipelineConfiguration pipeline : ingestMetadata.getPipelines().values()) { try { - pipelines.put(pipeline.getId(), constructPipeline(pipeline.getId(), pipeline.getConfigAsMap())); + pipelines.put(pipeline.getId(), factory.create(pipeline.getId(), pipeline.getConfigAsMap(), processorFactoryRegistry)); } catch (Exception e) { throw new RuntimeException(e); } @@ -148,16 +150,14 @@ public class PipelineStore extends AbstractComponent implements Closeable, Clust /** * Stores the specified pipeline definition in the request. - * - * @throws IllegalArgumentException If the pipeline holds incorrect configuration */ - public void put(ClusterService clusterService, PutPipelineRequest request, ActionListener listener) throws IllegalArgumentException { - try { - // validates the pipeline and processor configuration before submitting a cluster update task: - Map pipelineConfig = XContentHelper.convertToMap(request.getSource(), false).v2(); - constructPipeline(request.getId(), pipelineConfig); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid pipeline configuration", e); + public void put(ClusterService clusterService, PutPipelineRequest request, ActionListener listener) { + // validates the pipeline and processor configuration before submitting a cluster update task: + Map pipelineConfig = XContentHelper.convertToMap(request.getSource(), false).v2(); + WritePipelineResponse response = validatePipelineResponse(request.getId(), pipelineConfig); + if (response != null) { + listener.onResponse(response); + return; } clusterService.submitStateUpdateTask("put-pipeline-" + request.getId(), new AckedClusterStateUpdateTask(request, listener) { @@ -235,8 +235,15 @@ public class PipelineStore extends AbstractComponent implements Closeable, Clust return result; } - private Pipeline constructPipeline(String id, Map config) throws Exception { - return factory.create(id, config, processorFactoryRegistry); + WritePipelineResponse validatePipelineResponse(String id, Map config) { + try { + factory.create(id, config, processorFactoryRegistry); + return null; + } catch (ConfigurationPropertyException e) { + return new WritePipelineResponse(new PipelineFactoryError(e)); + } catch (Exception e) { + return new WritePipelineResponse(new PipelineFactoryError(e.getMessage())); + } } } diff --git a/core/src/main/java/org/elasticsearch/ingest/core/AbstractProcessorFactory.java b/core/src/main/java/org/elasticsearch/ingest/core/AbstractProcessorFactory.java index 1082461845e..323344f8f41 100644 --- a/core/src/main/java/org/elasticsearch/ingest/core/AbstractProcessorFactory.java +++ b/core/src/main/java/org/elasticsearch/ingest/core/AbstractProcessorFactory.java @@ -31,7 +31,7 @@ public abstract class AbstractProcessorFactory

implements P @Override public P create(Map config) throws Exception { - String tag = ConfigurationUtils.readOptionalStringProperty(config, TAG_KEY); + String tag = ConfigurationUtils.readOptionalStringProperty(null, null, config, TAG_KEY); return doCreate(tag, config); } diff --git a/core/src/main/java/org/elasticsearch/ingest/core/ConfigurationUtils.java b/core/src/main/java/org/elasticsearch/ingest/core/ConfigurationUtils.java index c6204166908..69adc0f9492 100644 --- a/core/src/main/java/org/elasticsearch/ingest/core/ConfigurationUtils.java +++ b/core/src/main/java/org/elasticsearch/ingest/core/ConfigurationUtils.java @@ -19,6 +19,8 @@ package org.elasticsearch.ingest.core; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; + import java.util.List; import java.util.Map; @@ -30,133 +32,133 @@ public final class ConfigurationUtils { /** * Returns and removes the specified optional property from the specified configuration map. * - * If the property value isn't of type string a {@link IllegalArgumentException} is thrown. + * If the property value isn't of type string a {@link ConfigurationPropertyException} is thrown. */ - public static String readOptionalStringProperty(Map configuration, String propertyName) { + public static String readOptionalStringProperty(String processorType, String processorTag, Map configuration, String propertyName) { Object value = configuration.remove(propertyName); - return readString(propertyName, value); + return readString(processorType, processorTag, propertyName, value); } /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type string an {@link IllegalArgumentException} is thrown. - * If the property is missing an {@link IllegalArgumentException} is thrown + * If the property value isn't of type string an {@link ConfigurationPropertyException} is thrown. + * If the property is missing an {@link ConfigurationPropertyException} is thrown */ - public static String readStringProperty(Map configuration, String propertyName) { - return readStringProperty(configuration, propertyName, null); + public static String readStringProperty(String processorType, String processorTag, Map configuration, String propertyName) { + return readStringProperty(processorType, processorTag, configuration, propertyName, null); } /** * Returns and removes the specified property from the specified configuration map. * - * If the property value isn't of type string a {@link IllegalArgumentException} is thrown. - * If the property is missing and no default value has been specified a {@link IllegalArgumentException} is thrown + * If the property value isn't of type string a {@link ConfigurationPropertyException} is thrown. + * If the property is missing and no default value has been specified a {@link ConfigurationPropertyException} is thrown */ - public static String readStringProperty(Map configuration, String propertyName, String defaultValue) { + public static String readStringProperty(String processorType, String processorTag, Map configuration, String propertyName, String defaultValue) { Object value = configuration.remove(propertyName); if (value == null && defaultValue != null) { return defaultValue; } else if (value == null) { - throw new IllegalArgumentException("required property [" + propertyName + "] is missing"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "required property is missing"); } - return readString(propertyName, value); + return readString(processorType, processorTag, propertyName, value); } - private static String readString(String propertyName, Object value) { + private static String readString(String processorType, String processorTag, String propertyName, Object value) { if (value == null) { return null; } if (value instanceof String) { return (String) value; } - throw new IllegalArgumentException("property [" + propertyName + "] isn't a string, but of type [" + value.getClass().getName() + "]"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "property isn't a string, but of type [" + value.getClass().getName() + "]"); } /** * Returns and removes the specified property of type list from the specified configuration map. * - * If the property value isn't of type list an {@link IllegalArgumentException} is thrown. + * If the property value isn't of type list an {@link ConfigurationPropertyException} is thrown. */ - public static List readOptionalList(Map configuration, String propertyName) { + public static List readOptionalList(String processorType, String processorTag, Map configuration, String propertyName) { Object value = configuration.remove(propertyName); if (value == null) { return null; } - return readList(propertyName, value); + return readList(processorType, processorTag, propertyName, value); } /** * Returns and removes the specified property of type list from the specified configuration map. * - * If the property value isn't of type list an {@link IllegalArgumentException} is thrown. - * If the property is missing an {@link IllegalArgumentException} is thrown + * If the property value isn't of type list an {@link ConfigurationPropertyException} is thrown. + * If the property is missing an {@link ConfigurationPropertyException} is thrown */ - public static List readList(Map configuration, String propertyName) { + public static List readList(String processorType, String processorTag, Map configuration, String propertyName) { Object value = configuration.remove(propertyName); if (value == null) { - throw new IllegalArgumentException("required property [" + propertyName + "] is missing"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "required property is missing"); } - return readList(propertyName, value); + return readList(processorType, processorTag, propertyName, value); } - private static List readList(String propertyName, Object value) { + private static List readList(String processorType, String processorTag, String propertyName, Object value) { if (value instanceof List) { @SuppressWarnings("unchecked") List stringList = (List) value; return stringList; } else { - throw new IllegalArgumentException("property [" + propertyName + "] isn't a list, but of type [" + value.getClass().getName() + "]"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "property isn't a list, but of type [" + value.getClass().getName() + "]"); } } /** * Returns and removes the specified property of type map from the specified configuration map. * - * If the property value isn't of type map an {@link IllegalArgumentException} is thrown. - * If the property is missing an {@link IllegalArgumentException} is thrown + * If the property value isn't of type map an {@link ConfigurationPropertyException} is thrown. + * If the property is missing an {@link ConfigurationPropertyException} is thrown */ - public static Map readMap(Map configuration, String propertyName) { + public static Map readMap(String processorType, String processorTag, Map configuration, String propertyName) { Object value = configuration.remove(propertyName); if (value == null) { - throw new IllegalArgumentException("required property [" + propertyName + "] is missing"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "required property is missing"); } - return readMap(propertyName, value); + return readMap(processorType, processorTag, propertyName, value); } /** * Returns and removes the specified property of type map from the specified configuration map. * - * If the property value isn't of type map an {@link IllegalArgumentException} is thrown. + * If the property value isn't of type map an {@link ConfigurationPropertyException} is thrown. */ - public static Map readOptionalMap(Map configuration, String propertyName) { + public static Map readOptionalMap(String processorType, String processorTag, Map configuration, String propertyName) { Object value = configuration.remove(propertyName); if (value == null) { return null; } - return readMap(propertyName, value); + return readMap(processorType, processorTag, propertyName, value); } - private static Map readMap(String propertyName, Object value) { + private static Map readMap(String processorType, String processorTag, String propertyName, Object value) { if (value instanceof Map) { @SuppressWarnings("unchecked") Map map = (Map) value; return map; } else { - throw new IllegalArgumentException("property [" + propertyName + "] isn't a map, but of type [" + value.getClass().getName() + "]"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "property isn't a map, but of type [" + value.getClass().getName() + "]"); } } /** * Returns and removes the specified property as an {@link Object} from the specified configuration map. */ - public static Object readObject(Map configuration, String propertyName) { + public static Object readObject(String processorType, String processorTag, Map configuration, String propertyName) { Object value = configuration.remove(propertyName); if (value == null) { - throw new IllegalArgumentException("required property [" + propertyName + "] is missing"); + throw new ConfigurationPropertyException(processorType, processorTag, propertyName, "required property is missing"); } return value; } diff --git a/core/src/main/java/org/elasticsearch/ingest/core/Pipeline.java b/core/src/main/java/org/elasticsearch/ingest/core/Pipeline.java index 68ba8da4855..5c654fbce21 100644 --- a/core/src/main/java/org/elasticsearch/ingest/core/Pipeline.java +++ b/core/src/main/java/org/elasticsearch/ingest/core/Pipeline.java @@ -19,6 +19,8 @@ package org.elasticsearch.ingest.core; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -82,19 +84,20 @@ public final class Pipeline { public final static class Factory { - public Pipeline create(String id, Map config, Map processorRegistry) throws Exception { - String description = ConfigurationUtils.readOptionalStringProperty(config, DESCRIPTION_KEY); - List processors = readProcessors(PROCESSORS_KEY, processorRegistry, config); - List onFailureProcessors = readProcessors(ON_FAILURE_KEY, processorRegistry, config); + public Pipeline create(String id, Map config, Map processorRegistry) throws ConfigurationPropertyException { + String description = ConfigurationUtils.readOptionalStringProperty(null, null, config, DESCRIPTION_KEY); + List>> processorConfigs = ConfigurationUtils.readList(null, null, config, PROCESSORS_KEY); + List processors = readProcessorConfigs(processorConfigs, processorRegistry); + List>> onFailureProcessorConfigs = ConfigurationUtils.readOptionalList(null, null, config, ON_FAILURE_KEY); + List onFailureProcessors = readProcessorConfigs(onFailureProcessorConfigs, processorRegistry); if (config.isEmpty() == false) { - throw new IllegalArgumentException("pipeline [" + id + "] doesn't support one or more provided configuration parameters " + Arrays.toString(config.keySet().toArray())); + throw new ConfigurationPropertyException("pipeline [" + id + "] doesn't support one or more provided configuration parameters " + Arrays.toString(config.keySet().toArray())); } CompoundProcessor compoundProcessor = new CompoundProcessor(Collections.unmodifiableList(processors), Collections.unmodifiableList(onFailureProcessors)); return new Pipeline(id, description, compoundProcessor); } - private List readProcessors(String fieldName, Map processorRegistry, Map config) throws Exception { - List>> processorConfigs = ConfigurationUtils.readOptionalList(config, fieldName); + private List readProcessorConfigs(List>> processorConfigs, Map processorRegistry) throws ConfigurationPropertyException { List processors = new ArrayList<>(); if (processorConfigs != null) { for (Map> processorConfigWithKey : processorConfigs) { @@ -107,20 +110,28 @@ public final class Pipeline { return processors; } - private Processor readProcessor(Map processorRegistry, String type, Map config) throws Exception { + private Processor readProcessor(Map processorRegistry, String type, Map config) throws ConfigurationPropertyException { Processor.Factory factory = processorRegistry.get(type); if (factory != null) { - List onFailureProcessors = readProcessors(ON_FAILURE_KEY, processorRegistry, config); - Processor processor = factory.create(config); - if (config.isEmpty() == false) { - throw new IllegalArgumentException("processor [" + type + "] doesn't support one or more provided configuration parameters " + Arrays.toString(config.keySet().toArray())); + List>> onFailureProcessorConfigs = ConfigurationUtils.readOptionalList(null, null, config, ON_FAILURE_KEY); + List onFailureProcessors = readProcessorConfigs(onFailureProcessorConfigs, processorRegistry); + Processor processor; + try { + processor = factory.create(config); + } catch (ConfigurationPropertyException e) { + throw e; + } catch (Exception e) { + throw new ConfigurationPropertyException(e.getMessage()); + } + if (!config.isEmpty()) { + throw new ConfigurationPropertyException("processor [" + type + "] doesn't support one or more provided configuration parameters " + Arrays.toString(config.keySet().toArray())); } if (onFailureProcessors.isEmpty()) { return processor; } return new CompoundProcessor(Collections.singletonList(processor), onFailureProcessors); } - throw new IllegalArgumentException("No processor type exists with name [" + type + "]"); + throw new ConfigurationPropertyException("No processor type exists with name [" + type + "]"); } } } diff --git a/core/src/main/java/org/elasticsearch/ingest/core/PipelineFactoryError.java b/core/src/main/java/org/elasticsearch/ingest/core/PipelineFactoryError.java new file mode 100644 index 00000000000..b987e1ee266 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/ingest/core/PipelineFactoryError.java @@ -0,0 +1,96 @@ +/* + * 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.ingest.core; + + +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Streamable; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentBuilderString; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; + +import java.io.IOException; + +public class PipelineFactoryError implements Streamable, ToXContent { + private String reason; + private String processorType; + private String processorTag; + private String processorPropertyName; + + public PipelineFactoryError() { + + } + + public PipelineFactoryError(ConfigurationPropertyException e) { + this.reason = e.getMessage(); + this.processorType = e.getProcessorType(); + this.processorTag = e.getProcessorTag(); + this.processorPropertyName = e.getPropertyName(); + } + + public PipelineFactoryError(String reason) { + this.reason = "Constructing Pipeline failed:" + reason; + } + + public String getReason() { + return reason; + } + + public String getProcessorTag() { + return processorTag; + } + + public String getProcessorPropertyName() { + return processorPropertyName; + } + + public String getProcessorType() { + return processorType; + } + + @Override + public void readFrom(StreamInput in) throws IOException { + reason = in.readString(); + processorType = in.readOptionalString(); + processorTag = in.readOptionalString(); + processorPropertyName = in.readOptionalString(); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(reason); + out.writeOptionalString(processorType); + out.writeOptionalString(processorTag); + out.writeOptionalString(processorPropertyName); + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject("error"); + builder.field("type", processorType); + builder.field("tag", processorTag); + builder.field("reason", reason); + builder.field("property_name", processorPropertyName); + builder.endObject(); + return builder; + } +} diff --git a/core/src/main/java/org/elasticsearch/ingest/core/PipelineFactoryResult.java b/core/src/main/java/org/elasticsearch/ingest/core/PipelineFactoryResult.java new file mode 100644 index 00000000000..ab284981b33 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/ingest/core/PipelineFactoryResult.java @@ -0,0 +1,43 @@ +/* + * 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.ingest.core; + +public class PipelineFactoryResult { + private final Pipeline pipeline; + private final PipelineFactoryError error; + + public PipelineFactoryResult(Pipeline pipeline) { + this.pipeline = pipeline; + this.error = null; + } + + public PipelineFactoryResult(PipelineFactoryError error) { + this.error = error; + this.pipeline = null; + } + + public Pipeline getPipeline() { + return pipeline; + } + + public PipelineFactoryError getError() { + return error; + } +} diff --git a/core/src/main/java/org/elasticsearch/ingest/core/Processor.java b/core/src/main/java/org/elasticsearch/ingest/core/Processor.java index f178051b751..28049983692 100644 --- a/core/src/main/java/org/elasticsearch/ingest/core/Processor.java +++ b/core/src/main/java/org/elasticsearch/ingest/core/Processor.java @@ -20,6 +20,8 @@ package org.elasticsearch.ingest.core; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; + import java.util.Map; /** diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/AbstractStringProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/AbstractStringProcessor.java index 32e54765b18..6ae9f2d3526 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/AbstractStringProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/AbstractStringProcessor.java @@ -55,10 +55,15 @@ public abstract class AbstractStringProcessor extends AbstractProcessor { protected abstract String process(String value); public static abstract class Factory extends AbstractProcessorFactory { + protected final String processorType; + + protected Factory(String processorType) { + this.processorType = processorType; + } @Override public T doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); + String field = ConfigurationUtils.readStringProperty(processorType, processorTag, config, "field"); return newProcessor(processorTag, field); } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/AppendProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/AppendProcessor.java index deff384cf92..84f979083b4 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/AppendProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/AppendProcessor.java @@ -74,8 +74,8 @@ public class AppendProcessor extends AbstractProcessor { @Override public AppendProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - Object value = ConfigurationUtils.readObject(config, "value"); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + Object value = ConfigurationUtils.readObject(TYPE, processorTag, config, "value"); return new AppendProcessor(processorTag, templateService.compile(field), ValueSource.wrap(value, templateService)); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/ConfigurationPropertyException.java b/core/src/main/java/org/elasticsearch/ingest/processor/ConfigurationPropertyException.java new file mode 100644 index 00000000000..dbc35c9334f --- /dev/null +++ b/core/src/main/java/org/elasticsearch/ingest/processor/ConfigurationPropertyException.java @@ -0,0 +1,53 @@ +/* + * 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.ingest.processor; + +/** + * Exception class thrown by processor factories. + */ +public class ConfigurationPropertyException extends RuntimeException { + private String processorType; + private String processorTag; + private String propertyName; + + public ConfigurationPropertyException(String processorType, String processorTag, String propertyName, String message) { + super("[" + propertyName + "] " + message); + this.processorTag = processorTag; + this.processorType = processorType; + this.propertyName = propertyName; + } + + public ConfigurationPropertyException(String errorMessage) { + super(errorMessage); + } + + public String getPropertyName() { + return propertyName; + } + + public String getProcessorType() { + return processorType; + } + + public String getProcessorTag() { + return processorTag; + } +} + diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/ConvertProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/ConvertProcessor.java index 5b6bacf2ed1..213e3ec2c78 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/ConvertProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/ConvertProcessor.java @@ -137,8 +137,8 @@ public class ConvertProcessor extends AbstractProcessor { public static class Factory extends AbstractProcessorFactory { @Override public ConvertProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - Type convertType = Type.fromString(ConfigurationUtils.readStringProperty(config, "type")); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + Type convertType = Type.fromString(ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "type")); return new ConvertProcessor(processorTag, field, convertType); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/DateProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/DateProcessor.java index 9fc0378d774..4b08b42a735 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/DateProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/DateProcessor.java @@ -112,11 +112,11 @@ public final class DateProcessor extends AbstractProcessor { @SuppressWarnings("unchecked") public DateProcessor doCreate(String processorTag, Map config) throws Exception { - String matchField = ConfigurationUtils.readStringProperty(config, "match_field"); - String targetField = ConfigurationUtils.readStringProperty(config, "target_field", DEFAULT_TARGET_FIELD); - String timezoneString = ConfigurationUtils.readOptionalStringProperty(config, "timezone"); + String matchField = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "match_field"); + String targetField = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "target_field", DEFAULT_TARGET_FIELD); + String timezoneString = ConfigurationUtils.readOptionalStringProperty(TYPE, processorTag, config, "timezone"); DateTimeZone timezone = timezoneString == null ? DateTimeZone.UTC : DateTimeZone.forID(timezoneString); - String localeString = ConfigurationUtils.readOptionalStringProperty(config, "locale"); + String localeString = ConfigurationUtils.readOptionalStringProperty(TYPE, processorTag, config, "locale"); Locale locale = Locale.ENGLISH; if (localeString != null) { try { @@ -125,7 +125,7 @@ public final class DateProcessor extends AbstractProcessor { throw new IllegalArgumentException("Invalid language tag specified: " + localeString); } } - List matchFormats = ConfigurationUtils.readList(config, "match_formats"); + List matchFormats = ConfigurationUtils.readList(TYPE, processorTag, config, "match_formats"); return new DateProcessor(processorTag, timezone, locale, matchField, matchFormats, targetField); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/DeDotProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/DeDotProcessor.java index b8f86616ffc..62063a49fd0 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/DeDotProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/DeDotProcessor.java @@ -95,7 +95,7 @@ public class DeDotProcessor extends AbstractProcessor { @Override public DeDotProcessor doCreate(String processorTag, Map config) throws Exception { - String separator = ConfigurationUtils.readOptionalStringProperty(config, "separator"); + String separator = ConfigurationUtils.readOptionalStringProperty(TYPE, processorTag, config, "separator"); if (separator == null) { separator = DEFAULT_SEPARATOR; } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/FailProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/FailProcessor.java index 76c7b3c40ea..86758de862c 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/FailProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/FailProcessor.java @@ -66,7 +66,7 @@ public class FailProcessor extends AbstractProcessor { @Override public FailProcessor doCreate(String processorTag, Map config) throws Exception { - String message = ConfigurationUtils.readStringProperty(config, "message"); + String message = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "message"); return new FailProcessor(processorTag, templateService.compile(message)); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/GsubProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/GsubProcessor.java index 0ec7fba84f2..1118ed6b956 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/GsubProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/GsubProcessor.java @@ -79,9 +79,9 @@ public class GsubProcessor extends AbstractProcessor { public static class Factory extends AbstractProcessorFactory { @Override public GsubProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - String pattern = ConfigurationUtils.readStringProperty(config, "pattern"); - String replacement = ConfigurationUtils.readStringProperty(config, "replacement"); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + String pattern = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "pattern"); + String replacement = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "replacement"); Pattern searchPattern = Pattern.compile(pattern); return new GsubProcessor(processorTag, field, searchPattern, replacement); } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/JoinProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/JoinProcessor.java index dd729dd0afd..813c42a2965 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/JoinProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/JoinProcessor.java @@ -73,8 +73,8 @@ public class JoinProcessor extends AbstractProcessor { public static class Factory extends AbstractProcessorFactory { @Override public JoinProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - String separator = ConfigurationUtils.readStringProperty(config, "separator"); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + String separator = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "separator"); return new JoinProcessor(processorTag, field, separator); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/LowercaseProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/LowercaseProcessor.java index 617efd9b480..0931e5d77d9 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/LowercaseProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/LowercaseProcessor.java @@ -45,6 +45,11 @@ public class LowercaseProcessor extends AbstractStringProcessor { } public static class Factory extends AbstractStringProcessor.Factory { + + public Factory() { + super(TYPE); + } + @Override protected LowercaseProcessor newProcessor(String tag, String field) { return new LowercaseProcessor(tag, field); diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/RemoveProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/RemoveProcessor.java index a39ac8f5cf4..489822867c9 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/RemoveProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/RemoveProcessor.java @@ -65,7 +65,7 @@ public class RemoveProcessor extends AbstractProcessor { @Override public RemoveProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); return new RemoveProcessor(processorTag, templateService.compile(field)); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/RenameProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/RenameProcessor.java index 6088315884e..8e19c4ecc15 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/RenameProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/RenameProcessor.java @@ -78,8 +78,8 @@ public class RenameProcessor extends AbstractProcessor { public static class Factory extends AbstractProcessorFactory { @Override public RenameProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - String newField = ConfigurationUtils.readStringProperty(config, "to"); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + String newField = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "to"); return new RenameProcessor(processorTag, field, newField); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/SetProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/SetProcessor.java index e046a5f3bdb..d150016cf91 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/SetProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/SetProcessor.java @@ -73,8 +73,8 @@ public class SetProcessor extends AbstractProcessor { @Override public SetProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - Object value = ConfigurationUtils.readObject(config, "value"); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + Object value = ConfigurationUtils.readObject(TYPE, processorTag, config, "value"); return new SetProcessor(processorTag, templateService.compile(field), ValueSource.wrap(value, templateService)); } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/SplitProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/SplitProcessor.java index ad0bffb061a..2ecaad1a7d0 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/SplitProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/SplitProcessor.java @@ -75,8 +75,8 @@ public class SplitProcessor extends AbstractProcessor { public static class Factory extends AbstractProcessorFactory { @Override public SplitProcessor doCreate(String processorTag, Map config) throws Exception { - String field = ConfigurationUtils.readStringProperty(config, "field"); - return new SplitProcessor(processorTag, field, ConfigurationUtils.readStringProperty(config, "separator")); + String field = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + return new SplitProcessor(processorTag, field, ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "separator")); } } } diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/TrimProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/TrimProcessor.java index c66cc848933..7de309b51c6 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/TrimProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/TrimProcessor.java @@ -42,6 +42,11 @@ public class TrimProcessor extends AbstractStringProcessor { } public static class Factory extends AbstractStringProcessor.Factory { + + public Factory() { + super(TYPE); + } + @Override protected TrimProcessor newProcessor(String tag, String field) { return new TrimProcessor(tag, field); diff --git a/core/src/main/java/org/elasticsearch/ingest/processor/UppercaseProcessor.java b/core/src/main/java/org/elasticsearch/ingest/processor/UppercaseProcessor.java index e6a1f77cb86..7b10d022798 100644 --- a/core/src/main/java/org/elasticsearch/ingest/processor/UppercaseProcessor.java +++ b/core/src/main/java/org/elasticsearch/ingest/processor/UppercaseProcessor.java @@ -44,6 +44,11 @@ public class UppercaseProcessor extends AbstractStringProcessor { } public static class Factory extends AbstractStringProcessor.Factory { + + public Factory() { + super(TYPE); + } + @Override protected UppercaseProcessor newProcessor(String tag, String field) { return new UppercaseProcessor(tag, field); diff --git a/core/src/main/java/org/elasticsearch/monitor/MonitorService.java b/core/src/main/java/org/elasticsearch/monitor/MonitorService.java index 15af2cb0a75..cf033e54d7c 100644 --- a/core/src/main/java/org/elasticsearch/monitor/MonitorService.java +++ b/core/src/main/java/org/elasticsearch/monitor/MonitorService.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.monitor.fs.FsService; -import org.elasticsearch.monitor.jvm.JvmMonitorService; +import org.elasticsearch.monitor.jvm.JvmGcMonitorService; import org.elasticsearch.monitor.jvm.JvmService; import org.elasticsearch.monitor.os.OsService; import org.elasticsearch.monitor.process.ProcessService; @@ -36,7 +36,7 @@ import java.io.IOException; */ public class MonitorService extends AbstractLifecycleComponent { - private final JvmMonitorService jvmMonitorService; + private final JvmGcMonitorService jvmGcMonitorService; private final OsService osService; @@ -48,7 +48,7 @@ public class MonitorService extends AbstractLifecycleComponent { public MonitorService(Settings settings, NodeEnvironment nodeEnvironment, ThreadPool threadPool) throws IOException { super(settings); - this.jvmMonitorService = new JvmMonitorService(settings, threadPool); + this.jvmGcMonitorService = new JvmGcMonitorService(settings, threadPool); this.osService = new OsService(settings); this.processService = new ProcessService(settings); this.jvmService = new JvmService(settings); @@ -73,16 +73,16 @@ public class MonitorService extends AbstractLifecycleComponent { @Override protected void doStart() { - jvmMonitorService.start(); + jvmGcMonitorService.start(); } @Override protected void doStop() { - jvmMonitorService.stop(); + jvmGcMonitorService.stop(); } @Override protected void doClose() { - jvmMonitorService.close(); + jvmGcMonitorService.close(); } } diff --git a/core/src/main/java/org/elasticsearch/monitor/fs/FsService.java b/core/src/main/java/org/elasticsearch/monitor/fs/FsService.java index 7019ec48e0b..99a78f13a07 100644 --- a/core/src/main/java/org/elasticsearch/monitor/fs/FsService.java +++ b/core/src/main/java/org/elasticsearch/monitor/fs/FsService.java @@ -20,6 +20,7 @@ package org.elasticsearch.monitor.fs; import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.SingleObjectCache; @@ -35,10 +36,13 @@ public class FsService extends AbstractComponent { private final SingleObjectCache fsStatsCache; + public final static Setting REFRESH_INTERVAL_SETTING = + Setting.timeSetting("monitor.fs.refresh_interval", TimeValue.timeValueSeconds(1), TimeValue.timeValueSeconds(1), false, Setting.Scope.CLUSTER); + public FsService(Settings settings, NodeEnvironment nodeEnvironment) throws IOException { super(settings); this.probe = new FsProbe(settings, nodeEnvironment); - TimeValue refreshInterval = settings.getAsTime("monitor.fs.refresh_interval", TimeValue.timeValueSeconds(1)); + TimeValue refreshInterval = REFRESH_INTERVAL_SETTING.get(settings); fsStatsCache = new FsInfoCache(refreshInterval, probe.stats()); logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval); } diff --git a/core/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java b/core/src/main/java/org/elasticsearch/monitor/jvm/JvmGcMonitorService.java similarity index 79% rename from core/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java rename to core/src/main/java/org/elasticsearch/monitor/jvm/JvmGcMonitorService.java index 8d83435bb98..97c813a0fe3 100644 --- a/core/src/main/java/org/elasticsearch/monitor/jvm/JvmMonitorService.java +++ b/core/src/main/java/org/elasticsearch/monitor/jvm/JvmGcMonitorService.java @@ -20,6 +20,8 @@ package org.elasticsearch.monitor.jvm; import org.elasticsearch.common.component.AbstractLifecycleComponent; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Setting.Scope; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.FutureUtils; @@ -31,13 +33,12 @@ import java.util.Map; import java.util.concurrent.ScheduledFuture; import static java.util.Collections.unmodifiableMap; -import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.monitor.jvm.JvmStats.jvmStats; /** * */ -public class JvmMonitorService extends AbstractLifecycleComponent { +public class JvmGcMonitorService extends AbstractLifecycleComponent { private final ThreadPool threadPool; private final boolean enabled; @@ -46,6 +47,13 @@ public class JvmMonitorService extends AbstractLifecycleComponent ENABLED_SETTING = Setting.boolSetting("monitor.jvm.gc.enabled", true, false, Scope.CLUSTER); + public final static Setting REFRESH_INTERVAL_SETTING = + Setting.timeSetting("monitor.jvm.gc.refresh_interval", TimeValue.timeValueSeconds(1), TimeValue.timeValueSeconds(1), false, Scope.CLUSTER); + + private static String GC_COLLECTOR_PREFIX = "monitor.jvm.gc.collector."; + public final static Setting GC_SETTING = Setting.groupSetting(GC_COLLECTOR_PREFIX, false, Scope.CLUSTER); + static class GcThreshold { public final String name; public final long warnThreshold; @@ -70,25 +78,21 @@ public class JvmMonitorService extends AbstractLifecycleComponent gcThresholds = new HashMap<>(); - Map gcThresholdGroups = this.settings.getGroups("monitor.jvm.gc"); + Map gcThresholdGroups = GC_SETTING.get(settings).getAsGroups(); for (Map.Entry entry : gcThresholdGroups.entrySet()) { String name = entry.getKey(); - TimeValue warn = entry.getValue().getAsTime("warn", null); - TimeValue info = entry.getValue().getAsTime("info", null); - TimeValue debug = entry.getValue().getAsTime("debug", null); - if (warn == null || info == null || debug == null) { - logger.warn("ignoring gc_threshold for [{}], missing warn/info/debug values", name); - } else { - gcThresholds.put(name, new GcThreshold(name, warn.millis(), info.millis(), debug.millis())); - } + TimeValue warn = getValidThreshold(entry.getValue(), entry.getKey(), "warn"); + TimeValue info = getValidThreshold(entry.getValue(), entry.getKey(), "info"); + TimeValue debug = getValidThreshold(entry.getValue(), entry.getKey(), "debug"); + gcThresholds.put(name, new GcThreshold(name, warn.millis(), info.millis(), debug.millis())); } gcThresholds.putIfAbsent(GcNames.YOUNG, new GcThreshold(GcNames.YOUNG, 1000, 700, 400)); gcThresholds.putIfAbsent(GcNames.OLD, new GcThreshold(GcNames.OLD, 10000, 5000, 2000)); @@ -98,6 +102,21 @@ public class JvmMonitorService extends AbstractLifecycleComponent REFRESH_INTERVAL_SETTING = + Setting.timeSetting("monitor.jvm.refresh_interval", TimeValue.timeValueSeconds(1), TimeValue.timeValueSeconds(1), false, Setting.Scope.CLUSTER); + public JvmService(Settings settings) { super(settings); this.jvmInfo = JvmInfo.jvmInfo(); this.jvmStats = JvmStats.jvmStats(); - this.refreshInterval = this.settings.getAsTime("refresh_interval", TimeValue.timeValueSeconds(1)); + this.refreshInterval = REFRESH_INTERVAL_SETTING.get(settings); logger.debug("Using refresh_interval [{}]", refreshInterval); } diff --git a/core/src/main/java/org/elasticsearch/monitor/os/OsService.java b/core/src/main/java/org/elasticsearch/monitor/os/OsService.java index dc1ecb643a8..5f836c6f928 100644 --- a/core/src/main/java/org/elasticsearch/monitor/os/OsService.java +++ b/core/src/main/java/org/elasticsearch/monitor/os/OsService.java @@ -20,6 +20,7 @@ package org.elasticsearch.monitor.os; import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.SingleObjectCache; @@ -36,11 +37,14 @@ public class OsService extends AbstractComponent { private SingleObjectCache osStatsCache; + public final static Setting REFRESH_INTERVAL_SETTING = + Setting.timeSetting("monitor.os.refresh_interval", TimeValue.timeValueSeconds(1), TimeValue.timeValueSeconds(1), false, Setting.Scope.CLUSTER); + public OsService(Settings settings) { super(settings); this.probe = OsProbe.getInstance(); - TimeValue refreshInterval = settings.getAsTime("monitor.os.refresh_interval", TimeValue.timeValueSeconds(1)); + TimeValue refreshInterval = REFRESH_INTERVAL_SETTING.get(settings); this.info = probe.osInfo(); this.info.refreshInterval = refreshInterval.millis(); diff --git a/core/src/main/java/org/elasticsearch/monitor/process/ProcessService.java b/core/src/main/java/org/elasticsearch/monitor/process/ProcessService.java index 0861dfe5b0c..9e3283af4fc 100644 --- a/core/src/main/java/org/elasticsearch/monitor/process/ProcessService.java +++ b/core/src/main/java/org/elasticsearch/monitor/process/ProcessService.java @@ -20,6 +20,7 @@ package org.elasticsearch.monitor.process; import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.SingleObjectCache; @@ -33,11 +34,14 @@ public final class ProcessService extends AbstractComponent { private final ProcessInfo info; private final SingleObjectCache processStatsCache; + public final static Setting REFRESH_INTERVAL_SETTING = + Setting.timeSetting("monitor.process.refresh_interval", TimeValue.timeValueSeconds(1), TimeValue.timeValueSeconds(1), false, Setting.Scope.CLUSTER); + public ProcessService(Settings settings) { super(settings); this.probe = ProcessProbe.getInstance(); - final TimeValue refreshInterval = settings.getAsTime("monitor.process.refresh_interval", TimeValue.timeValueSeconds(1)); + final TimeValue refreshInterval = REFRESH_INTERVAL_SETTING.get(settings); processStatsCache = new ProcessStatsCache(refreshInterval, probe.processStats()); this.info = probe.processInfo(); this.info.refreshInterval = refreshInterval.millis(); diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java index 2678636ea24..542039fe22f 100644 --- a/core/src/main/java/org/elasticsearch/node/Node.java +++ b/core/src/main/java/org/elasticsearch/node/Node.java @@ -19,6 +19,7 @@ package org.elasticsearch.node; +import org.apache.lucene.util.IOUtils; import org.elasticsearch.Build; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; @@ -100,6 +101,7 @@ import org.elasticsearch.watcher.ResourceWatcherModule; import org.elasticsearch.watcher.ResourceWatcherService; import java.io.BufferedWriter; +import java.io.Closeable; import java.io.IOException; import java.net.Inet6Address; import java.net.InetAddress; @@ -108,9 +110,11 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -120,7 +124,7 @@ import static org.elasticsearch.common.settings.Settings.settingsBuilder; * A node represent a node within a cluster (cluster.name). The {@link #client()} can be used * in order to use a {@link Client} to perform actions/operations against the cluster. */ -public class Node implements Releasable { +public class Node implements Closeable { public static final Setting WRITE_PORTS_FIELD_SETTING = Setting.boolSetting("node.portsfile", false, false, Setting.Scope.CLUSTER); public static final Setting NODE_CLIENT_SETTING = Setting.boolSetting("node.client", false, false, Setting.Scope.CLUSTER); @@ -351,7 +355,7 @@ public class Node implements Releasable { // If not, the hook that is added in Bootstrap#setup() will be useless: close() might not be executed, in case another (for example api) call // to close() has already set some lifecycles to stopped. In this case the process will be terminated even if the first call to close() has not finished yet. @Override - public synchronized void close() { + public synchronized void close() throws IOException { if (lifecycle.started()) { stop(); } @@ -361,88 +365,80 @@ public class Node implements Releasable { ESLogger logger = Loggers.getLogger(Node.class, settings.get("name")); logger.info("closing ..."); - + List toClose = new ArrayList<>(); StopWatch stopWatch = new StopWatch("node_close"); - stopWatch.start("tribe"); - injector.getInstance(TribeService.class).close(); - stopWatch.stop().start("node_service"); - try { - injector.getInstance(NodeService.class).close(); - } catch (IOException e) { - logger.warn("NodeService close failed", e); - } - stopWatch.stop().start("http"); + toClose.add(() -> stopWatch.start("tribe")); + toClose.add(injector.getInstance(TribeService.class)); + toClose.add(() -> stopWatch.stop().start("node_service")); + toClose.add(injector.getInstance(NodeService.class)); + toClose.add(() ->stopWatch.stop().start("http")); if (settings.getAsBoolean("http.enabled", true)) { - injector.getInstance(HttpServer.class).close(); + toClose.add(injector.getInstance(HttpServer.class)); } - stopWatch.stop().start("snapshot_service"); - injector.getInstance(SnapshotsService.class).close(); - injector.getInstance(SnapshotShardsService.class).close(); - stopWatch.stop().start("client"); + toClose.add(() ->stopWatch.stop().start("snapshot_service")); + toClose.add(injector.getInstance(SnapshotsService.class)); + toClose.add(injector.getInstance(SnapshotShardsService.class)); + toClose.add(() ->stopWatch.stop().start("client")); Releasables.close(injector.getInstance(Client.class)); - stopWatch.stop().start("indices_cluster"); - injector.getInstance(IndicesClusterStateService.class).close(); - stopWatch.stop().start("indices"); - injector.getInstance(IndicesTTLService.class).close(); - injector.getInstance(IndicesService.class).close(); + toClose.add(() ->stopWatch.stop().start("indices_cluster")); + toClose.add(injector.getInstance(IndicesClusterStateService.class)); + toClose.add(() ->stopWatch.stop().start("indices")); + toClose.add(injector.getInstance(IndicesTTLService.class)); + toClose.add(injector.getInstance(IndicesService.class)); // close filter/fielddata caches after indices - injector.getInstance(IndicesQueryCache.class).close(); - injector.getInstance(IndicesFieldDataCache.class).close(); - injector.getInstance(IndicesStore.class).close(); - stopWatch.stop().start("routing"); - injector.getInstance(RoutingService.class).close(); - stopWatch.stop().start("cluster"); - injector.getInstance(ClusterService.class).close(); - stopWatch.stop().start("discovery"); - injector.getInstance(DiscoveryService.class).close(); - stopWatch.stop().start("monitor"); - injector.getInstance(MonitorService.class).close(); - stopWatch.stop().start("gateway"); - injector.getInstance(GatewayService.class).close(); - stopWatch.stop().start("search"); - injector.getInstance(SearchService.class).close(); - stopWatch.stop().start("rest"); - injector.getInstance(RestController.class).close(); - stopWatch.stop().start("transport"); - injector.getInstance(TransportService.class).close(); - stopWatch.stop().start("percolator_service"); - injector.getInstance(PercolatorService.class).close(); + toClose.add(injector.getInstance(IndicesQueryCache.class)); + toClose.add(injector.getInstance(IndicesFieldDataCache.class)); + toClose.add(injector.getInstance(IndicesStore.class)); + toClose.add(() ->stopWatch.stop().start("routing")); + toClose.add(injector.getInstance(RoutingService.class)); + toClose.add(() ->stopWatch.stop().start("cluster")); + toClose.add(injector.getInstance(ClusterService.class)); + toClose.add(() ->stopWatch.stop().start("discovery")); + toClose.add(injector.getInstance(DiscoveryService.class)); + toClose.add(() ->stopWatch.stop().start("monitor")); + toClose.add(injector.getInstance(MonitorService.class)); + toClose.add(() ->stopWatch.stop().start("gateway")); + toClose.add(injector.getInstance(GatewayService.class)); + toClose.add(() ->stopWatch.stop().start("search")); + toClose.add(injector.getInstance(SearchService.class)); + toClose.add(() ->stopWatch.stop().start("rest")); + toClose.add(injector.getInstance(RestController.class)); + toClose.add(() ->stopWatch.stop().start("transport")); + toClose.add(injector.getInstance(TransportService.class)); + toClose.add(() ->stopWatch.stop().start("percolator_service")); + toClose.add(injector.getInstance(PercolatorService.class)); for (Class plugin : pluginsService.nodeServices()) { - stopWatch.stop().start("plugin(" + plugin.getName() + ")"); - injector.getInstance(plugin).close(); + toClose.add(() ->stopWatch.stop().start("plugin(" + plugin.getName() + ")")); + toClose.add(injector.getInstance(plugin)); } - stopWatch.stop().start("script"); - try { - injector.getInstance(ScriptService.class).close(); - } catch(IOException e) { - logger.warn("ScriptService close failed", e); - } + toClose.add(() ->stopWatch.stop().start("script")); + toClose.add(injector.getInstance(ScriptService.class)); - stopWatch.stop().start("thread_pool"); + toClose.add(() ->stopWatch.stop().start("thread_pool")); // TODO this should really use ThreadPool.terminate() - injector.getInstance(ThreadPool.class).shutdown(); - try { - injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - // ignore - } - stopWatch.stop().start("thread_pool_force_shutdown"); - try { - injector.getInstance(ThreadPool.class).shutdownNow(); - } catch (Exception e) { - // ignore - } - stopWatch.stop(); + toClose.add(() -> injector.getInstance(ThreadPool.class).shutdown()); + toClose.add(() -> { + try { + injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + // ignore + } + }); + + toClose.add(() ->stopWatch.stop().start("thread_pool_force_shutdown")); + toClose.add(() -> injector.getInstance(ThreadPool.class).shutdownNow()); + toClose.add(() -> stopWatch.stop()); + + + toClose.add(injector.getInstance(NodeEnvironment.class)); + toClose.add(injector.getInstance(PageCacheRecycler.class)); if (logger.isTraceEnabled()) { logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint()); } - - injector.getInstance(NodeEnvironment.class).close(); - injector.getInstance(PageCacheRecycler.class).close(); - + IOUtils.close(toClose); logger.info("closed"); } diff --git a/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java index 654c1d44e94..b845647cd2c 100644 --- a/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/core/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -44,6 +44,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.text.Text; @@ -87,7 +88,7 @@ import java.util.stream.StreamSupport; import static org.apache.lucene.search.BooleanClause.Occur.FILTER; import static org.apache.lucene.search.BooleanClause.Occur.MUST; -public class PercolatorService extends AbstractComponent { +public class PercolatorService extends AbstractComponent implements Releasable { public final static float NO_SCORE = Float.NEGATIVE_INFINITY; public final static String TYPE_NAME = ".percolator"; @@ -308,6 +309,7 @@ public class PercolatorService extends AbstractComponent { } } + @Override public void close() { cache.close(); } diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java index f0ddc83acaa..badccbb9579 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestPutPipelineAction.java @@ -20,9 +20,13 @@ package org.elasticsearch.rest.action.ingest; import org.elasticsearch.action.ingest.PutPipelineRequest; +import org.elasticsearch.action.ingest.WritePipelineResponse; +import org.elasticsearch.action.ingest.WritePipelineResponseRestListener; import org.elasticsearch.client.Client; 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.rest.BaseRestHandler; import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestController; @@ -30,6 +34,8 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.support.AcknowledgedRestListener; import org.elasticsearch.rest.action.support.RestActions; +import java.io.IOException; + public class RestPutPipelineAction extends BaseRestHandler { @Inject @@ -43,6 +49,7 @@ public class RestPutPipelineAction extends BaseRestHandler { PutPipelineRequest request = new PutPipelineRequest(restRequest.param("id"), RestActions.getRestContent(restRequest)); request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout())); request.timeout(restRequest.paramAsTime("timeout", request.timeout())); - client.admin().cluster().putPipeline(request, new AcknowledgedRestListener<>(channel)); + client.admin().cluster().putPipeline(request, new WritePipelineResponseRestListener(channel)); } + } diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java index 82b504b0ea7..94f80a9b611 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java @@ -28,6 +28,7 @@ import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.support.RestActions; +import org.elasticsearch.rest.action.support.RestStatusToXContentListener; import org.elasticsearch.rest.action.support.RestToXContentListener; public class RestSimulatePipelineAction extends BaseRestHandler { @@ -46,6 +47,6 @@ public class RestSimulatePipelineAction extends BaseRestHandler { SimulatePipelineRequest request = new SimulatePipelineRequest(RestActions.getRestContent(restRequest)); request.setId(restRequest.param("id")); request.setVerbose(restRequest.paramAsBoolean("verbose", false)); - client.admin().cluster().simulatePipeline(request, new RestToXContentListener<>(channel)); + client.admin().cluster().simulatePipeline(request, new RestStatusToXContentListener<>(channel)); } } diff --git a/core/src/main/java/org/elasticsearch/rest/support/RestUtils.java b/core/src/main/java/org/elasticsearch/rest/support/RestUtils.java index 56bb18d5e6e..167e858c1df 100644 --- a/core/src/main/java/org/elasticsearch/rest/support/RestUtils.java +++ b/core/src/main/java/org/elasticsearch/rest/support/RestUtils.java @@ -57,7 +57,7 @@ public class RestUtils { if (fromIndex >= s.length()) { return; } - + int queryStringLength = s.contains("#") ? s.indexOf("#") : s.length(); String name = null; diff --git a/core/src/main/java/org/elasticsearch/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index 62a77340cbf..b9c43cab4fa 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -1135,7 +1135,7 @@ public class SearchService extends AbstractLifecycleComponent imp // Use the same value for both checks since lastAccessTime can // be modified by another thread between checks! final long lastAccessTime = context.lastAccessTime(); - if (lastAccessTime == -1l) { // its being processed or timeout is disabled + if (lastAccessTime == -1L) { // its being processed or timeout is disabled continue; } if ((time - lastAccessTime > context.keepAlive())) { diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java index fbada14129d..cdaaf025ae4 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/avg/AvgAggregator.java @@ -114,7 +114,7 @@ public class AvgAggregator extends NumericMetricsAggregator.SingleValue { @Override public InternalAggregation buildEmptyAggregation() { - return new InternalAvg(name, 0.0, 0l, formatter, pipelineAggregators(), metaData()); + return new InternalAvg(name, 0.0, 0L, formatter, pipelineAggregators(), metaData()); } public static class Factory extends ValuesSourceAggregatorFactory.LeafOnly { diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/GeoCentroidAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/GeoCentroidAggregator.java index 39aa6bcea92..168270aa07a 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/GeoCentroidAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/geocentroid/GeoCentroidAggregator.java @@ -117,7 +117,7 @@ public final class GeoCentroidAggregator extends MetricsAggregator { @Override public InternalAggregation buildEmptyAggregation() { - return new InternalGeoCentroid(name, null, 0l, pipelineAggregators(), metaData()); + return new InternalGeoCentroid(name, null, 0L, pipelineAggregators(), metaData()); } @Override diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java index 3a3a41376bb..8c445e8e6c6 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/metrics/valuecount/ValueCountAggregator.java @@ -104,7 +104,7 @@ public class ValueCountAggregator extends NumericMetricsAggregator.SingleValue { @Override public InternalAggregation buildEmptyAggregation() { - return new InternalValueCount(name, 0l, formatter, pipelineAggregators(), metaData()); + return new InternalValueCount(name, 0L, formatter, pipelineAggregators(), metaData()); } @Override diff --git a/core/src/main/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorBuilder.java b/core/src/main/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorBuilder.java new file mode 100644 index 00000000000..90ec2845b8a --- /dev/null +++ b/core/src/main/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorBuilder.java @@ -0,0 +1,493 @@ +/* + * 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.search.suggest.phrase; + +import org.apache.lucene.util.automaton.LevenshteinAutomata; +import org.elasticsearch.ExceptionsHelper; +import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.collect.Tuple; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.xcontent.ObjectParser; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.query.QueryParseContext; +import org.elasticsearch.index.query.QueryShardContext; +import org.elasticsearch.search.suggest.SuggestUtils; +import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.CandidateGenerator; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; + +public final class DirectCandidateGeneratorBuilder + implements Writeable, CandidateGenerator { + + private static final String TYPE = "direct_generator"; + static final DirectCandidateGeneratorBuilder PROTOTYPE = new DirectCandidateGeneratorBuilder("_na_"); + + static final ParseField DIRECT_GENERATOR_FIELD = new ParseField(TYPE); + static final ParseField FIELDNAME_FIELD = new ParseField("field"); + static final ParseField PREFILTER_FIELD = new ParseField("pre_filter"); + static final ParseField POSTFILTER_FIELD = new ParseField("post_filter"); + static final ParseField SUGGESTMODE_FIELD = new ParseField("suggest_mode"); + static final ParseField MIN_DOC_FREQ_FIELD = new ParseField("min_doc_freq"); + static final ParseField ACCURACY_FIELD = new ParseField("accuracy"); + static final ParseField SIZE_FIELD = new ParseField("size"); + static final ParseField SORT_FIELD = new ParseField("sort"); + static final ParseField STRING_DISTANCE_FIELD = new ParseField("string_distance"); + static final ParseField MAX_EDITS_FIELD = new ParseField("max_edits"); + static final ParseField MAX_INSPECTIONS_FIELD = new ParseField("max_inspections"); + static final ParseField MAX_TERM_FREQ_FIELD = new ParseField("max_term_freq"); + static final ParseField PREFIX_LENGTH_FIELD = new ParseField("prefix_length"); + static final ParseField MIN_WORD_LENGTH_FIELD = new ParseField("min_word_length"); + + private final String field; + private String preFilter; + private String postFilter; + private String suggestMode; + private Float accuracy; + private Integer size; + private String sort; + private String stringDistance; + private Integer maxEdits; + private Integer maxInspections; + private Float maxTermFreq; + private Integer prefixLength; + private Integer minWordLength; + private Float minDocFreq; + + /** + * @param field Sets from what field to fetch the candidate suggestions from. + */ + public DirectCandidateGeneratorBuilder(String field) { + this.field = field; + } + + /** + * Quasi copy-constructor that takes all values from the generator + * passed in, but uses different field name. Needed by parser because we + * need to buffer the field name but read all other properties to a + * temporary object. + */ + private static DirectCandidateGeneratorBuilder replaceField(String field, DirectCandidateGeneratorBuilder other) { + DirectCandidateGeneratorBuilder generator = new DirectCandidateGeneratorBuilder(field); + generator.preFilter = other.preFilter; + generator.postFilter = other.postFilter; + generator.suggestMode = other.suggestMode; + generator.accuracy = other.accuracy; + generator.size = other.size; + generator.sort = other.sort; + generator.stringDistance = other.stringDistance; + generator.maxEdits = other.maxEdits; + generator.maxInspections = other.maxInspections; + generator.maxTermFreq = other.maxTermFreq; + generator.prefixLength = other.prefixLength; + generator.minWordLength = other.minWordLength; + generator.minDocFreq = other.minDocFreq; + return generator; + } + + /** + * The global suggest mode controls what suggested terms are included or + * controls for what suggest text tokens, terms should be suggested for. + * Three possible values can be specified: + *

    + *
  1. missing - Only suggest terms in the suggest text + * that aren't in the index. This is the default. + *
  2. popular - Only suggest terms that occur in more docs + * then the original suggest text term. + *
  3. always - Suggest any matching suggest terms based on + * tokens in the suggest text. + *
+ */ + public DirectCandidateGeneratorBuilder suggestMode(String suggestMode) { + this.suggestMode = suggestMode; + return this; + } + + /** + * Sets how similar the suggested terms at least need to be compared to + * the original suggest text tokens. A value between 0 and 1 can be + * specified. This value will be compared to the string distance result + * of each candidate spelling correction. + *

+ * Default is 0.5 + */ + public DirectCandidateGeneratorBuilder accuracy(float accuracy) { + this.accuracy = accuracy; + return this; + } + + /** + * Sets the maximum suggestions to be returned per suggest text term. + */ + public DirectCandidateGeneratorBuilder size(int size) { + if (size <= 0) { + throw new IllegalArgumentException("Size must be positive"); + } + this.size = size; + return this; + } + + /** + * Sets how to sort the suggest terms per suggest text token. Two + * possible values: + *

    + *
  1. score - Sort should first be based on score, then + * document frequency and then the term itself. + *
  2. frequency - Sort should first be based on document + * frequency, then score and then the term itself. + *
+ *

+ * What the score is depends on the suggester being used. + */ + public DirectCandidateGeneratorBuilder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Sets what string distance implementation to use for comparing how + * similar suggested terms are. Four possible values can be specified: + *

    + *
  1. internal - This is the default and is based on + * damerau_levenshtein, but highly optimized for comparing + * string distance for terms inside the index. + *
  2. damerau_levenshtein - String distance algorithm + * based on Damerau-Levenshtein algorithm. + *
  3. levenstein - String distance algorithm based on + * Levenstein edit distance algorithm. + *
  4. jarowinkler - String distance algorithm based on + * Jaro-Winkler algorithm. + *
  5. ngram - String distance algorithm based on character + * n-grams. + *
+ */ + public DirectCandidateGeneratorBuilder stringDistance(String stringDistance) { + this.stringDistance = stringDistance; + return this; + } + + /** + * Sets the maximum edit distance candidate suggestions can have in + * order to be considered as a suggestion. Can only be a value between 1 + * and 2. Any other value result in an bad request error being thrown. + * Defaults to 2. + */ + public DirectCandidateGeneratorBuilder maxEdits(Integer maxEdits) { + if (maxEdits < 1 || maxEdits > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) { + throw new IllegalArgumentException("Illegal max_edits value " + maxEdits); + } + this.maxEdits = maxEdits; + return this; + } + + /** + * A factor that is used to multiply with the size in order to inspect + * more candidate suggestions. Can improve accuracy at the cost of + * performance. Defaults to 5. + */ + public DirectCandidateGeneratorBuilder maxInspections(Integer maxInspections) { + this.maxInspections = maxInspections; + return this; + } + + /** + * Sets a maximum threshold in number of documents a suggest text token + * can exist in order to be corrected. Can be a relative percentage + * number (e.g 0.4) or an absolute number to represent document + * frequencies. If an value higher than 1 is specified then fractional + * can not be specified. Defaults to 0.01. + *

+ * This can be used to exclude high frequency terms from being + * suggested. High frequency terms are usually spelled correctly on top + * of this this also improves the suggest performance. + */ + public DirectCandidateGeneratorBuilder maxTermFreq(float maxTermFreq) { + this.maxTermFreq = maxTermFreq; + return this; + } + + /** + * Sets the number of minimal prefix characters that must match in order + * be a candidate suggestion. Defaults to 1. Increasing this number + * improves suggest performance. Usually misspellings don't occur in the + * beginning of terms. + */ + public DirectCandidateGeneratorBuilder prefixLength(int prefixLength) { + this.prefixLength = prefixLength; + return this; + } + + /** + * The minimum length a suggest text term must have in order to be + * corrected. Defaults to 4. + */ + public DirectCandidateGeneratorBuilder minWordLength(int minWordLength) { + this.minWordLength = minWordLength; + return this; + } + + /** + * Sets a minimal threshold in number of documents a suggested term + * should appear in. This can be specified as an absolute number or as a + * relative percentage of number of documents. This can improve quality + * by only suggesting high frequency terms. Defaults to 0f and is not + * enabled. If a value higher than 1 is specified then the number cannot + * be fractional. + */ + public DirectCandidateGeneratorBuilder minDocFreq(float minDocFreq) { + this.minDocFreq = minDocFreq; + return this; + } + + /** + * Sets a filter (analyzer) that is applied to each of the tokens passed to this candidate generator. + * This filter is applied to the original token before candidates are generated. + */ + public DirectCandidateGeneratorBuilder preFilter(String preFilter) { + this.preFilter = preFilter; + return this; + } + + /** + * Sets a filter (analyzer) that is applied to each of the generated tokens + * before they are passed to the actual phrase scorer. + */ + public DirectCandidateGeneratorBuilder postFilter(String postFilter) { + this.postFilter = postFilter; + return this; + } + + /** + * gets the type identifier of this {@link CandidateGenerator} + */ + @Override + public String getType() { + return TYPE; + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); + outputFieldIfNotNull(field, FIELDNAME_FIELD, builder); + outputFieldIfNotNull(accuracy, ACCURACY_FIELD, builder); + outputFieldIfNotNull(maxEdits, MAX_EDITS_FIELD, builder); + outputFieldIfNotNull(maxInspections, MAX_INSPECTIONS_FIELD, builder); + outputFieldIfNotNull(maxTermFreq, MAX_TERM_FREQ_FIELD, builder); + outputFieldIfNotNull(minWordLength, MIN_WORD_LENGTH_FIELD, builder); + outputFieldIfNotNull(minDocFreq, MIN_DOC_FREQ_FIELD, builder); + outputFieldIfNotNull(preFilter, PREFILTER_FIELD, builder); + outputFieldIfNotNull(prefixLength, PREFIX_LENGTH_FIELD, builder); + outputFieldIfNotNull(postFilter, POSTFILTER_FIELD, builder); + outputFieldIfNotNull(suggestMode, SUGGESTMODE_FIELD, builder); + outputFieldIfNotNull(size, SIZE_FIELD, builder); + outputFieldIfNotNull(sort, SORT_FIELD, builder); + outputFieldIfNotNull(stringDistance, STRING_DISTANCE_FIELD, builder); + builder.endObject(); + return builder; + } + + private static void outputFieldIfNotNull(T value, ParseField field, XContentBuilder builder) throws IOException { + if (value != null) { + builder.field(field.getPreferredName(), value); + } + } + + private static ObjectParser, DirectCandidateGeneratorBuilder>, QueryParseContext> PARSER = new ObjectParser<>(TYPE); + + static { + PARSER.declareString((tp, s) -> tp.v1().add(s), FIELDNAME_FIELD); + PARSER.declareString((tp, s) -> tp.v2().preFilter(s), PREFILTER_FIELD); + PARSER.declareString((tp, s) -> tp.v2().postFilter(s), POSTFILTER_FIELD); + PARSER.declareString((tp, s) -> tp.v2().suggestMode(s), SUGGESTMODE_FIELD); + PARSER.declareFloat((tp, f) -> tp.v2().minDocFreq(f), MIN_DOC_FREQ_FIELD); + PARSER.declareFloat((tp, f) -> tp.v2().accuracy(f), ACCURACY_FIELD); + PARSER.declareInt((tp, i) -> tp.v2().size(i), SIZE_FIELD); + PARSER.declareString((tp, s) -> tp.v2().sort(s), SORT_FIELD); + PARSER.declareString((tp, s) -> tp.v2().stringDistance(s), STRING_DISTANCE_FIELD); + PARSER.declareInt((tp, i) -> tp.v2().maxInspections(i), MAX_INSPECTIONS_FIELD); + PARSER.declareFloat((tp, f) -> tp.v2().maxTermFreq(f), MAX_TERM_FREQ_FIELD); + PARSER.declareInt((tp, i) -> tp.v2().maxEdits(i), MAX_EDITS_FIELD); + PARSER.declareInt((tp, i) -> tp.v2().minWordLength(i), MIN_WORD_LENGTH_FIELD); + PARSER.declareInt((tp, i) -> tp.v2().prefixLength(i), PREFIX_LENGTH_FIELD); + } + + @Override + public DirectCandidateGeneratorBuilder fromXContent(QueryParseContext parseContext) throws IOException { + DirectCandidateGeneratorBuilder tempGenerator = new DirectCandidateGeneratorBuilder("_na_"); + Set tmpFieldName = new HashSet<>(1); // bucket for the field + // name, needed as + // constructor arg + // later + PARSER.parse(parseContext.parser(), + new Tuple, DirectCandidateGeneratorBuilder>(tmpFieldName, tempGenerator)); + if (tmpFieldName.size() != 1) { + throw new IllegalArgumentException("[" + TYPE + "] expects exactly one field parameter, but found " + tmpFieldName); + } + return replaceField(tmpFieldName.iterator().next(), tempGenerator); + } + + public PhraseSuggestionContext.DirectCandidateGenerator build(QueryShardContext context) throws IOException { + MapperService mapperService = context.getMapperService(); + PhraseSuggestionContext.DirectCandidateGenerator generator = new PhraseSuggestionContext.DirectCandidateGenerator(); + generator.setField(this.field); + transferIfNotNull(this.size, generator::size); + if (this.preFilter != null) { + generator.preFilter(mapperService.analysisService().analyzer(this.preFilter)); + if (generator.preFilter() == null) { + throw new IllegalArgumentException("Analyzer [" + this.preFilter + "] doesn't exists"); + } + } + if (this.postFilter != null) { + generator.postFilter(mapperService.analysisService().analyzer(this.postFilter)); + if (generator.postFilter() == null) { + throw new IllegalArgumentException("Analyzer [" + this.postFilter + "] doesn't exists"); + } + } + transferIfNotNull(this.accuracy, generator::accuracy); + if (this.suggestMode != null) { + generator.suggestMode(SuggestUtils.resolveSuggestMode(this.suggestMode)); + } + if (this.sort != null) { + generator.sort(SuggestUtils.resolveSort(this.sort)); + } + if (this.stringDistance != null) { + generator.stringDistance(SuggestUtils.resolveDistance(this.stringDistance)); + } + transferIfNotNull(this.maxEdits, generator::maxEdits); + if (generator.maxEdits() < 1 || generator.maxEdits() > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) { + throw new IllegalArgumentException("Illegal max_edits value " + generator.maxEdits()); + } + transferIfNotNull(this.maxInspections, generator::maxInspections); + transferIfNotNull(this.maxTermFreq, generator::maxTermFreq); + transferIfNotNull(this.prefixLength, generator::prefixLength); + transferIfNotNull(this.minWordLength, generator::minQueryLength); + transferIfNotNull(this.minDocFreq, generator::minDocFreq); + return generator; + } + + private static void transferIfNotNull(T value, Consumer consumer) { + if (value != null) { + consumer.accept(value); + } + } + + @Override + public final String toString() { + try { + XContentBuilder builder = XContentFactory.jsonBuilder(); + builder.prettyPrint(); + toXContent(builder, EMPTY_PARAMS); + return builder.string(); + } catch (Exception e) { + return "{ \"error\" : \"" + ExceptionsHelper.detailedMessage(e) + "\"}"; + } + } + + @Override + public DirectCandidateGeneratorBuilder readFrom(StreamInput in) throws IOException { + DirectCandidateGeneratorBuilder cg = new DirectCandidateGeneratorBuilder(in.readString()); + cg.suggestMode = in.readOptionalString(); + if (in.readBoolean()) { + cg.accuracy = in.readFloat(); + } + cg.size = in.readOptionalVInt(); + cg.sort = in.readOptionalString(); + cg.stringDistance = in.readOptionalString(); + cg.maxEdits = in.readOptionalVInt(); + cg.maxInspections = in.readOptionalVInt(); + if (in.readBoolean()) { + cg.maxTermFreq = in.readFloat(); + } + cg.prefixLength = in.readOptionalVInt(); + cg.minWordLength = in.readOptionalVInt(); + if (in.readBoolean()) { + cg.minDocFreq = in.readFloat(); + } + cg.preFilter = in.readOptionalString(); + cg.postFilter = in.readOptionalString(); + return cg; + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeString(field); + out.writeOptionalString(suggestMode); + out.writeBoolean(accuracy != null); + if (accuracy != null) { + out.writeFloat(accuracy); + } + out.writeOptionalVInt(size); + out.writeOptionalString(sort); + out.writeOptionalString(stringDistance); + out.writeOptionalVInt(maxEdits); + out.writeOptionalVInt(maxInspections); + out.writeBoolean(maxTermFreq != null); + if (maxTermFreq != null) { + out.writeFloat(maxTermFreq); + } + out.writeOptionalVInt(prefixLength); + out.writeOptionalVInt(minWordLength); + out.writeBoolean(minDocFreq != null); + if (minDocFreq != null) { + out.writeFloat(minDocFreq); + } + out.writeOptionalString(preFilter); + out.writeOptionalString(postFilter); + } + + @Override + public final int hashCode() { + return Objects.hash(field, preFilter, postFilter, suggestMode, accuracy, + size, sort, stringDistance, maxEdits, maxInspections, + maxTermFreq, prefixLength, minWordLength, minDocFreq); + } + + @Override + public final boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + DirectCandidateGeneratorBuilder other = (DirectCandidateGeneratorBuilder) obj; + return Objects.equals(field, other.field) && + Objects.equals(preFilter, other.preFilter) && + Objects.equals(postFilter, other.postFilter) && + Objects.equals(suggestMode, other.suggestMode) && + Objects.equals(accuracy, other.accuracy) && + Objects.equals(size, other.size) && + Objects.equals(sort, other.sort) && + Objects.equals(stringDistance, other.stringDistance) && + Objects.equals(maxEdits, other.maxEdits) && + Objects.equals(maxInspections, other.maxInspections) && + Objects.equals(maxTermFreq, other.maxTermFreq) && + Objects.equals(prefixLength, other.prefixLength) && + Objects.equals(minWordLength, other.minWordLength) && + Objects.equals(minDocFreq, other.minDocFreq); + } +} \ No newline at end of file diff --git a/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java b/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java index ee0dc1b0b9f..fc60fc6fc80 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestParser.java @@ -98,18 +98,10 @@ public final class PhraseSuggestParser implements SuggestContextParser { } } } else if (token == Token.START_ARRAY) { - if ("direct_generator".equals(fieldName) || "directGenerator".equals(fieldName)) { + if (parseFieldMatcher.match(fieldName, DirectCandidateGeneratorBuilder.DIRECT_GENERATOR_FIELD)) { // for now we only have a single type of generators while ((token = parser.nextToken()) == Token.START_OBJECT) { - PhraseSuggestionContext.DirectCandidateGenerator generator = new PhraseSuggestionContext.DirectCandidateGenerator(); - while ((token = parser.nextToken()) != Token.END_OBJECT) { - if (token == XContentParser.Token.FIELD_NAME) { - fieldName = parser.currentName(); - } - if (token.isValue()) { - parseCandidateGenerator(parser, mapperService, fieldName, generator, parseFieldMatcher); - } - } + PhraseSuggestionContext.DirectCandidateGenerator generator = parseCandidateGenerator(parser, mapperService, parseFieldMatcher); verifyGenerator(generator); suggestion.addGenerator(generator); } @@ -323,34 +315,44 @@ public final class PhraseSuggestParser implements SuggestContextParser { } } - private void parseCandidateGenerator(XContentParser parser, MapperService mapperService, String fieldName, - PhraseSuggestionContext.DirectCandidateGenerator generator, ParseFieldMatcher parseFieldMatcher) throws IOException { - if (!SuggestUtils.parseDirectSpellcheckerSettings(parser, fieldName, generator, parseFieldMatcher)) { - if ("field".equals(fieldName)) { - generator.setField(parser.text()); - if (mapperService.fullName(generator.field()) == null) { - throw new IllegalArgumentException("No mapping found for field [" + generator.field() + "]"); + static PhraseSuggestionContext.DirectCandidateGenerator parseCandidateGenerator(XContentParser parser, MapperService mapperService, + ParseFieldMatcher parseFieldMatcher) throws IOException { + XContentParser.Token token; + String fieldName = null; + PhraseSuggestionContext.DirectCandidateGenerator generator = new PhraseSuggestionContext.DirectCandidateGenerator(); + while ((token = parser.nextToken()) != Token.END_OBJECT) { + if (token == XContentParser.Token.FIELD_NAME) { + fieldName = parser.currentName(); + } + if (token.isValue()) { + if (!SuggestUtils.parseDirectSpellcheckerSettings(parser, fieldName, generator, parseFieldMatcher)) { + if ("field".equals(fieldName)) { + generator.setField(parser.text()); + if (mapperService.fullName(generator.field()) == null) { + throw new IllegalArgumentException("No mapping found for field [" + generator.field() + "]"); + } + } else if ("size".equals(fieldName)) { + generator.size(parser.intValue()); + } else if ("pre_filter".equals(fieldName) || "preFilter".equals(fieldName)) { + String analyzerName = parser.text(); + Analyzer analyzer = mapperService.analysisService().analyzer(analyzerName); + if (analyzer == null) { + throw new IllegalArgumentException("Analyzer [" + analyzerName + "] doesn't exists"); + } + generator.preFilter(analyzer); + } else if ("post_filter".equals(fieldName) || "postFilter".equals(fieldName)) { + String analyzerName = parser.text(); + Analyzer analyzer = mapperService.analysisService().analyzer(analyzerName); + if (analyzer == null) { + throw new IllegalArgumentException("Analyzer [" + analyzerName + "] doesn't exists"); + } + generator.postFilter(analyzer); + } else { + throw new IllegalArgumentException("CandidateGenerator doesn't support [" + fieldName + "]"); + } } - } else if ("size".equals(fieldName)) { - generator.size(parser.intValue()); - } else if ("pre_filter".equals(fieldName) || "preFilter".equals(fieldName)) { - String analyzerName = parser.text(); - Analyzer analyzer = mapperService.analysisService().analyzer(analyzerName); - if (analyzer == null) { - throw new IllegalArgumentException("Analyzer [" + analyzerName + "] doesn't exists"); - } - generator.preFilter(analyzer); - } else if ("post_filter".equals(fieldName) || "postFilter".equals(fieldName)) { - String analyzerName = parser.text(); - Analyzer analyzer = mapperService.analysisService().analyzer(analyzerName); - if (analyzer == null) { - throw new IllegalArgumentException("Analyzer [" + analyzerName + "] doesn't exists"); - } - generator.postFilter(analyzer); - } else { - throw new IllegalArgumentException("CandidateGenerator doesn't support [" + fieldName + "]"); } } + return generator; } - } diff --git a/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java b/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java index 0e1fec6c7b2..b72cd41ea73 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/phrase/PhraseSuggestionBuilder.java @@ -278,13 +278,13 @@ public final class PhraseSuggestionBuilder extends SuggestionBuilder - *

  • missing - Only suggest terms in the suggest text - * that aren't in the index. This is the default. - *
  • popular - Only suggest terms that occur in more docs - * then the original suggest text term. - *
  • always - Suggest any matching suggest terms based on - * tokens in the suggest text. - * - */ - public DirectCandidateGenerator suggestMode(String suggestMode) { - this.suggestMode = suggestMode; - return this; - } - - /** - * Sets how similar the suggested terms at least need to be compared to - * the original suggest text tokens. A value between 0 and 1 can be - * specified. This value will be compared to the string distance result - * of each candidate spelling correction. - *

    - * Default is 0.5 - */ - public DirectCandidateGenerator accuracy(float accuracy) { - this.accuracy = accuracy; - return this; - } - - /** - * Sets the maximum suggestions to be returned per suggest text term. - */ - public DirectCandidateGenerator size(int size) { - if (size <= 0) { - throw new IllegalArgumentException("Size must be positive"); - } - this.size = size; - return this; - } - - /** - * Sets how to sort the suggest terms per suggest text token. Two - * possible values: - *

      - *
    1. score - Sort should first be based on score, then - * document frequency and then the term itself. - *
    2. frequency - Sort should first be based on document - * frequency, then scotr and then the term itself. - *
    - *

    - * What the score is depends on the suggester being used. - */ - public DirectCandidateGenerator sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Sets what string distance implementation to use for comparing how - * similar suggested terms are. Four possible values can be specified: - *

      - *
    1. internal - This is the default and is based on - * damerau_levenshtein, but highly optimized for comparing - * string distance for terms inside the index. - *
    2. damerau_levenshtein - String distance algorithm - * based on Damerau-Levenshtein algorithm. - *
    3. levenstein - String distance algorithm based on - * Levenstein edit distance algorithm. - *
    4. jarowinkler - String distance algorithm based on - * Jaro-Winkler algorithm. - *
    5. ngram - String distance algorithm based on character - * n-grams. - *
    - */ - public DirectCandidateGenerator stringDistance(String stringDistance) { - this.stringDistance = stringDistance; - return this; - } - - /** - * Sets the maximum edit distance candidate suggestions can have in - * order to be considered as a suggestion. Can only be a value between 1 - * and 2. Any other value result in an bad request error being thrown. - * Defaults to 2. - */ - public DirectCandidateGenerator maxEdits(Integer maxEdits) { - this.maxEdits = maxEdits; - return this; - } - - /** - * A factor that is used to multiply with the size in order to inspect - * more candidate suggestions. Can improve accuracy at the cost of - * performance. Defaults to 5. - */ - public DirectCandidateGenerator maxInspections(Integer maxInspections) { - this.maxInspections = maxInspections; - return this; - } - - /** - * Sets a maximum threshold in number of documents a suggest text token - * can exist in order to be corrected. Can be a relative percentage - * number (e.g 0.4) or an absolute number to represent document - * frequencies. If an value higher than 1 is specified then fractional - * can not be specified. Defaults to 0.01. - *

    - * This can be used to exclude high frequency terms from being - * suggested. High frequency terms are usually spelled correctly on top - * of this this also improves the suggest performance. - */ - public DirectCandidateGenerator maxTermFreq(float maxTermFreq) { - this.maxTermFreq = maxTermFreq; - return this; - } - - /** - * Sets the number of minimal prefix characters that must match in order - * be a candidate suggestion. Defaults to 1. Increasing this number - * improves suggest performance. Usually misspellings don't occur in the - * beginning of terms. - */ - public DirectCandidateGenerator prefixLength(int prefixLength) { - this.prefixLength = prefixLength; - return this; - } - - /** - * The minimum length a suggest text term must have in order to be - * corrected. Defaults to 4. - */ - public DirectCandidateGenerator minWordLength(int minWordLength) { - this.minWordLength = minWordLength; - return this; - } - - /** - * Sets a minimal threshold in number of documents a suggested term - * should appear in. This can be specified as an absolute number or as a - * relative percentage of number of documents. This can improve quality - * by only suggesting high frequency terms. Defaults to 0f and is not - * enabled. If a value higher than 1 is specified then the number cannot - * be fractional. - */ - public DirectCandidateGenerator minDocFreq(float minDocFreq) { - this.minDocFreq = minDocFreq; - return this; - } - - /** - * Sets a filter (analyzer) that is applied to each of the tokens passed to this candidate generator. - * This filter is applied to the original token before candidates are generated. - */ - public DirectCandidateGenerator preFilter(String preFilter) { - this.preFilter = preFilter; - return this; - } - - /** - * Sets a filter (analyzer) that is applied to each of the generated tokens - * before they are passed to the actual phrase scorer. - */ - public DirectCandidateGenerator postFilter(String postFilter) { - this.postFilter = postFilter; - return this; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - if (field != null) { - builder.field("field", field); - } - if (suggestMode != null) { - builder.field("suggest_mode", suggestMode); - } - if (accuracy != null) { - builder.field("accuracy", accuracy); - } - if (size != null) { - builder.field("size", size); - } - if (sort != null) { - builder.field("sort", sort); - } - if (stringDistance != null) { - builder.field("string_distance", stringDistance); - } - if (maxEdits != null) { - builder.field("max_edits", maxEdits); - } - if (maxInspections != null) { - builder.field("max_inspections", maxInspections); - } - if (maxTermFreq != null) { - builder.field("max_term_freq", maxTermFreq); - } - if (prefixLength != null) { - builder.field("prefix_length", prefixLength); - } - if (minWordLength != null) { - builder.field("min_word_length", minWordLength); - } - if (minDocFreq != null) { - builder.field("min_doc_freq", minDocFreq); - } - if (preFilter != null) { - builder.field("pre_filter", preFilter); - } - if (postFilter != null) { - builder.field("post_filter", postFilter); - } - builder.endObject(); - return builder; - } - - } - } diff --git a/core/src/main/java/org/elasticsearch/transport/TransportSettings.java b/core/src/main/java/org/elasticsearch/transport/TransportSettings.java index 468e9b1821e..affb7e535fb 100644 --- a/core/src/main/java/org/elasticsearch/transport/TransportSettings.java +++ b/core/src/main/java/org/elasticsearch/transport/TransportSettings.java @@ -21,13 +21,21 @@ package org.elasticsearch.transport; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; +import java.util.List; + +import static java.util.Collections.emptyList; + /** * a collection of settings related to transport components, which are also needed in org.elasticsearch.bootstrap.Security * This class should only contain static code which is *safe* to load before the security manager is enforced. */ final public class TransportSettings { + public static final Setting> HOST = Setting.listSetting("transport.host", emptyList(), s -> s, false, Setting.Scope.CLUSTER); + public static final Setting> PUBLISH_HOST = Setting.listSetting("transport.publish_host", HOST, s -> s, false, Setting.Scope.CLUSTER); + public static final Setting> BIND_HOST = Setting.listSetting("transport.bind_host", HOST, s -> s, false, Setting.Scope.CLUSTER); public static final Setting PORT = new Setting<>("transport.tcp.port", "9300-9400", s -> s, false, Setting.Scope.CLUSTER); + public static final Setting PUBLISH_PORT = Setting.intSetting("transport.publish_port", -1, -1, false, Setting.Scope.CLUSTER); public static final String DEFAULT_PROFILE = "default"; public static final Setting TRANSPORT_PROFILES_SETTING = Setting.groupSetting("transport.profiles.", true, Setting.Scope.CLUSTER); diff --git a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java index a1ec7b23805..99fbac17b69 100644 --- a/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/netty/NettyTransport.java @@ -119,12 +119,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static java.util.Collections.unmodifiableMap; -import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_BLOCKING_SERVER; -import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_KEEP_ALIVE; -import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_NO_DELAY; -import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_RECEIVE_BUFFER_SIZE; -import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_REUSE_ADDRESS; -import static org.elasticsearch.common.network.NetworkService.TcpSettings.TCP_SEND_BUFFER_SIZE; import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.elasticsearch.common.transport.NetworkExceptionHelper.isCloseConnectionException; import static org.elasticsearch.common.transport.NetworkExceptionHelper.isConnectException; @@ -158,8 +152,16 @@ public class NettyTransport extends AbstractLifecycleComponent implem public static final Setting CONNECTIONS_PER_NODE_PING = Setting.intSetting("transport.connections_per_node.ping", 1, 1, false, Setting.Scope.CLUSTER); // the scheduled internal ping interval setting, defaults to disabled (-1) public static final Setting PING_SCHEDULE = Setting.timeSetting("transport.ping_schedule", TimeValue.timeValueSeconds(-1), false, Setting.Scope.CLUSTER); - public static final Setting TCP_BLOCKING_CLIENT = Setting.boolSetting("transport." + TcpSettings.TCP_BLOCKING_CLIENT.getKey(), TcpSettings.TCP_BLOCKING_CLIENT, false, Setting.Scope.CLUSTER); - public static final Setting TCP_CONNECT_TIMEOUT = Setting.timeSetting("transport." + TcpSettings.TCP_CONNECT_TIMEOUT.getKey(), TcpSettings.TCP_CONNECT_TIMEOUT, false, Setting.Scope.CLUSTER); + public static final Setting TCP_BLOCKING_CLIENT = Setting.boolSetting("transport.tcp.blocking_client", TcpSettings.TCP_BLOCKING_CLIENT, false, Setting.Scope.CLUSTER); + public static final Setting TCP_CONNECT_TIMEOUT = Setting.timeSetting("transport.tcp.connect_timeout", TcpSettings.TCP_CONNECT_TIMEOUT, false, Setting.Scope.CLUSTER); + public static final Setting TCP_NO_DELAY = Setting.boolSetting("transport.tcp_no_delay", TcpSettings.TCP_NO_DELAY, false, Setting.Scope.CLUSTER); + public static final Setting TCP_KEEP_ALIVE = Setting.boolSetting("transport.tcp.keep_alive", TcpSettings.TCP_KEEP_ALIVE, false, Setting.Scope.CLUSTER); + public static final Setting TCP_BLOCKING_SERVER = Setting.boolSetting("transport.tcp.blocking_server", TcpSettings.TCP_BLOCKING_SERVER, false, Setting.Scope.CLUSTER); + public static final Setting TCP_REUSE_ADDRESS = Setting.boolSetting("transport.tcp.reuse_address", TcpSettings.TCP_REUSE_ADDRESS, false, Setting.Scope.CLUSTER); + + public static final Setting TCP_SEND_BUFFER_SIZE = Setting.byteSizeSetting("transport.tcp.send_buffer_size", TcpSettings.TCP_SEND_BUFFER_SIZE, false, Setting.Scope.CLUSTER); + public static final Setting TCP_RECEIVE_BUFFER_SIZE = Setting.byteSizeSetting("transport.tcp.receive_buffer_size", TcpSettings.TCP_RECEIVE_BUFFER_SIZE, false, Setting.Scope.CLUSTER); + public static final Setting NETTY_MAX_CUMULATION_BUFFER_CAPACITY = Setting.byteSizeSetting("transport.netty.max_cumulation_buffer_capacity", new ByteSizeValue(-1), false, Setting.Scope.CLUSTER); public static final Setting NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS = Setting.intSetting("transport.netty.max_composite_buffer_components", -1, -1, false, Setting.Scope.CLUSTER); @@ -179,7 +181,6 @@ public class NettyTransport extends AbstractLifecycleComponent implem public static final Setting NETTY_RECEIVE_PREDICTOR_MAX = Setting.byteSizeSetting("transport.netty.receive_predictor_max", NETTY_RECEIVE_PREDICTOR_SIZE, false, Setting.Scope.CLUSTER); public static final Setting NETTY_BOSS_COUNT = Setting.intSetting("transport.netty.boss_count", 1, 1, false, Setting.Scope.CLUSTER); - public static final Setting NETWORK_SERVER = Setting.boolSetting("network.server", true, false, Setting.Scope.CLUSTER); protected final NetworkService networkService; protected final Version version; @@ -284,7 +285,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem boolean success = false; try { clientBootstrap = createClientBootstrap(); - if (NETWORK_SERVER.get(settings)) { + if (NetworkService.NETWORK_SERVER.get(settings)) { final OpenChannelsHandler openChannels = new OpenChannelsHandler(logger); this.serverOpenChannels = openChannels; @@ -356,25 +357,25 @@ public class NettyTransport extends AbstractLifecycleComponent implem clientBootstrap.setPipelineFactory(configureClientChannelPipelineFactory()); clientBootstrap.setOption("connectTimeoutMillis", connectTimeout.millis()); - boolean tcpNoDelay = settings.getAsBoolean("transport.netty.tcp_no_delay", TCP_NO_DELAY.get(settings)); + boolean tcpNoDelay = TCP_NO_DELAY.get(settings); clientBootstrap.setOption("tcpNoDelay", tcpNoDelay); - boolean tcpKeepAlive = settings.getAsBoolean("transport.netty.tcp_keep_alive", TCP_KEEP_ALIVE.get(settings)); + boolean tcpKeepAlive = TCP_KEEP_ALIVE.get(settings); clientBootstrap.setOption("keepAlive", tcpKeepAlive); - ByteSizeValue tcpSendBufferSize = settings.getAsBytesSize("transport.netty.tcp_send_buffer_size", TCP_SEND_BUFFER_SIZE.get(settings)); + ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings); if (tcpSendBufferSize.bytes() > 0) { clientBootstrap.setOption("sendBufferSize", tcpSendBufferSize.bytes()); } - ByteSizeValue tcpReceiveBufferSize = settings.getAsBytesSize("transport.netty.tcp_receive_buffer_size", TCP_RECEIVE_BUFFER_SIZE.get(settings)); + ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings); if (tcpReceiveBufferSize.bytes() > 0) { clientBootstrap.setOption("receiveBufferSize", tcpReceiveBufferSize.bytes()); } clientBootstrap.setOption("receiveBufferSizePredictorFactory", receiveBufferSizePredictorFactory); - boolean reuseAddress = settings.getAsBoolean("transport.netty.reuse_address", TCP_REUSE_ADDRESS.get(settings)); + boolean reuseAddress = TCP_REUSE_ADDRESS.get(settings); clientBootstrap.setOption("reuseAddress", reuseAddress); return clientBootstrap; @@ -383,31 +384,31 @@ public class NettyTransport extends AbstractLifecycleComponent implem private Settings createFallbackSettings() { Settings.Builder fallbackSettingsBuilder = settingsBuilder(); - String fallbackBindHost = settings.get("transport.netty.bind_host", settings.get("transport.bind_host", settings.get("transport.host"))); - if (fallbackBindHost != null) { - fallbackSettingsBuilder.put("bind_host", fallbackBindHost); + List fallbackBindHost = TransportSettings.BIND_HOST.get(settings); + if (fallbackBindHost.isEmpty() == false) { + fallbackSettingsBuilder.putArray("bind_host", fallbackBindHost); } - String fallbackPublishHost = settings.get("transport.netty.publish_host", settings.get("transport.publish_host", settings.get("transport.host"))); - if (fallbackPublishHost != null) { - fallbackSettingsBuilder.put("publish_host", fallbackPublishHost); + List fallbackPublishHost = TransportSettings.PUBLISH_HOST.get(settings); + if (fallbackPublishHost.isEmpty() == false) { + fallbackSettingsBuilder.putArray("publish_host", fallbackPublishHost); } - boolean fallbackTcpNoDelay = settings.getAsBoolean("transport.netty.tcp_no_delay", TCP_NO_DELAY.get(settings)); + boolean fallbackTcpNoDelay = settings.getAsBoolean("transport.netty.tcp_no_delay", TcpSettings.TCP_NO_DELAY.get(settings)); fallbackSettingsBuilder.put("tcp_no_delay", fallbackTcpNoDelay); - boolean fallbackTcpKeepAlive = settings.getAsBoolean("transport.netty.tcp_keep_alive", TCP_KEEP_ALIVE.get(settings)); + boolean fallbackTcpKeepAlive = settings.getAsBoolean("transport.netty.tcp_keep_alive", TcpSettings.TCP_KEEP_ALIVE.get(settings)); fallbackSettingsBuilder.put("tcp_keep_alive", fallbackTcpKeepAlive); - boolean fallbackReuseAddress = settings.getAsBoolean("transport.netty.reuse_address", TCP_REUSE_ADDRESS.get(settings)); + boolean fallbackReuseAddress = settings.getAsBoolean("transport.netty.reuse_address", TcpSettings.TCP_REUSE_ADDRESS.get(settings)); fallbackSettingsBuilder.put("reuse_address", fallbackReuseAddress); - ByteSizeValue fallbackTcpSendBufferSize = settings.getAsBytesSize("transport.netty.tcp_send_buffer_size", TCP_SEND_BUFFER_SIZE.get(settings)); + ByteSizeValue fallbackTcpSendBufferSize = settings.getAsBytesSize("transport.netty.tcp_send_buffer_size", TcpSettings.TCP_SEND_BUFFER_SIZE.get(settings)); if (fallbackTcpSendBufferSize.bytes() >= 0) { fallbackSettingsBuilder.put("tcp_send_buffer_size", fallbackTcpSendBufferSize); } - ByteSizeValue fallbackTcpBufferSize = settings.getAsBytesSize("transport.netty.tcp_receive_buffer_size", TCP_RECEIVE_BUFFER_SIZE.get(settings)); + ByteSizeValue fallbackTcpBufferSize = settings.getAsBytesSize("transport.netty.tcp_receive_buffer_size", TcpSettings.TCP_RECEIVE_BUFFER_SIZE.get(settings)); if (fallbackTcpBufferSize.bytes() >= 0) { fallbackSettingsBuilder.put("tcp_receive_buffer_size", fallbackTcpBufferSize); } @@ -495,7 +496,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem final String[] publishHosts; if (TransportSettings.DEFAULT_PROFILE.equals(name)) { - publishHosts = settings.getAsArray("transport.netty.publish_host", settings.getAsArray("transport.publish_host", settings.getAsArray("transport.host", null))); + publishHosts = TransportSettings.PUBLISH_HOST.get(settings).toArray(Strings.EMPTY_ARRAY); } else { publishHosts = profileSettings.getAsArray("publish_host", boundAddressesHostStrings); } @@ -507,15 +508,15 @@ public class NettyTransport extends AbstractLifecycleComponent implem throw new BindTransportException("Failed to resolve publish address", e); } - Integer publishPort; + int publishPort; if (TransportSettings.DEFAULT_PROFILE.equals(name)) { - publishPort = settings.getAsInt("transport.netty.publish_port", settings.getAsInt("transport.publish_port", null)); + publishPort = TransportSettings.PUBLISH_PORT.get(settings); } else { - publishPort = profileSettings.getAsInt("publish_port", null); + publishPort = profileSettings.getAsInt("publish_port", -1); } // if port not explicitly provided, search for port of address in boundAddresses that matches publishInetAddress - if (publishPort == null) { + if (publishPort < 0) { for (InetSocketAddress boundAddress : boundAddresses) { InetAddress boundInetAddress = boundAddress.getAddress(); if (boundInetAddress.isAnyLocalAddress() || boundInetAddress.equals(publishInetAddress)) { @@ -526,7 +527,7 @@ public class NettyTransport extends AbstractLifecycleComponent implem } // if port still not matches, just take port of first bound address - if (publishPort == null) { + if (publishPort < 0) { // TODO: In case of DEFAULT_PROFILE we should probably fail here, as publish address does not match any bound address // In case of a custom profile, we might use the publish address of the default profile publishPort = boundAddresses.get(0).getPort(); @@ -538,15 +539,15 @@ public class NettyTransport extends AbstractLifecycleComponent implem } private void createServerBootstrap(String name, Settings settings) { - boolean blockingServer = settings.getAsBoolean("transport.tcp.blocking_server", TCP_BLOCKING_SERVER.get(settings)); + boolean blockingServer = TCP_BLOCKING_SERVER.get(settings); String port = settings.get("port"); String bindHost = settings.get("bind_host"); String publishHost = settings.get("publish_host"); String tcpNoDelay = settings.get("tcp_no_delay"); String tcpKeepAlive = settings.get("tcp_keep_alive"); boolean reuseAddress = settings.getAsBoolean("reuse_address", NetworkUtils.defaultReuseAddress()); - ByteSizeValue tcpSendBufferSize = settings.getAsBytesSize("tcp_send_buffer_size", TCP_SEND_BUFFER_SIZE.getDefault(settings)); - ByteSizeValue tcpReceiveBufferSize = settings.getAsBytesSize("tcp_receive_buffer_size", TCP_RECEIVE_BUFFER_SIZE.getDefault(settings)); + ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.getDefault(settings); + ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.getDefault(settings); logger.debug("using profile[{}], worker_count[{}], port[{}], bind_host[{}], publish_host[{}], compress[{}], connect_timeout[{}], connections_per_node[{}/{}/{}/{}/{}], receive_predictor[{}->{}]", name, workerCount, port, bindHost, publishHost, compress, connectTimeout, connectionsPerNodeRecovery, connectionsPerNodeBulk, connectionsPerNodeReg, connectionsPerNodeState, connectionsPerNodePing, receivePredictorMin, receivePredictorMax); diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java index e576f26eb4c..44d35305a60 100644 --- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java +++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java @@ -42,6 +42,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.regex.Regex; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.discovery.DiscoveryModule; @@ -51,12 +52,14 @@ import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.node.Node; import org.elasticsearch.rest.RestStatus; +import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.function.Function; import static java.util.Collections.unmodifiableMap; @@ -84,12 +87,12 @@ public class TribeService extends AbstractLifecycleComponent { public static final ClusterBlock TRIBE_WRITE_BLOCK = new ClusterBlock(11, "tribe node, write not allowed", false, false, RestStatus.BAD_REQUEST, EnumSet.of(ClusterBlockLevel.WRITE)); public static Settings processSettings(Settings settings) { - if (settings.get(TRIBE_NAME) != null) { + if (TRIBE_NAME_SETTING.exists(settings)) { // if its a node client started by this service as tribe, remove any tribe group setting // to avoid recursive configuration Settings.Builder sb = Settings.builder().put(settings); for (String s : settings.getAsMap().keySet()) { - if (s.startsWith("tribe.") && !s.equals(TRIBE_NAME)) { + if (s.startsWith("tribe.") && !s.equals(TRIBE_NAME_SETTING.getKey())) { sb.remove(s); } } @@ -111,14 +114,26 @@ public class TribeService extends AbstractLifecycleComponent { return sb.build(); } - public static final String TRIBE_NAME = "tribe.name"; - + private static final Setting TRIBE_NAME_SETTING = Setting.simpleString("tribe.name", false, Setting.Scope.CLUSTER); // internal settings only private final ClusterService clusterService; private final String[] blockIndicesWrite; private final String[] blockIndicesRead; private final String[] blockIndicesMetadata; - private static final String ON_CONFLICT_ANY = "any", ON_CONFLICT_DROP = "drop", ON_CONFLICT_PREFER = "prefer_"; + + public static final Setting ON_CONFLICT_SETTING = new Setting<>("tribe.on_conflict", ON_CONFLICT_ANY, (s) -> { + if (ON_CONFLICT_ANY.equals(s) || ON_CONFLICT_DROP.equals(s) || s.startsWith(ON_CONFLICT_PREFER)) { + return s; + } + throw new IllegalArgumentException("Invalid value for [tribe.on_conflict] must be either [any, drop or start with prefer_] but was: " +s); + }, false, Setting.Scope.CLUSTER); + + public static final Setting BLOCKS_METADATA_SETTING = Setting.boolSetting("tribe.blocks.metadata", false, false, Setting.Scope.CLUSTER); + public static final Setting BLOCKS_WRITE_SETTING = Setting.boolSetting("tribe.blocks.write", false, false, Setting.Scope.CLUSTER); + public static final Setting> BLOCKS_WRITE_INDICES_SETTING = Setting.listSetting("tribe.blocks.write.indices", Collections.emptyList(), Function.identity(), false, Setting.Scope.CLUSTER); + public static final Setting> BLOCKS_READ_INDICES_SETTING = Setting.listSetting("tribe.blocks.read.indices", Collections.emptyList(), Function.identity(), false, Setting.Scope.CLUSTER); + public static final Setting> BLOCKS_METADATA_INDICES_SETTING = Setting.listSetting("tribe.blocks.metadata.indices", Collections.emptyList(), Function.identity(), false, Setting.Scope.CLUSTER); + private final String onConflict; private final Set droppedIndices = ConcurrentCollections.newConcurrentSet(); @@ -138,7 +153,7 @@ public class TribeService extends AbstractLifecycleComponent { if (Environment.PATH_CONF_SETTING.exists(settings)) { sb.put(Environment.PATH_CONF_SETTING.getKey(), Environment.PATH_CONF_SETTING.get(settings)); } - sb.put(TRIBE_NAME, entry.getKey()); + sb.put(TRIBE_NAME_SETTING.getKey(), entry.getKey()); if (sb.get("http.enabled") == null) { sb.put("http.enabled", false); } @@ -154,15 +169,15 @@ public class TribeService extends AbstractLifecycleComponent { // master elected in this single tribe node local "cluster" clusterService.removeInitialStateBlock(discoveryService.getNoMasterBlock()); clusterService.removeInitialStateBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK); - if (settings.getAsBoolean("tribe.blocks.write", false)) { + if (BLOCKS_WRITE_SETTING.get(settings)) { clusterService.addInitialStateBlock(TRIBE_WRITE_BLOCK); } - blockIndicesWrite = settings.getAsArray("tribe.blocks.write.indices", Strings.EMPTY_ARRAY); - if (settings.getAsBoolean("tribe.blocks.metadata", false)) { + blockIndicesWrite = BLOCKS_WRITE_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); + if (BLOCKS_METADATA_SETTING.get(settings)) { clusterService.addInitialStateBlock(TRIBE_METADATA_BLOCK); } - blockIndicesMetadata = settings.getAsArray("tribe.blocks.metadata.indices", Strings.EMPTY_ARRAY); - blockIndicesRead = settings.getAsArray("tribe.blocks.read.indices", Strings.EMPTY_ARRAY); + blockIndicesMetadata = BLOCKS_METADATA_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); + blockIndicesRead = BLOCKS_READ_INDICES_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY); for (Node node : nodes) { node.injector().getInstance(ClusterService.class).add(new TribeClusterStateListener(node)); } @@ -171,7 +186,7 @@ public class TribeService extends AbstractLifecycleComponent { this.blockIndicesRead = blockIndicesRead; this.blockIndicesWrite = blockIndicesWrite; - this.onConflict = settings.get("tribe.on_conflict", ON_CONFLICT_ANY); + this.onConflict = ON_CONFLICT_SETTING.get(settings); } @Override @@ -218,7 +233,7 @@ public class TribeService extends AbstractLifecycleComponent { private final TribeNodeClusterStateTaskExecutor executor; TribeClusterStateListener(Node tribeNode) { - String tribeName = tribeNode.settings().get(TRIBE_NAME); + String tribeName = TRIBE_NAME_SETTING.get(tribeNode.settings()); this.tribeName = tribeName; executor = new TribeNodeClusterStateTaskExecutor(tribeName); } @@ -271,7 +286,7 @@ public class TribeService extends AbstractLifecycleComponent { // -- merge nodes // go over existing nodes, and see if they need to be removed for (DiscoveryNode discoNode : currentState.nodes()) { - String markedTribeName = discoNode.attributes().get(TRIBE_NAME); + String markedTribeName = discoNode.attributes().get(TRIBE_NAME_SETTING.getKey()); if (markedTribeName != null && markedTribeName.equals(tribeName)) { if (tribeState.nodes().get(discoNode.id()) == null) { clusterStateChanged = true; @@ -288,7 +303,7 @@ public class TribeService extends AbstractLifecycleComponent { for (ObjectObjectCursor attr : tribe.attributes()) { tribeAttr.put(attr.key, attr.value); } - tribeAttr.put(TRIBE_NAME, tribeName); + tribeAttr.put(TRIBE_NAME_SETTING.getKey(), tribeName); DiscoveryNode discoNode = new DiscoveryNode(tribe.name(), tribe.id(), tribe.getHostName(), tribe.getHostAddress(), tribe.address(), unmodifiableMap(tribeAttr), tribe.version()); clusterStateChanged = true; logger.info("[{}] adding node [{}]", tribeName, discoNode); @@ -302,18 +317,18 @@ public class TribeService extends AbstractLifecycleComponent { RoutingTable.Builder routingTable = RoutingTable.builder(currentState.routingTable()); // go over existing indices, and see if they need to be removed for (IndexMetaData index : currentState.metaData()) { - String markedTribeName = index.getSettings().get(TRIBE_NAME); + String markedTribeName = TRIBE_NAME_SETTING.get(index.getSettings()); if (markedTribeName != null && markedTribeName.equals(tribeName)) { IndexMetaData tribeIndex = tribeState.metaData().index(index.getIndex()); clusterStateChanged = true; if (tribeIndex == null || tribeIndex.getState() == IndexMetaData.State.CLOSE) { - logger.info("[{}] removing index [{}]", tribeName, index.getIndex()); + logger.info("[{}] removing index {}", tribeName, index.getIndex()); removeIndex(blocks, metaData, routingTable, index); } else { // always make sure to update the metadata and routing table, in case // there are changes in them (new mapping, shards moving from initializing to started) routingTable.add(tribeState.routingTable().index(index.getIndex())); - Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME, tribeName).build(); + Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME_SETTING.getKey(), tribeName).build(); metaData.put(IndexMetaData.builder(tribeIndex).settings(tribeSettings)); } } @@ -327,14 +342,14 @@ public class TribeService extends AbstractLifecycleComponent { } final IndexMetaData indexMetaData = currentState.metaData().index(tribeIndex.getIndex()); if (indexMetaData == null) { - if (!droppedIndices.contains(tribeIndex.getIndex())) { + if (!droppedIndices.contains(tribeIndex.getIndex().getName())) { // a new index, add it, and add the tribe name as a setting clusterStateChanged = true; - logger.info("[{}] adding index [{}]", tribeName, tribeIndex.getIndex()); + logger.info("[{}] adding index {}", tribeName, tribeIndex.getIndex()); addNewIndex(tribeState, blocks, metaData, routingTable, tribeIndex); } } else { - String existingFromTribe = indexMetaData.getSettings().get(TRIBE_NAME); + String existingFromTribe = TRIBE_NAME_SETTING.get(indexMetaData.getSettings()); if (!tribeName.equals(existingFromTribe)) { // we have a potential conflict on index names, decide what to do... if (ON_CONFLICT_ANY.equals(onConflict)) { @@ -342,7 +357,7 @@ public class TribeService extends AbstractLifecycleComponent { } else if (ON_CONFLICT_DROP.equals(onConflict)) { // drop the indices, there is a conflict clusterStateChanged = true; - logger.info("[{}] dropping index [{}] due to conflict with [{}]", tribeName, tribeIndex.getIndex(), existingFromTribe); + logger.info("[{}] dropping index {} due to conflict with [{}]", tribeName, tribeIndex.getIndex(), existingFromTribe); removeIndex(blocks, metaData, routingTable, tribeIndex); droppedIndices.add(tribeIndex.getIndex().getName()); } else if (onConflict.startsWith(ON_CONFLICT_PREFER)) { @@ -351,7 +366,7 @@ public class TribeService extends AbstractLifecycleComponent { if (tribeName.equals(preferredTribeName)) { // the new one is hte preferred one, replace... clusterStateChanged = true; - logger.info("[{}] adding index [{}], preferred over [{}]", tribeName, tribeIndex.getIndex(), existingFromTribe); + logger.info("[{}] adding index {}, preferred over [{}]", tribeName, tribeIndex.getIndex(), existingFromTribe); removeIndex(blocks, metaData, routingTable, tribeIndex); addNewIndex(tribeState, blocks, metaData, routingTable, tribeIndex); } // else: either the existing one is the preferred one, or we haven't seen one, carry on @@ -374,7 +389,7 @@ public class TribeService extends AbstractLifecycleComponent { } private void addNewIndex(ClusterState tribeState, ClusterBlocks.Builder blocks, MetaData.Builder metaData, RoutingTable.Builder routingTable, IndexMetaData tribeIndex) { - Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME, tribeName).build(); + Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME_SETTING.getKey(), tribeName).build(); metaData.put(IndexMetaData.builder(tribeIndex).settings(tribeSettings)); routingTable.add(tribeState.routingTable().index(tribeIndex.getIndex())); if (Regex.simpleMatch(blockIndicesMetadata, tribeIndex.getIndex().getName())) { diff --git a/core/src/test/java/org/elasticsearch/ESExceptionTests.java b/core/src/test/java/org/elasticsearch/ESExceptionTests.java index aef38850efc..75a69cd3e55 100644 --- a/core/src/test/java/org/elasticsearch/ESExceptionTests.java +++ b/core/src/test/java/org/elasticsearch/ESExceptionTests.java @@ -286,12 +286,12 @@ public class ESExceptionTests extends ESTestCase { public void testSerializeUnknownException() throws IOException { BytesStreamOutput out = new BytesStreamOutput(); ParsingException ParsingException = new ParsingException(1, 2, "foobar", null); - Throwable ex = new Throwable("wtf", ParsingException); + Throwable ex = new Throwable("eggplant", ParsingException); out.writeThrowable(ex); StreamInput in = StreamInput.wrap(out.bytes()); Throwable throwable = in.readThrowable(); - assertEquals("wtf", throwable.getMessage()); + assertEquals("throwable: eggplant", throwable.getMessage()); assertTrue(throwable instanceof ElasticsearchException); ParsingException e = (ParsingException)throwable.getCause(); assertEquals(ParsingException.getIndex(), e.getIndex()); @@ -329,7 +329,9 @@ public class ESExceptionTests extends ESTestCase { StreamInput in = StreamInput.wrap(out.bytes()); ElasticsearchException e = in.readThrowable(); assertEquals(e.getMessage(), ex.getMessage()); - assertEquals(ex.getCause().getClass().getName(), e.getCause().getMessage(), ex.getCause().getMessage()); + assertTrue("Expected: " + e.getCause().getMessage() + " to contain: " + + ex.getCause().getClass().getName() + " but it didn't", + e.getCause().getMessage().contains(ex.getCause().getMessage())); if (ex.getCause().getClass() != Throwable.class) { // throwable is not directly mapped assertEquals(e.getCause().getClass(), ex.getCause().getClass()); } else { diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 9f8e861f9ce..50764eef65e 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -543,9 +543,9 @@ public class ExceptionSerializationTests extends ESTestCase { public void testNotSerializableExceptionWrapper() throws IOException { NotSerializableExceptionWrapper ex = serialize(new NotSerializableExceptionWrapper(new NullPointerException())); - assertEquals("{\"type\":\"null_pointer_exception\",\"reason\":null}", toXContent(ex)); + assertEquals("{\"type\":\"null_pointer_exception\",\"reason\":\"null_pointer_exception: null\"}", toXContent(ex)); ex = serialize(new NotSerializableExceptionWrapper(new IllegalArgumentException("nono!"))); - assertEquals("{\"type\":\"illegal_argument_exception\",\"reason\":\"nono!\"}", toXContent(ex)); + assertEquals("{\"type\":\"illegal_argument_exception\",\"reason\":\"illegal_argument_exception: nono!\"}", toXContent(ex)); Throwable[] unknowns = new Throwable[]{ new Exception("foobar"), @@ -586,7 +586,7 @@ public class ExceptionSerializationTests extends ESTestCase { ElasticsearchException serialize = serialize((ElasticsearchException) uhe); assertTrue(serialize instanceof NotSerializableExceptionWrapper); NotSerializableExceptionWrapper e = (NotSerializableExceptionWrapper) serialize; - assertEquals("msg", e.getMessage()); + assertEquals("unknown_header_exception: msg", e.getMessage()); assertEquals(2, e.getHeader("foo").size()); assertEquals("foo", e.getHeader("foo").get(0)); assertEquals("bar", e.getHeader("foo").get(1)); diff --git a/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java b/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java index 6c11bc35dec..47823307ffd 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/HotThreadsIT.java @@ -119,7 +119,7 @@ public class HotThreadsIT extends ESIntegTestCase { .setQuery(matchAllQuery()) .setPostFilter(boolQuery().must(matchAllQuery()).mustNot(boolQuery().must(termQuery("field1", "value1")).must(termQuery("field1", "value2")))) .get(), - 3l); + 3L); } latch.await(); assertThat(hasErrors.get(), is(false)); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java index cc300ed101b..20e66361ab7 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java @@ -93,7 +93,7 @@ public class ClusterStatsIT extends ESIntegTestCase { ensureYellow(); response = client().admin().cluster().prepareClusterStats().get(); assertThat(response.getStatus(), Matchers.equalTo(ClusterHealthStatus.YELLOW)); - assertThat(response.indicesStats.getDocs().getCount(), Matchers.equalTo(0l)); + assertThat(response.indicesStats.getDocs().getCount(), Matchers.equalTo(0L)); assertThat(response.indicesStats.getIndexCount(), Matchers.equalTo(1)); assertShardStats(response.getIndicesStats().getShards(), 1, 2, 2, 0.0); @@ -104,7 +104,7 @@ public class ClusterStatsIT extends ESIntegTestCase { refresh(); // make the doc visible response = client().admin().cluster().prepareClusterStats().get(); assertThat(response.getStatus(), Matchers.equalTo(ClusterHealthStatus.GREEN)); - assertThat(response.indicesStats.getDocs().getCount(), Matchers.equalTo(1l)); + assertThat(response.indicesStats.getDocs().getCount(), Matchers.equalTo(1L)); assertShardStats(response.getIndicesStats().getShards(), 1, 4, 2, 1.0); prepareCreate("test2").setSettings("number_of_shards", 3, "number_of_replicas", 0).get(); @@ -141,10 +141,10 @@ public class ClusterStatsIT extends ESIntegTestCase { ensureYellow("test1"); ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); String msg = response.toString(); - assertThat(msg, response.getTimestamp(), Matchers.greaterThan(946681200000l)); // 1 Jan 2000 - assertThat(msg, response.indicesStats.getStore().getSizeInBytes(), Matchers.greaterThan(0l)); + assertThat(msg, response.getTimestamp(), Matchers.greaterThan(946681200000L)); // 1 Jan 2000 + assertThat(msg, response.indicesStats.getStore().getSizeInBytes(), Matchers.greaterThan(0L)); - assertThat(msg, response.nodesStats.getFs().getTotal().bytes(), Matchers.greaterThan(0l)); + assertThat(msg, response.nodesStats.getFs().getTotal().bytes(), Matchers.greaterThan(0L)); assertThat(msg, response.nodesStats.getJvm().getVersions().size(), Matchers.greaterThan(0)); assertThat(msg, response.nodesStats.getVersions().size(), Matchers.greaterThan(0)); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java index 292705305cc..5cf9d858016 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java @@ -54,7 +54,7 @@ import static org.hamcrest.core.IsNull.notNullValue; public class CreateIndexIT extends ESIntegTestCase { public void testCreationDateGivenFails() { try { - prepareCreate("test").setSettings(Settings.builder().put(IndexMetaData.SETTING_CREATION_DATE, 4l)).get(); + prepareCreate("test").setSettings(Settings.builder().put(IndexMetaData.SETTING_CREATION_DATE, 4L)).get(); fail(); } catch (IllegalArgumentException ex) { assertEquals("unknown setting [index.creation_date]", ex.getMessage()); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java index 3c70f241eec..118560b7ab6 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoreRequestIT.java @@ -93,7 +93,7 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase { assertThat(shardStores.values().size(), equalTo(2)); for (ObjectCursor> shardStoreStatuses : shardStores.values()) { for (IndicesShardStoresResponse.StoreStatus storeStatus : shardStoreStatuses.value) { - assertThat(storeStatus.getVersion(), greaterThan(-1l)); + assertThat(storeStatus.getVersion(), greaterThan(-1L)); assertThat(storeStatus.getAllocationId(), notNullValue()); assertThat(storeStatus.getNode(), notNullValue()); assertThat(storeStatus.getStoreException(), nullValue()); @@ -191,10 +191,10 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase { for (IndicesShardStoresResponse.StoreStatus status : shardStatus.value) { if (corruptedShardIDMap.containsKey(shardStatus.key) && corruptedShardIDMap.get(shardStatus.key).contains(status.getNode().name())) { - assertThat(status.getVersion(), greaterThanOrEqualTo(0l)); + assertThat(status.getVersion(), greaterThanOrEqualTo(0L)); assertThat(status.getStoreException(), notNullValue()); } else { - assertThat(status.getVersion(), greaterThanOrEqualTo(0l)); + assertThat(status.getVersion(), greaterThanOrEqualTo(0L)); assertNull(status.getStoreException()); } } diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java index 4d7e9aa216f..1f18da58204 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java @@ -66,11 +66,11 @@ public class IndicesStatsTests extends ESSingleNodeTestCase { IndicesStatsResponse rsp = client().admin().indices().prepareStats("test").get(); SegmentsStats stats = rsp.getIndex("test").getTotal().getSegments(); - assertThat(stats.getTermsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getTermVectorsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getNormsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0l)); + assertThat(stats.getTermsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getTermVectorsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getNormsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0L)); // now check multiple segments stats are merged together client().prepareIndex("test", "doc", "2").setSource("foo", "bar").get(); @@ -93,7 +93,7 @@ public class IndicesStatsTests extends ESSingleNodeTestCase { for (ShardStats shardStats : rsp.getIndex("test").getShards()) { final CommitStats commitStats = shardStats.getCommitStats(); assertNotNull(commitStats); - assertThat(commitStats.getGeneration(), greaterThan(0l)); + assertThat(commitStats.getGeneration(), greaterThan(0L)); assertThat(commitStats.getId(), notNullValue()); assertThat(commitStats.getUserData(), hasKey(Translog.TRANSLOG_GENERATION_KEY)); assertThat(commitStats.getUserData(), hasKey(Translog.TRANSLOG_UUID_KEY)); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java b/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java new file mode 100644 index 00000000000..8eb3f4ece75 --- /dev/null +++ b/core/src/test/java/org/elasticsearch/action/ingest/WritePipelineResponseTests.java @@ -0,0 +1,61 @@ +/* + * 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.ingest; + +import org.elasticsearch.common.io.stream.BytesStreamOutput; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.ingest.core.PipelineFactoryError; +import org.elasticsearch.test.ESTestCase; + +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.nullValue; + +public class WritePipelineResponseTests extends ESTestCase { + + public void testSerializationWithoutError() throws IOException { + boolean isAcknowledged = randomBoolean(); + WritePipelineResponse response; + response = new WritePipelineResponse(isAcknowledged); + BytesStreamOutput out = new BytesStreamOutput(); + response.writeTo(out); + StreamInput streamInput = StreamInput.wrap(out.bytes()); + WritePipelineResponse otherResponse = new WritePipelineResponse(); + otherResponse.readFrom(streamInput); + + assertThat(otherResponse.isAcknowledged(), equalTo(response.isAcknowledged())); + } + + public void testSerializationWithError() throws IOException { + PipelineFactoryError error = new PipelineFactoryError("error"); + WritePipelineResponse response = new WritePipelineResponse(error); + BytesStreamOutput out = new BytesStreamOutput(); + response.writeTo(out); + StreamInput streamInput = StreamInput.wrap(out.bytes()); + WritePipelineResponse otherResponse = new WritePipelineResponse(); + otherResponse.readFrom(streamInput); + + assertThat(otherResponse.getError().getReason(), equalTo(response.getError().getReason())); + assertThat(otherResponse.getError().getProcessorType(), equalTo(response.getError().getProcessorType())); + assertThat(otherResponse.getError().getProcessorTag(), equalTo(response.getError().getProcessorTag())); + assertThat(otherResponse.getError().getProcessorPropertyName(), equalTo(response.getError().getProcessorPropertyName())); + } +} diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java index 60fa0e9d684..4928cc66081 100644 --- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java +++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsCheckDocFreqIT.java @@ -99,7 +99,7 @@ public class GetTermVectorsCheckDocFreqIT extends ESIntegTestCase { Fields fields = response.getFields(); assertThat(fields.size(), equalTo(1)); Terms terms = fields.terms("field"); - assertThat(terms.size(), equalTo(8l)); + assertThat(terms.size(), equalTo(8L)); assertThat(terms.getSumTotalTermFreq(), Matchers.equalTo((long) -1)); assertThat(terms.getDocCount(), Matchers.equalTo(-1)); assertThat(terms.getSumDocFreq(), equalTo((long) -1)); @@ -158,7 +158,7 @@ public class GetTermVectorsCheckDocFreqIT extends ESIntegTestCase { Fields fields = response.getFields(); assertThat(fields.size(), equalTo(1)); Terms terms = fields.terms("field"); - assertThat(terms.size(), equalTo(8l)); + assertThat(terms.size(), equalTo(8L)); assertThat(terms.getSumTotalTermFreq(), Matchers.equalTo((long) (9 * numDocs))); assertThat(terms.getDocCount(), Matchers.equalTo(numDocs)); assertThat(terms.getSumDocFreq(), equalTo((long) numDocs * values.length)); @@ -214,7 +214,7 @@ public class GetTermVectorsCheckDocFreqIT extends ESIntegTestCase { Fields fields = response.getFields(); assertThat(fields.size(), equalTo(1)); Terms terms = fields.terms("field"); - assertThat(terms.size(), equalTo(8l)); + assertThat(terms.size(), equalTo(8L)); assertThat(terms.getSumTotalTermFreq(), Matchers.equalTo((long) (9 * numDocs))); assertThat(terms.getDocCount(), Matchers.equalTo(numDocs)); assertThat(terms.getSumDocFreq(), equalTo((long) numDocs * values.length)); diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java index 45b045a7f4b..21114804cbb 100644 --- a/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java +++ b/core/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java @@ -317,7 +317,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { assertThat(fields.size(), equalTo(ft.storeTermVectors() ? 1 : 0)); if (ft.storeTermVectors()) { Terms terms = fields.terms("field"); - assertThat(terms.size(), equalTo(8l)); + assertThat(terms.size(), equalTo(8L)); TermsEnum iterator = terms.iterator(); for (int j = 0; j < values.length; j++) { String string = values[j]; @@ -637,7 +637,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { int[][] endOffset = {{15}, {43}, {19}, {25}, {39}, {30}, {9}, {3, 34}}; Terms terms = fields.terms(fieldName); - assertThat(terms.size(), equalTo(8l)); + assertThat(terms.size(), equalTo(8L)); TermsEnum iterator = terms.iterator(); for (int j = 0; j < values.length; j++) { String string = values[j]; @@ -1087,12 +1087,12 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { response = client().prepareTermVectors(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); response = client().prepareTermVectors(indexOrAlias(), "type1", "1").setVersion(1).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get(); @@ -1109,13 +1109,13 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); response = client().prepareTermVectors(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get(); @@ -1134,7 +1134,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get(); @@ -1147,7 +1147,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); // From Lucene index: refresh(); @@ -1157,7 +1157,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); @@ -1170,7 +1170,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); } public void testFilterLength() throws ExecutionException, InterruptedException, IOException { diff --git a/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java b/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java index 18c1572e865..f60709d6da0 100644 --- a/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java +++ b/core/src/test/java/org/elasticsearch/broadcast/BroadcastActionsIT.java @@ -58,7 +58,7 @@ public class BroadcastActionsIT extends ESIntegTestCase { SearchResponse countResponse = client().prepareSearch("test").setSize(0) .setQuery(termQuery("_type", "type1")) .get(); - assertThat(countResponse.getHits().totalHits(), equalTo(2l)); + assertThat(countResponse.getHits().totalHits(), equalTo(2L)); assertThat(countResponse.getTotalShards(), equalTo(numShards.numPrimaries)); assertThat(countResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); assertThat(countResponse.getFailedShards(), equalTo(0)); diff --git a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java index 26dcb214bea..d5dcd142009 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityIT.java @@ -122,11 +122,11 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { assertThat(id, client().prepareIndex("test", "type1", id).setRouting(routingKey).setSource("field1", English.intToEnglish(i)).get().isCreated(), is(true)); GetResponse get = client().prepareGet("test", "type1", id).setRouting(routingKey).setVersion(1).get(); assertThat("Document with ID " + id + " should exist but doesn't", get.isExists(), is(true)); - assertThat(get.getVersion(), equalTo(1l)); + assertThat(get.getVersion(), equalTo(1L)); client().prepareIndex("test", "type1", id).setRouting(routingKey).setSource("field1", English.intToEnglish(i)).execute().actionGet(); get = client().prepareGet("test", "type1", id).setRouting(routingKey).setVersion(2).get(); assertThat("Document with ID " + id + " should exist but doesn't", get.isExists(), is(true)); - assertThat(get.getVersion(), equalTo(2l)); + assertThat(get.getVersion(), equalTo(2L)); } assertVersionCreated(compatibilityVersion(), "test"); @@ -416,30 +416,30 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { client().prepareIndex(indexName, "type1", "4").setSource(jsonBuilder().startObject().startObject("obj2").field("obj2_val", "1").endObject().field("y2", "y_2").field("field3", "value3_4").endObject())); SearchResponse countResponse = client().prepareSearch().setSize(0).setQuery(existsQuery("field1")).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); countResponse = client().prepareSearch().setSize(0).setQuery(constantScoreQuery(existsQuery("field1"))).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); countResponse = client().prepareSearch().setSize(0).setQuery(queryStringQuery("_exists_:field1")).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); countResponse = client().prepareSearch().setSize(0).setQuery(existsQuery("field2")).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); countResponse = client().prepareSearch().setSize(0).setQuery(existsQuery("field3")).get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); // wildcard check countResponse = client().prepareSearch().setSize(0).setQuery(existsQuery("x*")).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); // object check countResponse = client().prepareSearch().setSize(0).setQuery(existsQuery("obj1")).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); countResponse = client().prepareSearch().setSize(0).setQuery(queryStringQuery("_missing_:field1")).get(); - assertHitCount(countResponse, 2l); + assertHitCount(countResponse, 2L); if (!backwardsCluster().upgradeOneNode()) { break; @@ -598,7 +598,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase { assertThat(termVectorsResponse.isExists(), equalTo(true)); Fields fields = termVectorsResponse.getFields(); assertThat(fields.size(), equalTo(1)); - assertThat(fields.terms("field").size(), equalTo(8l)); + assertThat(fields.terms("field").size(), equalTo(8L)); } public void testIndicesStats() { diff --git a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java index 5c351abbce3..b5b1f955ae0 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java @@ -332,7 +332,7 @@ public class OldIndexBackwardsCompatibilityIT extends ESIntegTestCase { } } SearchResponse test = client().prepareSearch(indexName).get(); - assertThat(test.getHits().getTotalHits(), greaterThanOrEqualTo(1l)); + assertThat(test.getHits().getTotalHits(), greaterThanOrEqualTo(1L)); } void assertBasicSearchWorks(String indexName) { diff --git a/core/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityIT.java index 37961c3d353..794aea85487 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/StaticIndexBackwardCompatibilityIT.java @@ -49,7 +49,7 @@ public class StaticIndexBackwardCompatibilityIT extends ESIntegTestCase { assertEquals(index, getIndexResponse.indices()[0]); ensureYellow(index); SearchResponse test = client().prepareSearch(index).get(); - assertThat(test.getHits().getTotalHits(), greaterThanOrEqualTo(1l)); + assertThat(test.getHits().getTotalHits(), greaterThanOrEqualTo(1L)); } } diff --git a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java index a561b5bcf7b..bd1bd83ef8f 100644 --- a/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java +++ b/core/src/test/java/org/elasticsearch/client/transport/TransportClientIT.java @@ -32,6 +32,8 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + import static org.elasticsearch.common.settings.Settings.settingsBuilder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; @@ -48,7 +50,7 @@ public class TransportClientIT extends ESIntegTestCase { } - public void testNodeVersionIsUpdated() { + public void testNodeVersionIsUpdated() throws IOException { TransportClient client = (TransportClient) internalCluster().client(); TransportClientNodesService nodeService = client.nodeService(); Node node = new Node(Settings.builder() diff --git a/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java b/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java index 4819a97fce7..cc3cae8606b 100644 --- a/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/ClusterServiceIT.java @@ -632,7 +632,7 @@ public class ClusterServiceIT extends ESIntegTestCase { controlSources = new HashSet<>(Arrays.asList("1", "2", "3", "4", "5")); for (PendingClusterTask task : response) { if (controlSources.remove(task.getSource().string())) { - assertThat(task.getTimeInQueueInMillis(), greaterThan(0l)); + assertThat(task.getTimeInQueueInMillis(), greaterThan(0L)); } } assertTrue(controlSources.isEmpty()); diff --git a/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java b/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java index 9ee423b91df..a74102f6969 100644 --- a/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java @@ -115,8 +115,8 @@ public class DiskUsageTests extends ESTestCase { assertEquals(2, shardSizes.size()); assertTrue(shardSizes.containsKey(ClusterInfo.shardIdentifierFromRouting(test_0))); assertTrue(shardSizes.containsKey(ClusterInfo.shardIdentifierFromRouting(test_1))); - assertEquals(100l, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(test_0)).longValue()); - assertEquals(1000l, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(test_1)).longValue()); + assertEquals(100L, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(test_0)).longValue()); + assertEquals(1000L, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(test_1)).longValue()); assertEquals(2, routingToPath.size()); assertTrue(routingToPath.containsKey(test_0)); diff --git a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index d764216c056..78128fe30f2 100644 --- a/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java @@ -117,7 +117,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { logger.info("--> verify we the data back"); for (int i = 0; i < 10; i++) { - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100l)); + assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100L)); } internalCluster().stopCurrentMasterNode(); @@ -279,7 +279,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { setMinimumMasterNodes(2); // make sure it has been processed on all nodes (master node spawns a secondary cluster state update task) - for (Client client : internalCluster()) { + for (Client client : internalCluster().getClients()) { assertThat(client.admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setLocal(true).get().isTimedOut(), equalTo(false)); } @@ -303,7 +303,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { assertTrue(awaitBusy( () -> { boolean success = true; - for (Client client : internalCluster()) { + for (Client client : internalCluster().getClients()) { boolean clientHasNoMasterBlock = hasNoMasterBlock.test(client); if (logger.isDebugEnabled()) { logger.debug("Checking for NO_MASTER_BLOCK on client: {} NO_MASTER_BLOCK: [{}]", client, clientHasNoMasterBlock); diff --git a/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java index 3c71f5f5e2b..370f1464fd2 100644 --- a/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/NoMasterNodeIT.java @@ -248,10 +248,10 @@ public class NoMasterNodeIT extends ESIntegTestCase { assertExists(getResponse); SearchResponse countResponse = client().prepareSearch("test1").setSize(0).get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); SearchResponse searchResponse = client().prepareSearch("test1").get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); countResponse = client().prepareSearch("test2").setSize(0).get(); assertThat(countResponse.getTotalShards(), equalTo(2)); diff --git a/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java index 0c3eed1d532..f775918b8f7 100644 --- a/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/allocation/FilteringAllocationIT.java @@ -58,7 +58,7 @@ public class FilteringAllocationIT extends ESIntegTestCase { client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); } client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100l)); + assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100L)); logger.info("--> decommission the second node"); client().admin().cluster().prepareUpdateSettings() @@ -77,7 +77,7 @@ public class FilteringAllocationIT extends ESIntegTestCase { } client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100l)); + assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100L)); } public void testDisablingAllocationFiltering() throws Exception { @@ -99,7 +99,7 @@ public class FilteringAllocationIT extends ESIntegTestCase { client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value" + i).execute().actionGet(); } client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100l)); + assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(100L)); ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); IndexRoutingTable indexRoutingTable = clusterState.routingTable().index("test"); int numShardsOnNode1 = 0; diff --git a/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java b/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java index cbb5b7dfbdb..58861585066 100644 --- a/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetaDataTests.java @@ -55,7 +55,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { .settings(settings(Version.CURRENT)) .numberOfShards(1) .numberOfReplicas(2) - .creationDate(2l)) + .creationDate(2L)) .put(IndexMetaData.builder("test5") .settings(settings(Version.CURRENT).put("setting1", "value1").put("setting2", "value2")) .numberOfShards(1) @@ -66,12 +66,12 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { .settings(settings(Version.CURRENT).put("setting1", "value1").put("setting2", "value2")) .numberOfShards(1) .numberOfReplicas(2) - .creationDate(2l)) + .creationDate(2L)) .put(IndexMetaData.builder("test7") .settings(settings(Version.CURRENT)) .numberOfShards(1) .numberOfReplicas(2) - .creationDate(2l) + .creationDate(2L) .putMapping("mapping1", MAPPING_SOURCE1) .putMapping("mapping2", MAPPING_SOURCE2)) .put(IndexMetaData.builder("test8") @@ -84,7 +84,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { .putAlias(newAliasMetaDataBuilder("alias2"))) .put(IndexMetaData.builder("test9") .settings(settings(Version.CURRENT).put("setting1", "value1").put("setting2", "value2")) - .creationDate(2l) + .creationDate(2L) .numberOfShards(1) .numberOfReplicas(2) .putMapping("mapping1", MAPPING_SOURCE1) @@ -125,7 +125,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { .settings(settings(Version.CURRENT) .put("setting1", "value1") .put("setting2", "value2")) - .creationDate(2l) + .creationDate(2L) .numberOfShards(1) .numberOfReplicas(2) .putMapping("mapping1", MAPPING_SOURCE1) @@ -152,14 +152,14 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { IndexMetaData indexMetaData = parsedMetaData.index("test1"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(3)); assertThat(indexMetaData.getMappings().size(), equalTo(0)); indexMetaData = parsedMetaData.index("test2"); assertThat(indexMetaData.getNumberOfShards(), equalTo(2)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(3)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -168,13 +168,13 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test3"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(3)); assertThat(indexMetaData.getMappings().size(), equalTo(1)); assertThat(indexMetaData.getMappings().get("mapping1").source().string(), equalTo(MAPPING_SOURCE1)); indexMetaData = parsedMetaData.index("test4"); - assertThat(indexMetaData.getCreationDate(), equalTo(2l)); + assertThat(indexMetaData.getCreationDate(), equalTo(2L)); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(4)); @@ -183,7 +183,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test5"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -194,7 +194,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test6"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(2l)); + assertThat(indexMetaData.getCreationDate(), equalTo(2L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(6)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -203,7 +203,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test7"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(2l)); + assertThat(indexMetaData.getCreationDate(), equalTo(2L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(4)); assertThat(indexMetaData.getMappings().size(), equalTo(2)); assertThat(indexMetaData.getMappings().get("mapping1").source().string(), equalTo(MAPPING_SOURCE1)); @@ -212,7 +212,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test8"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -226,7 +226,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test9"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(2l)); + assertThat(indexMetaData.getCreationDate(), equalTo(2L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(6)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -240,7 +240,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test10"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -254,7 +254,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test11"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(-1l)); + assertThat(indexMetaData.getCreationDate(), equalTo(-1L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(5)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); @@ -272,7 +272,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase { indexMetaData = parsedMetaData.index("test12"); assertThat(indexMetaData.getNumberOfShards(), equalTo(1)); assertThat(indexMetaData.getNumberOfReplicas(), equalTo(2)); - assertThat(indexMetaData.getCreationDate(), equalTo(2l)); + assertThat(indexMetaData.getCreationDate(), equalTo(2L)); assertThat(indexMetaData.getSettings().getAsMap().size(), equalTo(6)); assertThat(indexMetaData.getSettings().get("setting1"), equalTo("value1")); assertThat(indexMetaData.getSettings().get("setting2"), equalTo("value2")); diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java index 457e679ebd8..d911a1175c7 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/PrimaryAllocationIT.java @@ -122,7 +122,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase { logger.info("--> check that the up-to-date primary shard gets promoted and that documents are available"); ensureYellow("test"); - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2L); } public void testFailedAllocationOfStalePrimaryToDataNodeWithNoData() throws Exception { @@ -171,7 +171,7 @@ public class PrimaryAllocationIT extends ESIntegTestCase { logger.info("--> check that the stale primary shard gets allocated and that documents are available"); ensureYellow("test"); - assertHitCount(client().prepareSearch("test").setSize(0).setQuery(matchAllQuery()).get(), useStaleReplica ? 1l : 0l); + assertHitCount(client().prepareSearch("test").setSize(0).setQuery(matchAllQuery()).get(), useStaleReplica ? 1L : 0L); } public void testForcePrimaryShardIfAllocationDecidersSayNoAfterIndexCreation() throws ExecutionException, InterruptedException { @@ -200,6 +200,6 @@ public class PrimaryAllocationIT extends ESIntegTestCase { internalCluster().fullRestart(); logger.info("--> checking that index still gets allocated with only 1 shard copy being available"); ensureYellow("test"); - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 1L); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java index 37882dd6772..e547405b336 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/UnassignedInfoTests.java @@ -221,7 +221,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase { assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).size(), equalTo(1)); assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo(), notNullValue()); assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getReason(), equalTo(UnassignedInfo.Reason.NODE_LEFT)); - assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getUnassignedTimeInMillis(), greaterThan(0l)); + assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getUnassignedTimeInMillis(), greaterThan(0L)); } /** @@ -252,7 +252,7 @@ public class UnassignedInfoTests extends ESAllocationTestCase { assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getReason(), equalTo(UnassignedInfo.Reason.ALLOCATION_FAILED)); assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getMessage(), equalTo("test fail")); assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getDetails(), equalTo("test fail")); - assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getUnassignedTimeInMillis(), greaterThan(0l)); + assertThat(clusterState.getRoutingNodes().shardsWithState(UNASSIGNED).get(0).unassignedInfo().getUnassignedTimeInMillis(), greaterThan(0L)); } /** @@ -276,9 +276,9 @@ public class UnassignedInfoTests extends ESAllocationTestCase { UnassignedInfo unassignedInfo = new UnassignedInfo(RandomPicks.randomFrom(getRandom(), reasons), null); long delay = unassignedInfo.updateDelay(unassignedInfo.getUnassignedTimeInNanos() + 1, // add 1 tick delay Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "10h").build(), Settings.EMPTY); - assertThat(delay, equalTo(0l)); + assertThat(delay, equalTo(0L)); delay = unassignedInfo.getLastComputedLeftDelayNanos(); - assertThat(delay, equalTo(0l)); + assertThat(delay, equalTo(0L)); } /** diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java index e1586c433a5..36f51675b21 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardVersioningTests.java @@ -64,14 +64,14 @@ public class ShardVersioningTests extends ESAllocationTestCase { for (int i = 0; i < routingTable.index("test1").shards().size(); i++) { assertThat(routingTable.index("test1").shard(i).shards().size(), equalTo(2)); assertThat(routingTable.index("test1").shard(i).primaryShard().state(), equalTo(INITIALIZING)); - assertThat(routingTable.index("test1").shard(i).primaryShard().version(), equalTo(1l)); + assertThat(routingTable.index("test1").shard(i).primaryShard().version(), equalTo(1L)); assertThat(routingTable.index("test1").shard(i).replicaShards().get(0).state(), equalTo(UNASSIGNED)); } for (int i = 0; i < routingTable.index("test2").shards().size(); i++) { assertThat(routingTable.index("test2").shard(i).shards().size(), equalTo(2)); assertThat(routingTable.index("test2").shard(i).primaryShard().state(), equalTo(INITIALIZING)); - assertThat(routingTable.index("test2").shard(i).primaryShard().version(), equalTo(1l)); + assertThat(routingTable.index("test2").shard(i).primaryShard().version(), equalTo(1L)); assertThat(routingTable.index("test2").shard(i).replicaShards().get(0).state(), equalTo(UNASSIGNED)); } @@ -84,17 +84,17 @@ public class ShardVersioningTests extends ESAllocationTestCase { for (int i = 0; i < routingTable.index("test1").shards().size(); i++) { assertThat(routingTable.index("test1").shard(i).shards().size(), equalTo(2)); assertThat(routingTable.index("test1").shard(i).primaryShard().state(), equalTo(STARTED)); - assertThat(routingTable.index("test1").shard(i).primaryShard().version(), equalTo(2l)); + assertThat(routingTable.index("test1").shard(i).primaryShard().version(), equalTo(2L)); assertThat(routingTable.index("test1").shard(i).replicaShards().get(0).state(), equalTo(INITIALIZING)); - assertThat(routingTable.index("test1").shard(i).replicaShards().get(0).version(), equalTo(2l)); + assertThat(routingTable.index("test1").shard(i).replicaShards().get(0).version(), equalTo(2L)); } for (int i = 0; i < routingTable.index("test2").shards().size(); i++) { assertThat(routingTable.index("test2").shard(i).shards().size(), equalTo(2)); assertThat(routingTable.index("test2").shard(i).primaryShard().state(), equalTo(INITIALIZING)); - assertThat(routingTable.index("test2").shard(i).primaryShard().version(), equalTo(1l)); + assertThat(routingTable.index("test2").shard(i).primaryShard().version(), equalTo(1L)); assertThat(routingTable.index("test2").shard(i).replicaShards().get(0).state(), equalTo(UNASSIGNED)); - assertThat(routingTable.index("test2").shard(i).replicaShards().get(0).version(), equalTo(1l)); + assertThat(routingTable.index("test2").shard(i).replicaShards().get(0).version(), equalTo(1L)); } } } \ No newline at end of file diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java index ec076a54af7..511449ebc6a 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java @@ -239,20 +239,20 @@ public class DiskThresholdDeciderUnitTests extends ESTestCase { ShardRoutingHelper.initialize(test_2, "node1"); ShardRoutingHelper.moveToStarted(test_2); - assertEquals(1000l, DiskThresholdDecider.getShardSize(test_2, info)); - assertEquals(100l, DiskThresholdDecider.getShardSize(test_1, info)); - assertEquals(10l, DiskThresholdDecider.getShardSize(test_0, info)); + assertEquals(1000L, DiskThresholdDecider.getShardSize(test_2, info)); + assertEquals(100L, DiskThresholdDecider.getShardSize(test_1, info)); + assertEquals(10L, DiskThresholdDecider.getShardSize(test_0, info)); RoutingNode node = new RoutingNode("node1", new DiscoveryNode("node1", LocalTransportAddress.PROTO, Version.CURRENT), Arrays.asList(test_0, test_1.buildTargetRelocatingShard(), test_2)); - assertEquals(100l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, false, "/dev/null")); - assertEquals(90l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/null")); - assertEquals(0l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/some/other/dev")); - assertEquals(0l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/some/other/dev")); + assertEquals(100L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, false, "/dev/null")); + assertEquals(90L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/null")); + assertEquals(0L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/some/other/dev")); + assertEquals(0L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/some/other/dev")); ShardRouting test_3 = ShardRouting.newUnassigned(index, 3, null, false, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo")); ShardRoutingHelper.initialize(test_3, "node1"); ShardRoutingHelper.moveToStarted(test_3); - assertEquals(0l, DiskThresholdDecider.getShardSize(test_3, info)); + assertEquals(0L, DiskThresholdDecider.getShardSize(test_3, info)); ShardRouting other_0 = ShardRouting.newUnassigned(new Index("other", "_NA_"), 0, null, randomBoolean(), new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo")); @@ -263,11 +263,11 @@ public class DiskThresholdDeciderUnitTests extends ESTestCase { node = new RoutingNode("node1", new DiscoveryNode("node1", LocalTransportAddress.PROTO, Version.CURRENT), Arrays.asList(test_0, test_1.buildTargetRelocatingShard(), test_2, other_0.buildTargetRelocatingShard())); if (other_0.primary()) { - assertEquals(10100l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, false, "/dev/null")); - assertEquals(10090l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/null")); + assertEquals(10100L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, false, "/dev/null")); + assertEquals(10090L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/null")); } else { - assertEquals(100l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, false, "/dev/null")); - assertEquals(90l, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/null")); + assertEquals(100L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, false, "/dev/null")); + assertEquals(90L, DiskThresholdDecider.sizeOfRelocatingShards(node, info, true, "/dev/null")); } } diff --git a/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java b/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java index fb0ff372551..5e01aef90c6 100644 --- a/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java +++ b/core/src/test/java/org/elasticsearch/cluster/settings/ClusterSettingsIT.java @@ -95,7 +95,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertAcked(response); assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); @@ -118,7 +118,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertAcked(response); assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertFalse(discoverySettings.getPublishDiff()); response = client().admin().cluster() .prepareUpdateSettings() @@ -138,7 +138,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertAcked(response); assertThat(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertThat(discoverySettings.getPublishDiff(), equalTo(DiscoverySettings.PUBLISH_DIFF_ENABLE_SETTING.get(Settings.EMPTY))); @@ -162,7 +162,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertAcked(response); assertThat(response.getPersistentSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); assertFalse(discoverySettings.getPublishDiff()); response = client().admin().cluster() .prepareUpdateSettings() @@ -254,7 +254,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertAcked(response); assertThat(response.getTransientSettings().getAsMap().get(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey()), equalTo("1s")); - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); try { client().admin().cluster() @@ -266,7 +266,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertEquals(ex.getMessage(), "Failed to parse setting [discovery.zen.publish_timeout] with value [whatever] as a time value: unit is missing or unrecognized"); } - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); try { client().admin().cluster() @@ -278,7 +278,7 @@ public class ClusterSettingsIT extends ESIntegTestCase { assertEquals(ex.getMessage(), "Failed to parse value [-1] for setting [discovery.zen.publish_timeout] must be >= 0s"); } - assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1l)); + assertThat(discoverySettings.getPublishTimeout().seconds(), equalTo(1L)); } public void testClusterUpdateSettingsWithBlocks() { diff --git a/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java b/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java index 573138c50f7..b0e2ea873c4 100644 --- a/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java +++ b/core/src/test/java/org/elasticsearch/common/lucene/search/morelikethis/MoreLikeThisQueryTests.java @@ -62,7 +62,7 @@ public class MoreLikeThisQueryTests extends ESTestCase { mltQuery.setMinTermFrequency(1); mltQuery.setMinDocFreq(1); long count = searcher.count(mltQuery); - assertThat(count, equalTo(2l)); + assertThat(count, equalTo(2L)); reader.close(); indexWriter.close(); diff --git a/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java b/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java index 99acdde7af4..e8d8b914a4d 100644 --- a/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java +++ b/core/src/test/java/org/elasticsearch/common/lucene/store/InputStreamIndexInputTests.java @@ -51,7 +51,7 @@ public class InputStreamIndexInputTests extends ESTestCase { for (int i = 0; i < 3; i++) { InputStreamIndexInput is = new InputStreamIndexInput(input, 1); assertThat(input.getFilePointer(), lessThan(input.length())); - assertThat(is.actualSizeToRead(), equalTo(1l)); + assertThat(is.actualSizeToRead(), equalTo(1L)); assertThat(is.read(), equalTo(1)); assertThat(is.read(), equalTo(-1)); } @@ -59,14 +59,14 @@ public class InputStreamIndexInputTests extends ESTestCase { for (int i = 0; i < 3; i++) { InputStreamIndexInput is = new InputStreamIndexInput(input, 1); assertThat(input.getFilePointer(), lessThan(input.length())); - assertThat(is.actualSizeToRead(), equalTo(1l)); + assertThat(is.actualSizeToRead(), equalTo(1L)); assertThat(is.read(), equalTo(2)); assertThat(is.read(), equalTo(-1)); } assertThat(input.getFilePointer(), equalTo(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 1); - assertThat(is.actualSizeToRead(), equalTo(0l)); + assertThat(is.actualSizeToRead(), equalTo(0L)); assertThat(is.read(), equalTo(-1)); } @@ -89,7 +89,7 @@ public class InputStreamIndexInputTests extends ESTestCase { for (int i = 0; i < 3; i++) { assertThat(input.getFilePointer(), lessThan(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 1); - assertThat(is.actualSizeToRead(), equalTo(1l)); + assertThat(is.actualSizeToRead(), equalTo(1L)); assertThat(is.read(read), equalTo(1)); assertThat(read[0], equalTo((byte) 1)); } @@ -97,14 +97,14 @@ public class InputStreamIndexInputTests extends ESTestCase { for (int i = 0; i < 3; i++) { assertThat(input.getFilePointer(), lessThan(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 1); - assertThat(is.actualSizeToRead(), equalTo(1l)); + assertThat(is.actualSizeToRead(), equalTo(1L)); assertThat(is.read(read), equalTo(1)); assertThat(read[0], equalTo((byte) 2)); } assertThat(input.getFilePointer(), equalTo(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 1); - assertThat(is.actualSizeToRead(), equalTo(0l)); + assertThat(is.actualSizeToRead(), equalTo(0L)); assertThat(is.read(read), equalTo(-1)); } @@ -124,28 +124,28 @@ public class InputStreamIndexInputTests extends ESTestCase { assertThat(input.getFilePointer(), lessThan(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(), equalTo(1)); assertThat(is.read(), equalTo(1)); assertThat(is.read(), equalTo(-1)); assertThat(input.getFilePointer(), lessThan(input.length())); is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(), equalTo(1)); assertThat(is.read(), equalTo(2)); assertThat(is.read(), equalTo(-1)); assertThat(input.getFilePointer(), lessThan(input.length())); is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(), equalTo(2)); assertThat(is.read(), equalTo(2)); assertThat(is.read(), equalTo(-1)); assertThat(input.getFilePointer(), equalTo(input.length())); is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(0l)); + assertThat(is.actualSizeToRead(), equalTo(0L)); assertThat(is.read(), equalTo(-1)); } @@ -167,28 +167,28 @@ public class InputStreamIndexInputTests extends ESTestCase { assertThat(input.getFilePointer(), lessThan(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(read), equalTo(2)); assertThat(read[0], equalTo((byte) 1)); assertThat(read[1], equalTo((byte) 1)); assertThat(input.getFilePointer(), lessThan(input.length())); is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(read), equalTo(2)); assertThat(read[0], equalTo((byte) 1)); assertThat(read[1], equalTo((byte) 2)); assertThat(input.getFilePointer(), lessThan(input.length())); is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(read), equalTo(2)); assertThat(read[0], equalTo((byte) 2)); assertThat(read[1], equalTo((byte) 2)); assertThat(input.getFilePointer(), equalTo(input.length())); is = new InputStreamIndexInput(input, 2); - assertThat(is.actualSizeToRead(), equalTo(0l)); + assertThat(is.actualSizeToRead(), equalTo(0L)); assertThat(is.read(read), equalTo(-1)); } @@ -210,7 +210,7 @@ public class InputStreamIndexInputTests extends ESTestCase { assertThat(input.getFilePointer(), lessThan(input.length())); InputStreamIndexInput is = new InputStreamIndexInput(input, 4); - assertThat(is.actualSizeToRead(), equalTo(4l)); + assertThat(is.actualSizeToRead(), equalTo(4L)); assertThat(is.read(read), equalTo(4)); assertThat(read[0], equalTo((byte) 1)); assertThat(read[1], equalTo((byte) 1)); @@ -219,14 +219,14 @@ public class InputStreamIndexInputTests extends ESTestCase { assertThat(input.getFilePointer(), lessThan(input.length())); is = new InputStreamIndexInput(input, 4); - assertThat(is.actualSizeToRead(), equalTo(2l)); + assertThat(is.actualSizeToRead(), equalTo(2L)); assertThat(is.read(read), equalTo(2)); assertThat(read[0], equalTo((byte) 2)); assertThat(read[1], equalTo((byte) 2)); assertThat(input.getFilePointer(), equalTo(input.length())); is = new InputStreamIndexInput(input, 4); - assertThat(is.actualSizeToRead(), equalTo(0l)); + assertThat(is.actualSizeToRead(), equalTo(0L)); assertThat(is.read(read), equalTo(-1)); } diff --git a/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java b/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java index fb839f9c49e..7539d2aa635 100644 --- a/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java +++ b/core/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java @@ -93,8 +93,8 @@ public class VersionsTests extends ESTestCase { doc.add(new NumericDocValuesField(VersionFieldMapper.NAME, 1)); writer.updateDocument(new Term(UidFieldMapper.NAME, "1"), doc); directoryReader = reopen(directoryReader); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(1l)); - assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(1l)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(1L)); + assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(1L)); doc = new Document(); Field uid = new Field(UidFieldMapper.NAME, "1", UidFieldMapper.Defaults.FIELD_TYPE); @@ -103,8 +103,8 @@ public class VersionsTests extends ESTestCase { doc.add(version); writer.updateDocument(new Term(UidFieldMapper.NAME, "1"), doc); directoryReader = reopen(directoryReader); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(2l)); - assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(2l)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(2L)); + assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(2L)); // test reuse of uid field doc = new Document(); @@ -114,8 +114,8 @@ public class VersionsTests extends ESTestCase { writer.updateDocument(new Term(UidFieldMapper.NAME, "1"), doc); directoryReader = reopen(directoryReader); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(3l)); - assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(3l)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(3L)); + assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(3L)); writer.deleteDocuments(new Term(UidFieldMapper.NAME, "1")); directoryReader = reopen(directoryReader); @@ -146,16 +146,16 @@ public class VersionsTests extends ESTestCase { writer.updateDocuments(new Term(UidFieldMapper.NAME, "1"), docs); DirectoryReader directoryReader = ElasticsearchDirectoryReader.wrap(DirectoryReader.open(writer, true), new ShardId("foo", "_na_", 1)); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(5l)); - assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(5l)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(5L)); + assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(5L)); version.setLongValue(6L); writer.updateDocuments(new Term(UidFieldMapper.NAME, "1"), docs); version.setLongValue(7L); writer.updateDocuments(new Term(UidFieldMapper.NAME, "1"), docs); directoryReader = reopen(directoryReader); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(7l)); - assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(7l)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(7L)); + assertThat(Versions.loadDocIdAndVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")).version, equalTo(7L)); writer.deleteDocuments(new Term(UidFieldMapper.NAME, "1")); directoryReader = reopen(directoryReader); @@ -184,8 +184,8 @@ public class VersionsTests extends ESTestCase { writer.commit(); directoryReader = reopen(directoryReader); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(1l)); - assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "2")), equalTo(2l)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "1")), equalTo(1L)); + assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "2")), equalTo(2L)); assertThat(Versions.loadVersion(directoryReader, new Term(UidFieldMapper.NAME, "3")), equalTo(Versions.NOT_FOUND)); directoryReader.close(); writer.close(); diff --git a/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java b/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java index e90691ee403..2c4d78adbd0 100644 --- a/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java +++ b/core/src/test/java/org/elasticsearch/common/rounding/TimeZoneRoundingTests.java @@ -101,8 +101,8 @@ public class TimeZoneRoundingTests extends ESTestCase { int timezoneOffset = -2; Rounding tzRounding = TimeZoneRounding.builder(DateTimeUnit.DAY_OF_MONTH).timeZone(DateTimeZone.forOffsetHours(timezoneOffset)) .build(); - assertThat(tzRounding.round(0), equalTo(0l - TimeValue.timeValueHours(24 + timezoneOffset).millis())); - assertThat(tzRounding.nextRoundingValue(0l - TimeValue.timeValueHours(24 + timezoneOffset).millis()), equalTo(0l - TimeValue + assertThat(tzRounding.round(0), equalTo(0L - TimeValue.timeValueHours(24 + timezoneOffset).millis())); + assertThat(tzRounding.nextRoundingValue(0L - TimeValue.timeValueHours(24 + timezoneOffset).millis()), equalTo(0L - TimeValue .timeValueHours(timezoneOffset).millis())); tzRounding = TimeZoneRounding.builder(DateTimeUnit.DAY_OF_MONTH).timeZone(DateTimeZone.forID("-08:00")).build(); @@ -135,8 +135,8 @@ public class TimeZoneRoundingTests extends ESTestCase { public void testTimeTimeZoneRounding() { // hour unit Rounding tzRounding = TimeZoneRounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(DateTimeZone.forOffsetHours(-2)).build(); - assertThat(tzRounding.round(0), equalTo(0l)); - assertThat(tzRounding.nextRoundingValue(0l), equalTo(TimeValue.timeValueHours(1l).getMillis())); + assertThat(tzRounding.round(0), equalTo(0L)); + assertThat(tzRounding.nextRoundingValue(0L), equalTo(TimeValue.timeValueHours(1L).getMillis())); tzRounding = TimeZoneRounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(DateTimeZone.forOffsetHours(-2)).build(); assertThat(tzRounding.round(utc("2009-02-03T01:01:01")), equalTo(utc("2009-02-03T01:00:00"))); diff --git a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java index 70ea1d19cbb..ab6d2818946 100644 --- a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java +++ b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeUnitTests.java @@ -34,47 +34,47 @@ import static org.hamcrest.Matchers.equalTo; */ public class ByteSizeUnitTests extends ESTestCase { public void testBytes() { - assertThat(BYTES.toBytes(1), equalTo(1l)); - assertThat(BYTES.toKB(1024), equalTo(1l)); - assertThat(BYTES.toMB(1024 * 1024), equalTo(1l)); - assertThat(BYTES.toGB(1024 * 1024 * 1024), equalTo(1l)); + assertThat(BYTES.toBytes(1), equalTo(1L)); + assertThat(BYTES.toKB(1024), equalTo(1L)); + assertThat(BYTES.toMB(1024 * 1024), equalTo(1L)); + assertThat(BYTES.toGB(1024 * 1024 * 1024), equalTo(1L)); } public void testKB() { - assertThat(KB.toBytes(1), equalTo(1024l)); - assertThat(KB.toKB(1), equalTo(1l)); - assertThat(KB.toMB(1024), equalTo(1l)); - assertThat(KB.toGB(1024 * 1024), equalTo(1l)); + assertThat(KB.toBytes(1), equalTo(1024L)); + assertThat(KB.toKB(1), equalTo(1L)); + assertThat(KB.toMB(1024), equalTo(1L)); + assertThat(KB.toGB(1024 * 1024), equalTo(1L)); } public void testMB() { - assertThat(MB.toBytes(1), equalTo(1024l * 1024)); - assertThat(MB.toKB(1), equalTo(1024l)); - assertThat(MB.toMB(1), equalTo(1l)); - assertThat(MB.toGB(1024), equalTo(1l)); + assertThat(MB.toBytes(1), equalTo(1024L * 1024)); + assertThat(MB.toKB(1), equalTo(1024L)); + assertThat(MB.toMB(1), equalTo(1L)); + assertThat(MB.toGB(1024), equalTo(1L)); } public void testGB() { - assertThat(GB.toBytes(1), equalTo(1024l * 1024 * 1024)); - assertThat(GB.toKB(1), equalTo(1024l * 1024)); - assertThat(GB.toMB(1), equalTo(1024l)); - assertThat(GB.toGB(1), equalTo(1l)); + assertThat(GB.toBytes(1), equalTo(1024L * 1024 * 1024)); + assertThat(GB.toKB(1), equalTo(1024L * 1024)); + assertThat(GB.toMB(1), equalTo(1024L)); + assertThat(GB.toGB(1), equalTo(1L)); } public void testTB() { - assertThat(TB.toBytes(1), equalTo(1024l * 1024 * 1024 * 1024)); - assertThat(TB.toKB(1), equalTo(1024l * 1024 * 1024)); - assertThat(TB.toMB(1), equalTo(1024l * 1024)); - assertThat(TB.toGB(1), equalTo(1024l)); - assertThat(TB.toTB(1), equalTo(1l)); + assertThat(TB.toBytes(1), equalTo(1024L * 1024 * 1024 * 1024)); + assertThat(TB.toKB(1), equalTo(1024L * 1024 * 1024)); + assertThat(TB.toMB(1), equalTo(1024L * 1024)); + assertThat(TB.toGB(1), equalTo(1024L)); + assertThat(TB.toTB(1), equalTo(1L)); } public void testPB() { - assertThat(PB.toBytes(1), equalTo(1024l * 1024 * 1024 * 1024 * 1024)); - assertThat(PB.toKB(1), equalTo(1024l * 1024 * 1024 * 1024)); - assertThat(PB.toMB(1), equalTo(1024l * 1024 * 1024)); - assertThat(PB.toGB(1), equalTo(1024l * 1024)); - assertThat(PB.toTB(1), equalTo(1024l)); - assertThat(PB.toPB(1), equalTo(1l)); + assertThat(PB.toBytes(1), equalTo(1024L * 1024 * 1024 * 1024 * 1024)); + assertThat(PB.toKB(1), equalTo(1024L * 1024 * 1024 * 1024)); + assertThat(PB.toMB(1), equalTo(1024L * 1024 * 1024)); + assertThat(PB.toGB(1), equalTo(1024L * 1024)); + assertThat(PB.toTB(1), equalTo(1024L)); + assertThat(PB.toPB(1), equalTo(1L)); } } diff --git a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java index 56e61798325..b075e9d56d7 100644 --- a/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java +++ b/core/src/test/java/org/elasticsearch/common/unit/ByteSizeValueTests.java @@ -32,15 +32,15 @@ import static org.hamcrest.Matchers.is; */ public class ByteSizeValueTests extends ESTestCase { public void testActualPeta() { - MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.PB).bytes(), equalTo(4503599627370496l)); + MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.PB).bytes(), equalTo(4503599627370496L)); } public void testActualTera() { - MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.TB).bytes(), equalTo(4398046511104l)); + MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.TB).bytes(), equalTo(4398046511104L)); } public void testActual() { - MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296l)); + MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296L)); } public void testSimple() { diff --git a/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java b/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java index 4c64e04ec34..a6de68b3a46 100644 --- a/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java +++ b/core/src/test/java/org/elasticsearch/common/unit/FuzzinessTests.java @@ -40,7 +40,7 @@ public class FuzzinessTests extends ESTestCase { assertThat(Fuzziness.build(randomFrom(options)).asInt(), equalTo(1)); assertThat(Fuzziness.build(randomFrom(options)).asFloat(), equalTo(1f)); assertThat(Fuzziness.build(randomFrom(options)).asDouble(), equalTo(1d)); - assertThat(Fuzziness.build(randomFrom(options)).asLong(), equalTo(1l)); + assertThat(Fuzziness.build(randomFrom(options)).asLong(), equalTo(1L)); assertThat(Fuzziness.build(randomFrom(options)).asShort(), equalTo((short) 1)); } @@ -143,7 +143,7 @@ public class FuzzinessTests extends ESTestCase { assertThat(Fuzziness.AUTO.asInt(), equalTo(1)); assertThat(Fuzziness.AUTO.asFloat(), equalTo(1f)); assertThat(Fuzziness.AUTO.asDouble(), equalTo(1d)); - assertThat(Fuzziness.AUTO.asLong(), equalTo(1l)); + assertThat(Fuzziness.AUTO.asLong(), equalTo(1L)); assertThat(Fuzziness.AUTO.asShort(), equalTo((short) 1)); assertThat(Fuzziness.AUTO.asTimeValue(), equalTo(TimeValue.parseTimeValue("1ms", TimeValue.timeValueMillis(1), "fuzziness"))); diff --git a/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java index f2f85e0c7f5..b5fc54de7d0 100644 --- a/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java +++ b/core/src/test/java/org/elasticsearch/common/unit/SizeValueTests.java @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.is; public class SizeValueTests extends ESTestCase { public void testThatConversionWorks() { SizeValue sizeValue = new SizeValue(1000); - assertThat(sizeValue.kilo(), is(1l)); + assertThat(sizeValue.kilo(), is(1L)); assertThat(sizeValue.toString(), is("1k")); sizeValue = new SizeValue(1000, SizeUnit.KILO); diff --git a/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java b/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java index 2945d86fe59..20568826d40 100644 --- a/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java +++ b/core/src/test/java/org/elasticsearch/common/unit/TimeValueTests.java @@ -60,7 +60,7 @@ public class TimeValueTests extends ESTestCase { } public void testMinusOne() { - assertThat(new TimeValue(-1).nanos(), lessThan(0l)); + assertThat(new TimeValue(-1).nanos(), lessThan(0L)); } public void testParseTimeValue() { diff --git a/core/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java b/core/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java index 757b79af387..9d17e3328b7 100644 --- a/core/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java +++ b/core/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java @@ -315,8 +315,8 @@ public class ObjectParserTests extends ESTestCase { assertArrayEquals(parse.double_array_field.toArray(), Arrays.asList(2.1d).toArray()); assertEquals(parse.double_field, 2.1d, 0.0d); - assertArrayEquals(parse.long_array_field.toArray(), Arrays.asList(4l).toArray()); - assertEquals(parse.long_field, 4l); + assertArrayEquals(parse.long_array_field.toArray(), Arrays.asList(4L).toArray()); + assertEquals(parse.long_field, 4L); assertArrayEquals(parse.string_array_field.toArray(), Arrays.asList("5").toArray()); assertEquals(parse.string_field, "5"); diff --git a/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java b/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java index bb531c41da8..5cb30a15f1c 100644 --- a/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java +++ b/core/src/test/java/org/elasticsearch/deps/joda/SimpleJodaTests.java @@ -63,7 +63,7 @@ public class SimpleJodaTests extends ESTestCase { DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC); long millis = formatter.parseMillis("1970-01-01T00:00:00Z"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); } public void testUpperBound() { @@ -79,20 +79,20 @@ public class SimpleJodaTests extends ESTestCase { public void testIsoDateFormatDateOptionalTimeUTC() { DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC); long millis = formatter.parseMillis("1970-01-01T00:00:00Z"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); millis = formatter.parseMillis("1970-01-01T00:00:00.001Z"); - assertThat(millis, equalTo(1l)); + assertThat(millis, equalTo(1L)); millis = formatter.parseMillis("1970-01-01T00:00:00.1Z"); - assertThat(millis, equalTo(100l)); + assertThat(millis, equalTo(100L)); millis = formatter.parseMillis("1970-01-01T00:00:00.1"); - assertThat(millis, equalTo(100l)); + assertThat(millis, equalTo(100L)); millis = formatter.parseMillis("1970-01-01T00:00:00"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); millis = formatter.parseMillis("1970-01-01"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); millis = formatter.parseMillis("1970"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); try { formatter.parseMillis("1970 kuku"); @@ -109,15 +109,15 @@ public class SimpleJodaTests extends ESTestCase { public void testIsoVsCustom() { DateTimeFormatter formatter = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC); long millis = formatter.parseMillis("1970-01-01T00:00:00"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); formatter = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").withZone(DateTimeZone.UTC); millis = formatter.parseMillis("1970/01/01 00:00:00"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); FormatDateTimeFormatter formatter2 = Joda.forPattern("yyyy/MM/dd HH:mm:ss"); millis = formatter2.parser().parseMillis("1970/01/01 00:00:00"); - assertThat(millis, equalTo(0l)); + assertThat(millis, equalTo(0L)); } public void testWriteAndParse() { @@ -345,19 +345,19 @@ public class SimpleJodaTests extends ESTestCase { public void testThatEpochParserIsIdempotent() { FormatDateTimeFormatter formatter = Joda.forPattern("epoch_millis"); DateTime dateTime = formatter.parser().parseDateTime("1234567890123"); - assertThat(dateTime.getMillis(), is(1234567890123l)); + assertThat(dateTime.getMillis(), is(1234567890123L)); dateTime = formatter.printer().parseDateTime("1234567890456"); - assertThat(dateTime.getMillis(), is(1234567890456l)); + assertThat(dateTime.getMillis(), is(1234567890456L)); dateTime = formatter.parser().parseDateTime("1234567890789"); - assertThat(dateTime.getMillis(), is(1234567890789l)); + assertThat(dateTime.getMillis(), is(1234567890789L)); FormatDateTimeFormatter secondsFormatter = Joda.forPattern("epoch_second"); DateTime secondsDateTime = secondsFormatter.parser().parseDateTime("1234567890"); - assertThat(secondsDateTime.getMillis(), is(1234567890000l)); + assertThat(secondsDateTime.getMillis(), is(1234567890000L)); secondsDateTime = secondsFormatter.printer().parseDateTime("1234567890"); - assertThat(secondsDateTime.getMillis(), is(1234567890000l)); + assertThat(secondsDateTime.getMillis(), is(1234567890000L)); secondsDateTime = secondsFormatter.parser().parseDateTime("1234567890"); - assertThat(secondsDateTime.getMillis(), is(1234567890000l)); + assertThat(secondsDateTime.getMillis(), is(1234567890000L)); } public void testThatDefaultFormatterChecksForCorrectYearLength() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java index d3b9df8b7ed..c282f3ef183 100644 --- a/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java +++ b/core/src/test/java/org/elasticsearch/discovery/DiscoveryWithServiceDisruptionsIT.java @@ -469,7 +469,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { int shard = MathUtils.mod(Murmur3HashFunction.hash(id), numPrimaries); logger.trace("[{}] indexing id [{}] through node [{}] targeting shard [{}]", name, id, node, shard); IndexResponse response = client.prepareIndex("test", "type", id).setSource("{}").setTimeout("1s").get(); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); ackedDocs.put(id, node); logger.trace("[{}] indexed id [{}] through node [{}]", name, id, node); } catch (ElasticsearchException e) { @@ -728,14 +728,14 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { IndexResponse indexResponse = internalCluster().client(notIsolatedNode).prepareIndex("test", "type").setSource("field", "value").get(); - assertThat(indexResponse.getVersion(), equalTo(1l)); + assertThat(indexResponse.getVersion(), equalTo(1L)); logger.info("Verifying if document exists via node[" + notIsolatedNode + "]"); GetResponse getResponse = internalCluster().client(notIsolatedNode).prepareGet("test", "type", indexResponse.getId()) .setPreference("_local") .get(); assertThat(getResponse.isExists(), is(true)); - assertThat(getResponse.getVersion(), equalTo(1l)); + assertThat(getResponse.getVersion(), equalTo(1L)); assertThat(getResponse.getId(), equalTo(indexResponse.getId())); scheme.stopDisrupting(); @@ -749,7 +749,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { .setPreference("_local") .get(); assertThat(getResponse.isExists(), is(true)); - assertThat(getResponse.getVersion(), equalTo(1l)); + assertThat(getResponse.getVersion(), equalTo(1L)); assertThat(getResponse.getId(), equalTo(indexResponse.getId())); } } @@ -1049,7 +1049,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase { // wait for relocation to finish endRelocationLatch.await(); // now search for the documents and see if we get a reply - assertThat(client().prepareSearch().setSize(0).get().getHits().totalHits(), equalTo(100l)); + assertThat(client().prepareSearch().setSize(0).get().getHits().totalHits(), equalTo(100L)); } public void testIndexImportedFromDataOnlyNodesIfMasterLostDataFolder() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index 52f19d7deee..6f002e8404d 100644 --- a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -157,14 +157,14 @@ public class DocumentActionsIT extends ESIntegTestCase { // test successful SearchResponse countResponse = client().prepareSearch("test").setSize(0).setQuery(termQuery("_type", "type1")).execute().actionGet(); assertNoFailures(countResponse); - assertThat(countResponse.getHits().totalHits(), equalTo(2l)); + assertThat(countResponse.getHits().totalHits(), equalTo(2L)); assertThat(countResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); assertThat(countResponse.getFailedShards(), equalTo(0)); // count with no query is a match all one countResponse = client().prepareSearch("test").setSize(0).execute().actionGet(); assertThat("Failures " + countResponse.getShardFailures(), countResponse.getShardFailures() == null ? 0 : countResponse.getShardFailures().length, equalTo(0)); - assertThat(countResponse.getHits().totalHits(), equalTo(2l)); + assertThat(countResponse.getHits().totalHits(), equalTo(2L)); assertThat(countResponse.getSuccessfulShards(), equalTo(numShards.numPrimaries)); assertThat(countResponse.getFailedShards(), equalTo(0)); } diff --git a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java index a661575cbec..f5e99ab2561 100644 --- a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsIntegrationIT.java @@ -144,32 +144,32 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { // default: FieldStatsResponse response = client().prepareFieldStats().setFields("value").get(); assertAllSuccessful(response); - assertThat(response.getAllFieldStats().get("value").getMinValue(), equalTo(-10l)); - assertThat(response.getAllFieldStats().get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getAllFieldStats().get("value").getMinValue(), equalTo(-10L)); + assertThat(response.getAllFieldStats().get("value").getMaxValue(), equalTo(300L)); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMinValue(), equalTo(-10l)); - assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMinValue(), equalTo(-10L)); + assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMaxValue(), equalTo(300L)); // Level: cluster response = client().prepareFieldStats().setFields("value").setLevel("cluster").get(); assertAllSuccessful(response); - assertThat(response.getAllFieldStats().get("value").getMinValue(), equalTo(-10l)); - assertThat(response.getAllFieldStats().get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getAllFieldStats().get("value").getMinValue(), equalTo(-10L)); + assertThat(response.getAllFieldStats().get("value").getMaxValue(), equalTo(300L)); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMinValue(), equalTo(-10l)); - assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMinValue(), equalTo(-10L)); + assertThat(response.getIndicesMergedFieldStats().get("_all").get("value").getMaxValue(), equalTo(300L)); // Level: indices response = client().prepareFieldStats().setFields("value").setLevel("indices").get(); assertAllSuccessful(response); assertThat(response.getAllFieldStats(), nullValue()); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(3)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(-10l)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMaxValue(), equalTo(100l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200l)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201l)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(-10L)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMaxValue(), equalTo(100L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200L)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201L)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300L)); // Illegal level option: try { @@ -189,8 +189,8 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { )); ensureGreen("test1", "test2"); - client().prepareIndex("test1", "test").setSource("value", 1l).get(); - client().prepareIndex("test1", "test").setSource("value", 2l).get(); + client().prepareIndex("test1", "test").setSource("value", 1L).get(); + client().prepareIndex("test1", "test").setSource("value", 2L).get(); client().prepareIndex("test2", "test").setSource("value", "a").get(); client().prepareIndex("test2", "test").setSource("value", "b").get(); refresh(); @@ -205,8 +205,8 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { FieldStatsResponse response = client().prepareFieldStats().setFields("value").setLevel("indices").get(); assertAllSuccessful(response); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(2)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1l)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMaxValue(), equalTo(2l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1L)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMaxValue(), equalTo(2L)); assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(new BytesRef("a"))); assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(new BytesRef("b"))); } @@ -235,8 +235,8 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { assertAllSuccessful(response); assertThat(response.getAllFieldStats(), nullValue()); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201l)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201L)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300L)); response = client().prepareFieldStats() .setFields("value") @@ -246,10 +246,10 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { assertAllSuccessful(response); assertThat(response.getAllFieldStats(), nullValue()); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(2)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(-10l)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMaxValue(), equalTo(100l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(-10L)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMaxValue(), equalTo(100L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200L)); response = client().prepareFieldStats() .setFields("value") @@ -259,10 +259,10 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { assertAllSuccessful(response); assertThat(response.getAllFieldStats(), nullValue()); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(2)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200l)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201l)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200L)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201L)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300L)); response = client().prepareFieldStats() .setFields("value") @@ -290,8 +290,8 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { assertAllSuccessful(response); assertThat(response.getAllFieldStats(), nullValue()); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200l)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(101L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMaxValue(), equalTo(200L)); response = client().prepareFieldStats() .setFields("value") @@ -301,8 +301,8 @@ public class FieldStatsIntegrationIT extends ESIntegTestCase { assertAllSuccessful(response); assertThat(response.getAllFieldStats(), nullValue()); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201l)); - assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300l)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMinValue(), equalTo(201L)); + assertThat(response.getIndicesMergedFieldStats().get("test3").get("value").getMaxValue(), equalTo(300L)); } public void testIncompatibleFilter() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java index 60cf2ef5dc1..63437d4ebe0 100644 --- a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java +++ b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java @@ -66,9 +66,9 @@ public class FieldStatsTests extends ESSingleNodeTestCase { } public void testLong() { - testNumberRange("field1", "long", 312321312312412l, 312321312312422l); + testNumberRange("field1", "long", 312321312312412L, 312321312312422L); testNumberRange("field1", "long", -5, 5); - testNumberRange("field1", "long", -312321312312422l, -312321312312412l); + testNumberRange("field1", "long", -312321312312422L, -312321312312412L); } public void testString() { @@ -79,8 +79,8 @@ public class FieldStatsTests extends ESSingleNodeTestCase { client().admin().indices().prepareRefresh().get(); FieldStatsResponse result = client().prepareFieldStats().setFields("field").get(); - assertThat(result.getAllFieldStats().get("field").getMaxDoc(), equalTo(11l)); - assertThat(result.getAllFieldStats().get("field").getDocCount(), equalTo(11l)); + assertThat(result.getAllFieldStats().get("field").getMaxDoc(), equalTo(11L)); + assertThat(result.getAllFieldStats().get("field").getDocCount(), equalTo(11L)); assertThat(result.getAllFieldStats().get("field").getDensity(), equalTo(100)); assertThat(result.getAllFieldStats().get("field").getMinValue(), equalTo(new BytesRef(String.format(Locale.ENGLISH, "%03d", 0)))); assertThat(result.getAllFieldStats().get("field").getMaxValue(), equalTo(new BytesRef(String.format(Locale.ENGLISH, "%03d", 10)))); @@ -97,8 +97,8 @@ public class FieldStatsTests extends ESSingleNodeTestCase { client().admin().indices().prepareRefresh().get(); FieldStatsResponse result = client().prepareFieldStats().setFields(fieldName).get(); - assertThat(result.getAllFieldStats().get(fieldName).getMaxDoc(), equalTo(11l)); - assertThat(result.getAllFieldStats().get(fieldName).getDocCount(), equalTo(11l)); + assertThat(result.getAllFieldStats().get(fieldName).getMaxDoc(), equalTo(11L)); + assertThat(result.getAllFieldStats().get(fieldName).getDocCount(), equalTo(11L)); assertThat(result.getAllFieldStats().get(fieldName).getDensity(), equalTo(100)); assertThat(result.getAllFieldStats().get(fieldName).getMinValue(), equalTo(-1d)); assertThat(result.getAllFieldStats().get(fieldName).getMaxValue(), equalTo(9d)); @@ -114,8 +114,8 @@ public class FieldStatsTests extends ESSingleNodeTestCase { client().admin().indices().prepareRefresh().get(); FieldStatsResponse result = client().prepareFieldStats().setFields(fieldName).get(); - assertThat(result.getAllFieldStats().get(fieldName).getMaxDoc(), equalTo(11l)); - assertThat(result.getAllFieldStats().get(fieldName).getDocCount(), equalTo(11l)); + assertThat(result.getAllFieldStats().get(fieldName).getMaxDoc(), equalTo(11L)); + assertThat(result.getAllFieldStats().get(fieldName).getDocCount(), equalTo(11L)); assertThat(result.getAllFieldStats().get(fieldName).getDensity(), equalTo(100)); assertThat(result.getAllFieldStats().get(fieldName).getMinValue(), equalTo(-1f)); assertThat(result.getAllFieldStats().get(fieldName).getMaxValue(), equalTo(9f)); @@ -144,44 +144,44 @@ public class FieldStatsTests extends ESSingleNodeTestCase { public void testMerge() { List stats = new ArrayList<>(); - stats.add(new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l)); - stats.add(new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l)); - stats.add(new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l)); + stats.add(new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L)); + stats.add(new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L)); + stats.add(new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L)); - FieldStats stat = new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l); + FieldStats stat = new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L); for (FieldStats otherStat : stats) { stat.append(otherStat); } - assertThat(stat.getMaxDoc(), equalTo(4l)); - assertThat(stat.getDocCount(), equalTo(4l)); - assertThat(stat.getSumDocFreq(), equalTo(4l)); - assertThat(stat.getSumTotalTermFreq(), equalTo(4l)); + assertThat(stat.getMaxDoc(), equalTo(4L)); + assertThat(stat.getDocCount(), equalTo(4L)); + assertThat(stat.getSumDocFreq(), equalTo(4L)); + assertThat(stat.getSumTotalTermFreq(), equalTo(4L)); } public void testMerge_notAvailable() { List stats = new ArrayList<>(); - stats.add(new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l)); - stats.add(new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l)); - stats.add(new FieldStats.Long(1, 1l, 1l, 1l, 1l, 1l)); + stats.add(new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L)); + stats.add(new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L)); + stats.add(new FieldStats.Long(1, 1L, 1L, 1L, 1L, 1L)); - FieldStats stat = new FieldStats.Long(1, -1l, -1l, -1l, 1l, 1l); + FieldStats stat = new FieldStats.Long(1, -1L, -1L, -1L, 1L, 1L); for (FieldStats otherStat : stats) { stat.append(otherStat); } - assertThat(stat.getMaxDoc(), equalTo(4l)); - assertThat(stat.getDocCount(), equalTo(-1l)); - assertThat(stat.getSumDocFreq(), equalTo(-1l)); - assertThat(stat.getSumTotalTermFreq(), equalTo(-1l)); + assertThat(stat.getMaxDoc(), equalTo(4L)); + assertThat(stat.getDocCount(), equalTo(-1L)); + assertThat(stat.getSumDocFreq(), equalTo(-1L)); + assertThat(stat.getSumTotalTermFreq(), equalTo(-1L)); - stats.add(new FieldStats.Long(1, -1l, -1l, -1l, 1l, 1l)); + stats.add(new FieldStats.Long(1, -1L, -1L, -1L, 1L, 1L)); stat = stats.remove(0); for (FieldStats otherStat : stats) { stat.append(otherStat); } - assertThat(stat.getMaxDoc(), equalTo(4l)); - assertThat(stat.getDocCount(), equalTo(-1l)); - assertThat(stat.getSumDocFreq(), equalTo(-1l)); - assertThat(stat.getSumTotalTermFreq(), equalTo(-1l)); + assertThat(stat.getMaxDoc(), equalTo(4L)); + assertThat(stat.getDocCount(), equalTo(-1L)); + assertThat(stat.getSumDocFreq(), equalTo(-1L)); + assertThat(stat.getSumTotalTermFreq(), equalTo(-1L)); } public void testInvalidField() { @@ -213,9 +213,9 @@ public class FieldStatsTests extends ESSingleNodeTestCase { public void testNumberFiltering() { createIndex("test1", Settings.EMPTY, "type", "value", "type=long"); - client().prepareIndex("test1", "test").setSource("value", 1l).get(); + client().prepareIndex("test1", "test").setSource("value", 1L).get(); createIndex("test2", Settings.EMPTY, "type", "value", "type=long"); - client().prepareIndex("test2", "test").setSource("value", 3l).get(); + client().prepareIndex("test2", "test").setSource("value", 3L).get(); client().admin().indices().prepareRefresh().get(); FieldStatsResponse response = client().prepareFieldStats() @@ -223,8 +223,8 @@ public class FieldStatsTests extends ESSingleNodeTestCase { .setLevel("indices") .get(); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(2)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3L)); response = client().prepareFieldStats() .setFields("value") @@ -246,7 +246,7 @@ public class FieldStatsTests extends ESSingleNodeTestCase { .setLevel("indices") .get(); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1L)); response = client().prepareFieldStats() .setFields("value") @@ -254,7 +254,7 @@ public class FieldStatsTests extends ESSingleNodeTestCase { .setLevel("indices") .get(); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1L)); response = client().prepareFieldStats() .setFields("value") @@ -269,7 +269,7 @@ public class FieldStatsTests extends ESSingleNodeTestCase { .setLevel("indices") .get(); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3l)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3L)); response = client().prepareFieldStats() .setFields("value") @@ -277,7 +277,7 @@ public class FieldStatsTests extends ESSingleNodeTestCase { .setLevel("indices") .get(); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(1)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3l)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3L)); response = client().prepareFieldStats() .setFields("value") @@ -292,8 +292,8 @@ public class FieldStatsTests extends ESSingleNodeTestCase { .setLevel("indices") .get(); assertThat(response.getIndicesMergedFieldStats().size(), equalTo(2)); - assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1l)); - assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3l)); + assertThat(response.getIndicesMergedFieldStats().get("test1").get("value").getMinValue(), equalTo(1L)); + assertThat(response.getIndicesMergedFieldStats().get("test2").get("value").getMinValue(), equalTo(3L)); response = client().prepareFieldStats() .setFields("value") diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java b/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java index 3dbb39d6281..52c8ed2d404 100644 --- a/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java @@ -232,7 +232,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { logger.info("--> verify 1 doc in the index"); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); } logger.info("--> closing test index..."); @@ -250,9 +250,9 @@ public class GatewayIndexStateIT extends ESIntegTestCase { assertThat(health.isTimedOut(), equalTo(false)); logger.info("--> verify 1 doc in the index"); - assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); } } @@ -268,7 +268,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { logger.info("--> verify 1 doc in the index"); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); } assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true)); @@ -328,7 +328,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { logger.info("--> verify 1 doc in the index"); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); } assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(true)); diff --git a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java index 3d90d948ea6..36540355e4d 100644 --- a/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/MetaDataStateFormatTests.java @@ -215,7 +215,7 @@ public class MetaDataStateFormatTests extends ESTestCase { long checksumAfterCorruption; long actualChecksumAfterCorruption; try (ChecksumIndexInput input = dir.openChecksumInput(fileToCorrupt.getFileName().toString(), IOContext.DEFAULT)) { - assertThat(input.getFilePointer(), is(0l)); + assertThat(input.getFilePointer(), is(0L)); input.seek(input.length() - 8); // one long is the checksum... 8 bytes checksumAfterCorruption = input.getChecksum(); actualChecksumAfterCorruption = input.readLong(); diff --git a/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java b/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java index a817b23949f..399ef9badab 100644 --- a/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/QuorumGatewayIT.java @@ -67,7 +67,7 @@ public class QuorumGatewayIT extends ESIntegTestCase { refresh(); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2L); } logger.info("--> restart all nodes"); internalCluster().fullRestart(new RestartCallback() { @@ -89,7 +89,7 @@ public class QuorumGatewayIT extends ESIntegTestCase { activeClient.prepareIndex("test", "type1", "3").setSource(jsonBuilder().startObject().field("field", "value3").endObject()).get(); assertNoFailures(activeClient.admin().indices().prepareRefresh().get()); for (int i = 0; i < 10; i++) { - assertHitCount(activeClient.prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 3l); + assertHitCount(activeClient.prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 3L); } } } @@ -100,7 +100,7 @@ public class QuorumGatewayIT extends ESIntegTestCase { ensureGreen(); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 3l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 3L); } } } diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java index 87a10625c5b..2fce6e44c1c 100644 --- a/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/RecoveryBackwardsCompatibilityIT.java @@ -98,8 +98,8 @@ public class RecoveryBackwardsCompatibilityIT extends ESBackcompatTestCase { final String recoverStateAsJSON = XContentHelper.toString(recoveryState, params); if (!recoveryState.getPrimary()) { RecoveryState.Index index = recoveryState.getIndex(); - assertThat(recoverStateAsJSON, index.recoveredBytes(), equalTo(0l)); - assertThat(recoverStateAsJSON, index.reusedBytes(), greaterThan(0l)); + assertThat(recoverStateAsJSON, index.recoveredBytes(), equalTo(0L)); + assertThat(recoverStateAsJSON, index.reusedBytes(), greaterThan(0L)); assertThat(recoverStateAsJSON, index.reusedBytes(), equalTo(index.totalBytes())); assertThat(recoverStateAsJSON, index.recoveredFileCount(), equalTo(0)); assertThat(recoverStateAsJSON, index.reusedFileCount(), equalTo(index.totalFileCount())); diff --git a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java index e2cb4bc7925..a08a0722a88 100644 --- a/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/RecoveryFromGatewayIT.java @@ -409,7 +409,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { recoveryState.getShardId().getId(), recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); assertThat("no bytes should be recovered", recoveryState.getIndex().recoveredBytes(), equalTo(recovered)); - assertThat("data should have been reused", recoveryState.getIndex().reusedBytes(), greaterThan(0l)); + assertThat("data should have been reused", recoveryState.getIndex().reusedBytes(), greaterThan(0L)); // we have to recover the segments file since we commit the translog ID on engine startup assertThat("all bytes should be reused except of the segments file", recoveryState.getIndex().reusedBytes(), equalTo(recoveryState.getIndex().totalBytes() - recovered)); assertThat("no files should be recovered except of the segments file", recoveryState.getIndex().recoveredFileCount(), equalTo(1)); @@ -421,7 +421,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase { recoveryState.getShardId().getId(), recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); } - assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0l)); + assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0L)); assertThat(recoveryState.getIndex().reusedBytes(), equalTo(recoveryState.getIndex().totalBytes())); assertThat(recoveryState.getIndex().recoveredFileCount(), equalTo(0)); assertThat(recoveryState.getIndex().reusedFileCount(), equalTo(recoveryState.getIndex().totalFileCount())); diff --git a/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java b/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java index e9d6154f71a..6f188ef4280 100644 --- a/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java +++ b/core/src/test/java/org/elasticsearch/gateway/ReusePeerRecoverySharedTest.java @@ -127,7 +127,7 @@ public class ReusePeerRecoverySharedTest { recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); assertThat("no bytes should be recovered", recoveryState.getIndex().recoveredBytes(), equalTo(recovered)); - assertThat("data should have been reused", recoveryState.getIndex().reusedBytes(), greaterThan(0l)); + assertThat("data should have been reused", recoveryState.getIndex().reusedBytes(), greaterThan(0L)); // we have to recover the segments file since we commit the translog ID on engine startup assertThat("all bytes should be reused except of the segments file", recoveryState.getIndex().reusedBytes(), equalTo(recoveryState.getIndex().totalBytes() - recovered)); @@ -142,7 +142,7 @@ public class ReusePeerRecoverySharedTest { recoveryState.getShardId().getId(), recoveryState.getSourceNode().name(), recoveryState.getTargetNode().name(), recoveryState.getIndex().recoveredBytes(), recoveryState.getIndex().reusedBytes()); } - assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0l)); + assertThat(recoveryState.getIndex().recoveredBytes(), equalTo(0L)); assertThat(recoveryState.getIndex().reusedBytes(), equalTo(recoveryState.getIndex().totalBytes())); assertThat(recoveryState.getIndex().recoveredFileCount(), equalTo(0)); assertThat(recoveryState.getIndex().reusedFileCount(), equalTo(recoveryState.getIndex().totalFileCount())); diff --git a/core/src/test/java/org/elasticsearch/get/GetActionIT.java b/core/src/test/java/org/elasticsearch/get/GetActionIT.java index 43a4e4f1470..f0f90311907 100644 --- a/core/src/test/java/org/elasticsearch/get/GetActionIT.java +++ b/core/src/test/java/org/elasticsearch/get/GetActionIT.java @@ -462,12 +462,12 @@ public class GetActionIT extends ESIntegTestCase { response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(Versions.MATCH_ANY).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).get(); @@ -483,13 +483,13 @@ public class GetActionIT extends ESIntegTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); response = client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(2).setRealtime(false).get(); @@ -507,7 +507,7 @@ public class GetActionIT extends ESIntegTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).get(); @@ -520,7 +520,7 @@ public class GetActionIT extends ESIntegTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); // From Lucene index: refresh(); @@ -529,7 +529,7 @@ public class GetActionIT extends ESIntegTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); try { client().prepareGet(indexOrAlias(), "type1", "1").setVersion(1).setRealtime(false).get(); @@ -542,7 +542,7 @@ public class GetActionIT extends ESIntegTestCase { assertThat(response.isExists(), equalTo(true)); assertThat(response.getId(), equalTo("1")); assertThat(response.getIndex(), equalTo("test")); - assertThat(response.getVersion(), equalTo(2l)); + assertThat(response.getVersion(), equalTo(2L)); } public void testMultiGetWithVersion() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java b/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java index f227a9a03b4..b6cf9d91894 100644 --- a/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java +++ b/core/src/test/java/org/elasticsearch/http/netty/HttpPublishPortIT.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.InetSocketTransportAddress; -import org.elasticsearch.node.Node; +import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; @@ -41,7 +41,7 @@ public class HttpPublishPortIT extends ESIntegTestCase { return Settings.settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) .put(NetworkModule.HTTP_ENABLED.getKey(), true) - .put("http.publish_port", 9080) + .put(HttpTransportSettings.SETTING_HTTP_PUBLISH_PORT.getKey(), 9080) .build(); } diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java index 017eef345a7..6311e56834d 100644 --- a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java +++ b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpChannelTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.MockBigArrays; +import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; @@ -81,7 +82,7 @@ public class NettyHttpChannelTests extends ESTestCase { public void testCorsEnabledWithoutAllowOrigins() { // Set up a HTTP transport with only the CORS enabled setting Settings settings = Settings.builder() - .put(NettyHttpServerTransport.SETTING_CORS_ENABLED.getKey(), true) + .put(HttpTransportSettings.SETTING_CORS_ENABLED.getKey(), true) .build(); httpServerTransport = new NettyHttpServerTransport(settings, networkService, bigArrays, threadPool); HttpRequest httpRequest = new TestHttpRequest(); @@ -104,8 +105,8 @@ public class NettyHttpChannelTests extends ESTestCase { public void testCorsEnabledWithAllowOrigins() { // create a http transport with CORS enabled and allow origin configured Settings settings = Settings.builder() - .put(NettyHttpServerTransport.SETTING_CORS_ENABLED.getKey(), true) - .put(NettyHttpServerTransport.SETTING_CORS_ALLOW_ORIGIN, "remote-host") + .put(HttpTransportSettings.SETTING_CORS_ENABLED.getKey(), true) + .put(HttpTransportSettings.SETTING_CORS_ALLOW_ORIGIN.getKey(), "remote-host") .build(); httpServerTransport = new NettyHttpServerTransport(settings, networkService, bigArrays, threadPool); HttpRequest httpRequest = new TestHttpRequest(); diff --git a/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java b/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java index d54d1a953bc..837d998dfec 100644 --- a/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java +++ b/core/src/test/java/org/elasticsearch/index/VersionTypeTests.java @@ -192,24 +192,24 @@ public class VersionTypeTests extends ESTestCase { } public void testUpdateVersion() { - assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_SET, 10), equalTo(1l)); - assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_FOUND, 10), equalTo(1l)); - assertThat(VersionType.INTERNAL.updateVersion(1, 1), equalTo(2l)); - assertThat(VersionType.INTERNAL.updateVersion(2, Versions.MATCH_ANY), equalTo(3l)); + assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_SET, 10), equalTo(1L)); + assertThat(VersionType.INTERNAL.updateVersion(Versions.NOT_FOUND, 10), equalTo(1L)); + assertThat(VersionType.INTERNAL.updateVersion(1, 1), equalTo(2L)); + assertThat(VersionType.INTERNAL.updateVersion(2, Versions.MATCH_ANY), equalTo(3L)); - assertThat(VersionType.EXTERNAL.updateVersion(Versions.NOT_SET, 10), equalTo(10l)); - assertThat(VersionType.EXTERNAL.updateVersion(Versions.NOT_FOUND, 10), equalTo(10l)); - assertThat(VersionType.EXTERNAL.updateVersion(1, 10), equalTo(10l)); + assertThat(VersionType.EXTERNAL.updateVersion(Versions.NOT_SET, 10), equalTo(10L)); + assertThat(VersionType.EXTERNAL.updateVersion(Versions.NOT_FOUND, 10), equalTo(10L)); + assertThat(VersionType.EXTERNAL.updateVersion(1, 10), equalTo(10L)); - assertThat(VersionType.EXTERNAL_GTE.updateVersion(Versions.NOT_SET, 10), equalTo(10l)); - assertThat(VersionType.EXTERNAL_GTE.updateVersion(Versions.NOT_FOUND, 10), equalTo(10l)); - assertThat(VersionType.EXTERNAL_GTE.updateVersion(1, 10), equalTo(10l)); - assertThat(VersionType.EXTERNAL_GTE.updateVersion(10, 10), equalTo(10l)); + assertThat(VersionType.EXTERNAL_GTE.updateVersion(Versions.NOT_SET, 10), equalTo(10L)); + assertThat(VersionType.EXTERNAL_GTE.updateVersion(Versions.NOT_FOUND, 10), equalTo(10L)); + assertThat(VersionType.EXTERNAL_GTE.updateVersion(1, 10), equalTo(10L)); + assertThat(VersionType.EXTERNAL_GTE.updateVersion(10, 10), equalTo(10L)); - assertThat(VersionType.FORCE.updateVersion(Versions.NOT_SET, 10), equalTo(10l)); - assertThat(VersionType.FORCE.updateVersion(Versions.NOT_FOUND, 10), equalTo(10l)); - assertThat(VersionType.FORCE.updateVersion(11, 10), equalTo(10l)); + assertThat(VersionType.FORCE.updateVersion(Versions.NOT_SET, 10), equalTo(10L)); + assertThat(VersionType.FORCE.updateVersion(Versions.NOT_FOUND, 10), equalTo(10L)); + assertThat(VersionType.FORCE.updateVersion(11, 10), equalTo(10L)); // Old indexing code // if (index.versionType() == VersionType.INTERNAL) { // internal version type 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 30e0ff5cb38..cd39806e222 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -293,8 +293,8 @@ public class InternalEngineTests extends ESTestCase { Engine engine = createEngine(defaultSettings, store, createTempDir(), NoMergePolicy.INSTANCE)) { List segments = engine.segments(false); assertThat(segments.isEmpty(), equalTo(true)); - assertThat(engine.segmentsStats().getCount(), equalTo(0l)); - assertThat(engine.segmentsStats().getMemoryInBytes(), equalTo(0l)); + assertThat(engine.segmentsStats().getCount(), equalTo(0L)); + assertThat(engine.segmentsStats().getMemoryInBytes(), equalTo(0L)); // create a doc and refresh ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocumentWithTextField(), B_1, null); @@ -307,12 +307,12 @@ public class InternalEngineTests extends ESTestCase { segments = engine.segments(false); assertThat(segments.size(), equalTo(1)); SegmentsStats stats = engine.segmentsStats(); - assertThat(stats.getCount(), equalTo(1l)); - assertThat(stats.getTermsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getTermVectorsMemoryInBytes(), equalTo(0l)); - assertThat(stats.getNormsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0l)); + assertThat(stats.getCount(), equalTo(1L)); + assertThat(stats.getTermsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getTermVectorsMemoryInBytes(), equalTo(0L)); + assertThat(stats.getNormsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0L)); assertThat(segments.get(0).isCommitted(), equalTo(false)); assertThat(segments.get(0).isSearch(), equalTo(true)); assertThat(segments.get(0).getNumDocs(), equalTo(2)); @@ -324,7 +324,7 @@ public class InternalEngineTests extends ESTestCase { segments = engine.segments(false); assertThat(segments.size(), equalTo(1)); - assertThat(engine.segmentsStats().getCount(), equalTo(1l)); + assertThat(engine.segmentsStats().getCount(), equalTo(1L)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); assertThat(segments.get(0).getNumDocs(), equalTo(2)); @@ -337,10 +337,10 @@ public class InternalEngineTests extends ESTestCase { segments = engine.segments(false); assertThat(segments.size(), equalTo(2)); - assertThat(engine.segmentsStats().getCount(), equalTo(2l)); + assertThat(engine.segmentsStats().getCount(), equalTo(2L)); assertThat(engine.segmentsStats().getTermsMemoryInBytes(), greaterThan(stats.getTermsMemoryInBytes())); assertThat(engine.segmentsStats().getStoredFieldsMemoryInBytes(), greaterThan(stats.getStoredFieldsMemoryInBytes())); - assertThat(engine.segmentsStats().getTermVectorsMemoryInBytes(), equalTo(0l)); + assertThat(engine.segmentsStats().getTermVectorsMemoryInBytes(), equalTo(0L)); assertThat(engine.segmentsStats().getNormsMemoryInBytes(), greaterThan(stats.getNormsMemoryInBytes())); assertThat(engine.segmentsStats().getDocValuesMemoryInBytes(), greaterThan(stats.getDocValuesMemoryInBytes())); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); @@ -363,7 +363,7 @@ public class InternalEngineTests extends ESTestCase { segments = engine.segments(false); assertThat(segments.size(), equalTo(2)); - assertThat(engine.segmentsStats().getCount(), equalTo(2l)); + assertThat(engine.segmentsStats().getCount(), equalTo(2L)); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); @@ -384,7 +384,7 @@ public class InternalEngineTests extends ESTestCase { segments = engine.segments(false); assertThat(segments.size(), equalTo(3)); - assertThat(engine.segmentsStats().getCount(), equalTo(3l)); + assertThat(engine.segmentsStats().getCount(), equalTo(3L)); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); @@ -494,7 +494,7 @@ public class InternalEngineTests extends ESTestCase { engine.index(new Engine.Index(newUid("1"), doc)); CommitStats stats1 = engine.commitStats(); - assertThat(stats1.getGeneration(), greaterThan(0l)); + assertThat(stats1.getGeneration(), greaterThan(0L)); assertThat(stats1.getId(), notNullValue()); assertThat(stats1.getUserData(), hasKey(Translog.TRANSLOG_GENERATION_KEY)); @@ -895,46 +895,46 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED); engine.index(create); - assertThat(create.version(), equalTo(1l)); + assertThat(create.version(), equalTo(1L)); create = new Engine.Index(newUid("1"), doc, create.version(), create.versionType().versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(create); - assertThat(create.version(), equalTo(1l)); + assertThat(create.version(), equalTo(1L)); } public void testVersioningNewIndex() { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); index = new Engine.Index(newUid("1"), doc, index.version(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); } public void testExternalVersioningNewIndex() { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc, 12, VersionType.EXTERNAL, PRIMARY, 0); engine.index(index); - assertThat(index.version(), equalTo(12l)); + assertThat(index.version(), equalTo(12L)); index = new Engine.Index(newUid("1"), doc, index.version(), index.versionType().versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(index); - assertThat(index.version(), equalTo(12l)); + assertThat(index.version(), equalTo(12L)); } public void testVersioningIndexConflict() { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); - index = new Engine.Index(newUid("1"), doc, 1l, VersionType.INTERNAL, Engine.Operation.Origin.PRIMARY, 0); + index = new Engine.Index(newUid("1"), doc, 1L, VersionType.INTERNAL, Engine.Operation.Origin.PRIMARY, 0); try { engine.index(index); fail(); @@ -943,7 +943,7 @@ public class InternalEngineTests extends ESTestCase { } // future versions should not work as well - index = new Engine.Index(newUid("1"), doc, 3l, VersionType.INTERNAL, PRIMARY, 0); + index = new Engine.Index(newUid("1"), doc, 3L, VersionType.INTERNAL, PRIMARY, 0); try { engine.index(index); fail(); @@ -956,11 +956,11 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc, 12, VersionType.EXTERNAL, PRIMARY, 0); engine.index(index); - assertThat(index.version(), equalTo(12l)); + assertThat(index.version(), equalTo(12L)); index = new Engine.Index(newUid("1"), doc, 14, VersionType.EXTERNAL, PRIMARY, 0); engine.index(index); - assertThat(index.version(), equalTo(14l)); + assertThat(index.version(), equalTo(14L)); index = new Engine.Index(newUid("1"), doc, 13, VersionType.EXTERNAL, PRIMARY, 0); try { @@ -975,15 +975,15 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); engine.flush(); - index = new Engine.Index(newUid("1"), doc, 1l, VersionType.INTERNAL, PRIMARY, 0); + index = new Engine.Index(newUid("1"), doc, 1L, VersionType.INTERNAL, PRIMARY, 0); try { engine.index(index); fail(); @@ -992,7 +992,7 @@ public class InternalEngineTests extends ESTestCase { } // future versions should not work as well - index = new Engine.Index(newUid("1"), doc, 3l, VersionType.INTERNAL, PRIMARY, 0); + index = new Engine.Index(newUid("1"), doc, 3L, VersionType.INTERNAL, PRIMARY, 0); try { engine.index(index); fail(); @@ -1005,11 +1005,11 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc, 12, VersionType.EXTERNAL, PRIMARY, 0); engine.index(index); - assertThat(index.version(), equalTo(12l)); + assertThat(index.version(), equalTo(12L)); index = new Engine.Index(newUid("1"), doc, 14, VersionType.EXTERNAL, PRIMARY, 0); engine.index(index); - assertThat(index.version(), equalTo(14l)); + assertThat(index.version(), equalTo(14L)); engine.flush(); @@ -1121,13 +1121,13 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); - Engine.Delete delete = new Engine.Delete("test", "1", newUid("1"), 1l, VersionType.INTERNAL, PRIMARY, 0, false); + Engine.Delete delete = new Engine.Delete("test", "1", newUid("1"), 1L, VersionType.INTERNAL, PRIMARY, 0, false); try { engine.delete(delete); fail(); @@ -1136,7 +1136,7 @@ public class InternalEngineTests extends ESTestCase { } // future versions should not work as well - delete = new Engine.Delete("test", "1", newUid("1"), 3l, VersionType.INTERNAL, PRIMARY, 0, false); + delete = new Engine.Delete("test", "1", newUid("1"), 3L, VersionType.INTERNAL, PRIMARY, 0, false); try { engine.delete(delete); fail(); @@ -1145,12 +1145,12 @@ public class InternalEngineTests extends ESTestCase { } // now actually delete - delete = new Engine.Delete("test", "1", newUid("1"), 2l, VersionType.INTERNAL, PRIMARY, 0, false); + delete = new Engine.Delete("test", "1", newUid("1"), 2L, VersionType.INTERNAL, PRIMARY, 0, false); engine.delete(delete); - assertThat(delete.version(), equalTo(3l)); + assertThat(delete.version(), equalTo(3L)); // now check if we can index to a delete doc with version - index = new Engine.Index(newUid("1"), doc, 2l, VersionType.INTERNAL, PRIMARY, 0); + index = new Engine.Index(newUid("1"), doc, 2L, VersionType.INTERNAL, PRIMARY, 0); try { engine.index(index); fail(); @@ -1171,15 +1171,15 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); engine.flush(); - Engine.Delete delete = new Engine.Delete("test", "1", newUid("1"), 1l, VersionType.INTERNAL, PRIMARY, 0, false); + Engine.Delete delete = new Engine.Delete("test", "1", newUid("1"), 1L, VersionType.INTERNAL, PRIMARY, 0, false); try { engine.delete(delete); fail(); @@ -1188,7 +1188,7 @@ public class InternalEngineTests extends ESTestCase { } // future versions should not work as well - delete = new Engine.Delete("test", "1", newUid("1"), 3l, VersionType.INTERNAL, PRIMARY, 0, false); + delete = new Engine.Delete("test", "1", newUid("1"), 3L, VersionType.INTERNAL, PRIMARY, 0, false); try { engine.delete(delete); fail(); @@ -1199,14 +1199,14 @@ public class InternalEngineTests extends ESTestCase { engine.flush(); // now actually delete - delete = new Engine.Delete("test", "1", newUid("1"), 2l, VersionType.INTERNAL, PRIMARY, 0, false); + delete = new Engine.Delete("test", "1", newUid("1"), 2L, VersionType.INTERNAL, PRIMARY, 0, false); engine.delete(delete); - assertThat(delete.version(), equalTo(3l)); + assertThat(delete.version(), equalTo(3L)); engine.flush(); // now check if we can index to a delete doc with version - index = new Engine.Index(newUid("1"), doc, 2l, VersionType.INTERNAL, PRIMARY, 0); + index = new Engine.Index(newUid("1"), doc, 2L, VersionType.INTERNAL, PRIMARY, 0); try { engine.index(index); fail(); @@ -1227,7 +1227,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, 0); engine.index(create); - assertThat(create.version(), equalTo(1l)); + assertThat(create.version(), equalTo(1L)); create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, 0); try { @@ -1242,7 +1242,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index create = new Engine.Index(newUid("1"), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, 0); engine.index(create); - assertThat(create.version(), equalTo(1l)); + assertThat(create.version(), equalTo(1L)); engine.flush(); @@ -1259,19 +1259,19 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); // apply the second index to the replica, should work fine index = new Engine.Index(newUid("1"), doc, index.version(), VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); // now, the old one should not work - index = new Engine.Index(newUid("1"), doc, 1l, VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); + index = new Engine.Index(newUid("1"), doc, 1L, VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); try { replicaEngine.index(index); fail(); @@ -1281,10 +1281,10 @@ public class InternalEngineTests extends ESTestCase { // second version on replica should fail as well try { - index = new Engine.Index(newUid("1"), doc, 2l + index = new Engine.Index(newUid("1"), doc, 2L , VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); } catch (VersionConflictEngineException e) { // all is well } @@ -1294,33 +1294,33 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocument(), B_1, null); Engine.Index index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); // apply the first index to the replica, should work fine - index = new Engine.Index(newUid("1"), doc, 1l + index = new Engine.Index(newUid("1"), doc, 1L , VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(index); - assertThat(index.version(), equalTo(1l)); + assertThat(index.version(), equalTo(1L)); // index it again index = new Engine.Index(newUid("1"), doc); engine.index(index); - assertThat(index.version(), equalTo(2l)); + assertThat(index.version(), equalTo(2L)); // now delete it Engine.Delete delete = new Engine.Delete("test", "1", newUid("1")); engine.delete(delete); - assertThat(delete.version(), equalTo(3l)); + assertThat(delete.version(), equalTo(3L)); // apply the delete on the replica (skipping the second index) - delete = new Engine.Delete("test", "1", newUid("1"), 3l + delete = new Engine.Delete("test", "1", newUid("1"), 3L , VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0, false); replicaEngine.delete(delete); - assertThat(delete.version(), equalTo(3l)); + assertThat(delete.version(), equalTo(3L)); // second time delete with same version should fail try { - delete = new Engine.Delete("test", "1", newUid("1"), 3l + delete = new Engine.Delete("test", "1", newUid("1"), 3L , VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0, false); replicaEngine.delete(delete); fail("excepted VersionConflictEngineException to be thrown"); @@ -1330,7 +1330,7 @@ public class InternalEngineTests extends ESTestCase { // now do the second index on the replica, it should fail try { - index = new Engine.Index(newUid("1"), doc, 2l, VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); + index = new Engine.Index(newUid("1"), doc, 2L, VersionType.INTERNAL.versionTypeForReplicationAndRecovery(), REPLICA, 0); replicaEngine.index(index); fail("excepted VersionConflictEngineException to be thrown"); } catch (VersionConflictEngineException e) { @@ -1610,7 +1610,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null); Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime()); engine.index(firstIndexRequest); - assertThat(firstIndexRequest.version(), equalTo(1l)); + assertThat(firstIndexRequest.version(), equalTo(1L)); } engine.refresh("test"); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { @@ -1662,7 +1662,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null); Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime()); engine.index(firstIndexRequest); - assertThat(firstIndexRequest.version(), equalTo(1l)); + assertThat(firstIndexRequest.version(), equalTo(1L)); } engine.refresh("test"); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { @@ -1757,7 +1757,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument("extra" + Integer.toString(i), "extra" + Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null); Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime()); engine.index(firstIndexRequest); - assertThat(firstIndexRequest.version(), equalTo(1l)); + assertThat(firstIndexRequest.version(), equalTo(1L)); } engine.refresh("test"); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { @@ -1786,7 +1786,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null); Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime()); engine.index(firstIndexRequest); - assertThat(firstIndexRequest.version(), equalTo(1l)); + assertThat(firstIndexRequest.version(), equalTo(1L)); } engine.refresh("test"); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { @@ -1835,7 +1835,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument(uuidValue, Integer.toString(randomId), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null); Engine.Index firstIndexRequest = new Engine.Index(newUid(uuidValue), doc, 1, VersionType.EXTERNAL, PRIMARY, System.nanoTime()); engine.index(firstIndexRequest); - assertThat(firstIndexRequest.version(), equalTo(1l)); + assertThat(firstIndexRequest.version(), equalTo(1L)); if (flush) { engine.flush(); } @@ -1844,7 +1844,7 @@ public class InternalEngineTests extends ESTestCase { Engine.Index idxRequest = new Engine.Index(newUid(uuidValue), doc, 2, VersionType.EXTERNAL, PRIMARY, System.nanoTime()); engine.index(idxRequest); engine.refresh("test"); - assertThat(idxRequest.version(), equalTo(2l)); + assertThat(idxRequest.version(), equalTo(2L)); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { TopDocs topDocs = searcher.searcher().search(new MatchAllDocsQuery(), numDocs + 1); assertThat(topDocs.totalHits, equalTo(numDocs + 1)); @@ -1909,7 +1909,7 @@ public class InternalEngineTests extends ESTestCase { ParsedDocument doc = testParsedDocument(Integer.toString(i), Integer.toString(i), "test", null, -1, -1, testDocument(), new BytesArray("{}"), null); Engine.Index firstIndexRequest = new Engine.Index(newUid(Integer.toString(i)), doc, Versions.MATCH_DELETED, VersionType.INTERNAL, PRIMARY, System.nanoTime()); engine.index(firstIndexRequest); - assertThat(firstIndexRequest.version(), equalTo(1l)); + assertThat(firstIndexRequest.version(), equalTo(1L)); } engine.refresh("test"); try (Engine.Searcher searcher = engine.acquireSearcher("test")) { diff --git a/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java index 93a0b4345fa..6b81512b796 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/ShadowEngineTests.java @@ -252,7 +252,7 @@ public class ShadowEngineTests extends ESTestCase { primaryEngine.index(new Engine.Index(newUid("1"), doc)); CommitStats stats1 = replicaEngine.commitStats(); - assertThat(stats1.getGeneration(), greaterThan(0l)); + assertThat(stats1.getGeneration(), greaterThan(0L)); assertThat(stats1.getId(), notNullValue()); assertThat(stats1.getUserData(), hasKey(Translog.TRANSLOG_GENERATION_KEY)); @@ -276,8 +276,8 @@ public class ShadowEngineTests extends ESTestCase { primaryEngine = createInternalEngine(defaultSettings, store, createTempDir(), NoMergePolicy.INSTANCE); List segments = primaryEngine.segments(false); assertThat(segments.isEmpty(), equalTo(true)); - assertThat(primaryEngine.segmentsStats().getCount(), equalTo(0l)); - assertThat(primaryEngine.segmentsStats().getMemoryInBytes(), equalTo(0l)); + assertThat(primaryEngine.segmentsStats().getCount(), equalTo(0L)); + assertThat(primaryEngine.segmentsStats().getMemoryInBytes(), equalTo(0L)); // create a doc and refresh ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, testDocumentWithTextField(), B_1, null); @@ -290,12 +290,12 @@ public class ShadowEngineTests extends ESTestCase { segments = primaryEngine.segments(false); assertThat(segments.size(), equalTo(1)); SegmentsStats stats = primaryEngine.segmentsStats(); - assertThat(stats.getCount(), equalTo(1l)); - assertThat(stats.getTermsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getTermVectorsMemoryInBytes(), equalTo(0l)); - assertThat(stats.getNormsMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0l)); + assertThat(stats.getCount(), equalTo(1L)); + assertThat(stats.getTermsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getTermVectorsMemoryInBytes(), equalTo(0L)); + assertThat(stats.getNormsMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0L)); assertThat(segments.get(0).isCommitted(), equalTo(false)); assertThat(segments.get(0).isSearch(), equalTo(true)); assertThat(segments.get(0).getNumDocs(), equalTo(2)); @@ -307,12 +307,12 @@ public class ShadowEngineTests extends ESTestCase { segments = replicaEngine.segments(false); assertThat(segments.size(), equalTo(0)); stats = replicaEngine.segmentsStats(); - assertThat(stats.getCount(), equalTo(0l)); - assertThat(stats.getTermsMemoryInBytes(), equalTo(0l)); - assertThat(stats.getStoredFieldsMemoryInBytes(), equalTo(0l)); - assertThat(stats.getTermVectorsMemoryInBytes(), equalTo(0l)); - assertThat(stats.getNormsMemoryInBytes(), equalTo(0l)); - assertThat(stats.getDocValuesMemoryInBytes(), equalTo(0l)); + assertThat(stats.getCount(), equalTo(0L)); + assertThat(stats.getTermsMemoryInBytes(), equalTo(0L)); + assertThat(stats.getStoredFieldsMemoryInBytes(), equalTo(0L)); + assertThat(stats.getTermVectorsMemoryInBytes(), equalTo(0L)); + assertThat(stats.getNormsMemoryInBytes(), equalTo(0L)); + assertThat(stats.getDocValuesMemoryInBytes(), equalTo(0L)); assertThat(segments.size(), equalTo(0)); // flush the primary engine @@ -323,7 +323,7 @@ public class ShadowEngineTests extends ESTestCase { // Check that the primary AND replica sees segments now segments = primaryEngine.segments(false); assertThat(segments.size(), equalTo(1)); - assertThat(primaryEngine.segmentsStats().getCount(), equalTo(1l)); + assertThat(primaryEngine.segmentsStats().getCount(), equalTo(1L)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); assertThat(segments.get(0).getNumDocs(), equalTo(2)); @@ -332,7 +332,7 @@ public class ShadowEngineTests extends ESTestCase { segments = replicaEngine.segments(false); assertThat(segments.size(), equalTo(1)); - assertThat(replicaEngine.segmentsStats().getCount(), equalTo(1l)); + assertThat(replicaEngine.segmentsStats().getCount(), equalTo(1L)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); assertThat(segments.get(0).getNumDocs(), equalTo(2)); @@ -346,10 +346,10 @@ public class ShadowEngineTests extends ESTestCase { segments = primaryEngine.segments(false); assertThat(segments.size(), equalTo(2)); - assertThat(primaryEngine.segmentsStats().getCount(), equalTo(2l)); + assertThat(primaryEngine.segmentsStats().getCount(), equalTo(2L)); assertThat(primaryEngine.segmentsStats().getTermsMemoryInBytes(), greaterThan(stats.getTermsMemoryInBytes())); assertThat(primaryEngine.segmentsStats().getStoredFieldsMemoryInBytes(), greaterThan(stats.getStoredFieldsMemoryInBytes())); - assertThat(primaryEngine.segmentsStats().getTermVectorsMemoryInBytes(), equalTo(0l)); + assertThat(primaryEngine.segmentsStats().getTermVectorsMemoryInBytes(), equalTo(0L)); assertThat(primaryEngine.segmentsStats().getNormsMemoryInBytes(), greaterThan(stats.getNormsMemoryInBytes())); assertThat(primaryEngine.segmentsStats().getDocValuesMemoryInBytes(), greaterThan(stats.getDocValuesMemoryInBytes())); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); @@ -370,10 +370,10 @@ public class ShadowEngineTests extends ESTestCase { segments = replicaEngine.segments(false); assertThat(segments.size(), equalTo(2)); - assertThat(replicaEngine.segmentsStats().getCount(), equalTo(2l)); + assertThat(replicaEngine.segmentsStats().getCount(), equalTo(2L)); assertThat(replicaEngine.segmentsStats().getTermsMemoryInBytes(), greaterThan(stats.getTermsMemoryInBytes())); assertThat(replicaEngine.segmentsStats().getStoredFieldsMemoryInBytes(), greaterThan(stats.getStoredFieldsMemoryInBytes())); - assertThat(replicaEngine.segmentsStats().getTermVectorsMemoryInBytes(), equalTo(0l)); + assertThat(replicaEngine.segmentsStats().getTermVectorsMemoryInBytes(), equalTo(0L)); assertThat(replicaEngine.segmentsStats().getNormsMemoryInBytes(), greaterThan(stats.getNormsMemoryInBytes())); assertThat(replicaEngine.segmentsStats().getDocValuesMemoryInBytes(), greaterThan(stats.getDocValuesMemoryInBytes())); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); @@ -393,7 +393,7 @@ public class ShadowEngineTests extends ESTestCase { segments = primaryEngine.segments(false); assertThat(segments.size(), equalTo(2)); - assertThat(primaryEngine.segmentsStats().getCount(), equalTo(2l)); + assertThat(primaryEngine.segmentsStats().getCount(), equalTo(2L)); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); @@ -416,7 +416,7 @@ public class ShadowEngineTests extends ESTestCase { segments = primaryEngine.segments(false); assertThat(segments.size(), equalTo(3)); - assertThat(primaryEngine.segmentsStats().getCount(), equalTo(3l)); + assertThat(primaryEngine.segmentsStats().getCount(), equalTo(3L)); assertThat(segments.get(0).getGeneration() < segments.get(1).getGeneration(), equalTo(true)); assertThat(segments.get(0).isCommitted(), equalTo(true)); assertThat(segments.get(0).isSearch(), equalTo(true)); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java index 743be637853..37e530cc7f4 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataImplTestCase.java @@ -206,7 +206,7 @@ public abstract class AbstractFieldDataImplTestCase extends AbstractFieldDataTes IndexFieldData indexFieldData = getForField("value"); AtomicFieldData fieldData = indexFieldData.load(refreshReader()); // Some impls (FST) return size 0 and some (PagedBytes) do take size in the case no actual data is loaded - assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(0l)); + assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(0L)); SortedBinaryDocValues bytesValues = fieldData.getBytesValues(); diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTestCase.java index 012e383ac1e..0bdbfb58722 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTestCase.java @@ -174,7 +174,7 @@ public abstract class AbstractFieldDataTestCase extends ESSingleNodeTestCase { AtomicFieldData previous = null; for (int i = 0; i < max; i++) { AtomicFieldData current = fieldData.load(readerContext); - assertThat(current.ramBytesUsed(), equalTo(0l)); + assertThat(current.ramBytesUsed(), equalTo(0L)); if (previous != null) { assertThat(current, not(sameInstance(previous))); } diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java index ceb4ce66bcb..31a17a684ee 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/AbstractStringFieldDataTestCase.java @@ -485,17 +485,17 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI values.setDocument(0); assertThat(values.cardinality(), equalTo(2)); long ord = values.nextOrd(); - assertThat(ord, equalTo(3l)); + assertThat(ord, equalTo(3L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("02")); ord = values.nextOrd(); - assertThat(ord, equalTo(5l)); + assertThat(ord, equalTo(5L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("04")); values.setDocument(1); assertThat(values.cardinality(), equalTo(0)); values.setDocument(2); assertThat(values.cardinality(), equalTo(1)); ord = values.nextOrd(); - assertThat(ord, equalTo(4l)); + assertThat(ord, equalTo(4L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("03")); // Second segment @@ -506,37 +506,37 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI values.setDocument(0); assertThat(values.cardinality(), equalTo(3)); ord = values.nextOrd(); - assertThat(ord, equalTo(5l)); + assertThat(ord, equalTo(5L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("04")); ord = values.nextOrd(); - assertThat(ord, equalTo(6l)); + assertThat(ord, equalTo(6L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("05")); ord = values.nextOrd(); - assertThat(ord, equalTo(7l)); + assertThat(ord, equalTo(7L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("06")); values.setDocument(1); assertThat(values.cardinality(), equalTo(3)); ord = values.nextOrd(); - assertThat(ord, equalTo(7l)); + assertThat(ord, equalTo(7L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("06")); ord = values.nextOrd(); - assertThat(ord, equalTo(8l)); + assertThat(ord, equalTo(8L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("07")); ord = values.nextOrd(); - assertThat(ord, equalTo(9l)); + assertThat(ord, equalTo(9L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("08")); values.setDocument(2); assertThat(values.cardinality(), equalTo(0)); values.setDocument(3); assertThat(values.cardinality(), equalTo(3)); ord = values.nextOrd(); - assertThat(ord, equalTo(9l)); + assertThat(ord, equalTo(9L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("08")); ord = values.nextOrd(); - assertThat(ord, equalTo(10l)); + assertThat(ord, equalTo(10L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("09")); ord = values.nextOrd(); - assertThat(ord, equalTo(11l)); + assertThat(ord, equalTo(11L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("10")); // Third segment @@ -548,13 +548,13 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI values.setDocument(0); assertThat(values.cardinality(), equalTo(3)); ord = values.nextOrd(); - assertThat(ord, equalTo(0l)); + assertThat(ord, equalTo(0L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!08")); ord = values.nextOrd(); - assertThat(ord, equalTo(1l)); + assertThat(ord, equalTo(1L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!09")); ord = values.nextOrd(); - assertThat(ord, equalTo(2l)); + assertThat(ord, equalTo(2L)); assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!10")); } @@ -620,6 +620,6 @@ public abstract class AbstractStringFieldDataTestCase extends AbstractFieldDataI assertThat(ifd.loadGlobal(topLevelReader), not(sameInstance(globalOrdinals))); ifdService.clear(); - assertThat(indicesFieldDataCache.getCache().weight(), equalTo(0l)); + assertThat(indicesFieldDataCache.getCache().weight(), equalTo(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java index fc8a830f9c5..d88ef884eb9 100644 --- a/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java +++ b/core/src/test/java/org/elasticsearch/index/fielddata/FieldDataLoadingIT.java @@ -43,7 +43,7 @@ public class FieldDataLoadingIT extends ESIntegTestCase { client().admin().indices().prepareRefresh("test").get(); ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); } public void testEagerGlobalOrdinalsFieldDataLoading() throws Exception { @@ -60,7 +60,7 @@ public class FieldDataLoadingIT extends ESIntegTestCase { client().admin().indices().prepareRefresh("test").get(); ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java b/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java index 0a0f746ccd5..51eef673c5f 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/boost/CustomBoostMappingTests.java @@ -59,7 +59,7 @@ public class CustomBoostMappingTests extends ESSingleNodeTestCase { ParsedDocument doc = mapper.parse("test", "type", "1", XContentFactory.jsonBuilder().startObject() .startObject("s_field").field("value", "s_value").field("boost", 2.0f).endObject() - .startObject("l_field").field("value", 1l).field("boost", 3.0f).endObject() + .startObject("l_field").field("value", 1L).field("boost", 3.0f).endObject() .startObject("i_field").field("value", 1).field("boost", 4.0f).endObject() .startObject("sh_field").field("value", 1).field("boost", 5.0f).endObject() .startObject("b_field").field("value", 1).field("boost", 6.0f).endObject() diff --git a/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java b/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java index d74b445ebbd..0cd6fa0e1c9 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/lucene/StoredNumericValuesTests.java @@ -80,9 +80,9 @@ public class StoredNumericValuesTests extends ESSingleNodeTestCase { Document doc2 = new Document(); doc2.add(new StoredField("field1", new BytesRef(Numbers.intToBytes(1)))); doc2.add(new StoredField("field2", new BytesRef(Numbers.floatToBytes(1.1f)))); - doc2.add(new StoredField("field3", new BytesRef(Numbers.longToBytes(1l)))); - doc2.add(new StoredField("field3", new BytesRef(Numbers.longToBytes(2l)))); - doc2.add(new StoredField("field3", new BytesRef(Numbers.longToBytes(3l)))); + doc2.add(new StoredField("field3", new BytesRef(Numbers.longToBytes(1L)))); + doc2.add(new StoredField("field3", new BytesRef(Numbers.longToBytes(2L)))); + doc2.add(new StoredField("field3", new BytesRef(Numbers.longToBytes(3L)))); writer.addDocument(doc2); DirectoryReader reader = DirectoryReader.open(writer, true); @@ -98,9 +98,9 @@ public class StoredNumericValuesTests extends ESSingleNodeTestCase { assertThat(fieldsVisitor.fields().get("field2").size(), equalTo(1)); assertThat((Float) fieldsVisitor.fields().get("field2").get(0), equalTo(1.1f)); assertThat(fieldsVisitor.fields().get("field3").size(), equalTo(3)); - assertThat((Long) fieldsVisitor.fields().get("field3").get(0), equalTo(1l)); - assertThat((Long) fieldsVisitor.fields().get("field3").get(1), equalTo(2l)); - assertThat((Long) fieldsVisitor.fields().get("field3").get(2), equalTo(3l)); + assertThat((Long) fieldsVisitor.fields().get("field3").get(0), equalTo(1L)); + assertThat((Long) fieldsVisitor.fields().get("field3").get(1), equalTo(2L)); + assertThat((Long) fieldsVisitor.fields().get("field3").get(2), equalTo(3L)); // Make sure the doc gets loaded as if it was stored in the new way fieldsVisitor.reset(); @@ -112,9 +112,9 @@ public class StoredNumericValuesTests extends ESSingleNodeTestCase { assertThat(fieldsVisitor.fields().get("field2").size(), equalTo(1)); assertThat((Float) fieldsVisitor.fields().get("field2").get(0), equalTo(1.1f)); assertThat(fieldsVisitor.fields().get("field3").size(), equalTo(3)); - assertThat((Long) fieldsVisitor.fields().get("field3").get(0), equalTo(1l)); - assertThat((Long) fieldsVisitor.fields().get("field3").get(1), equalTo(2l)); - assertThat((Long) fieldsVisitor.fields().get("field3").get(2), equalTo(3l)); + assertThat((Long) fieldsVisitor.fields().get("field3").get(0), equalTo(1L)); + assertThat((Long) fieldsVisitor.fields().get("field3").get(1), equalTo(2L)); + assertThat((Long) fieldsVisitor.fields().get("field3").get(2), equalTo(3L)); reader.close(); writer.close(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java index e4892583cf8..347e4dd9201 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java @@ -67,11 +67,11 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("my-index") .setQuery(matchQuery("title", "multi")) .get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("my-index") .setQuery(matchQuery("title.not_analyzed", "Multi fields")) .get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertAcked( client().admin().indices().preparePutMapping("my-index").setType("my-type") @@ -98,7 +98,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { searchResponse = client().prepareSearch("my-index") .setQuery(matchQuery("title.uncased", "Multi")) .get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); } public void testGeoPointMultiField() throws Exception { @@ -127,9 +127,9 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { SearchResponse countResponse = client().prepareSearch("my-index").setSize(0) .setQuery(constantScoreQuery(geoDistanceQuery("a").point(51, 19).distance(50, DistanceUnit.KILOMETERS))) .get(); - assertThat(countResponse.getHits().totalHits(), equalTo(1l)); + assertThat(countResponse.getHits().totalHits(), equalTo(1L)); countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", point.toString())).get(); - assertThat(countResponse.getHits().totalHits(), equalTo(1l)); + assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } public void testTokenCountMultiField() throws Exception { @@ -167,7 +167,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { client().prepareIndex("my-index", "my-type", "1").setSource("a", "my tokens").setRefresh(true).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "my tokens")).get(); - assertThat(countResponse.getHits().totalHits(), equalTo(1l)); + assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } public void testCompletionMultiField() throws Exception { @@ -192,7 +192,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { client().prepareIndex("my-index", "my-type", "1").setSource("a", "complete me").setRefresh(true).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "complete me")).get(); - assertThat(countResponse.getHits().totalHits(), equalTo(1l)); + assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } public void testIpMultiField() throws Exception { @@ -217,7 +217,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { client().prepareIndex("my-index", "my-type", "1").setSource("a", "127.0.0.1").setRefresh(true).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "127.0.0.1")).get(); - assertThat(countResponse.getHits().totalHits(), equalTo(1l)); + assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } private XContentBuilder createMappingSource(String fieldType) throws IOException { diff --git a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java index 35034dfd911..8b6aa794062 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingOnClusterIT.java @@ -167,7 +167,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase { private void compareMappingOnNodes(GetMappingsResponse previousMapping) { // make sure all nodes have same cluster state - for (Client client : cluster()) { + for (Client client : cluster().getClients()) { GetMappingsResponse currentMapping = client.admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).setLocal(true).get(); assertThat(previousMapping.getMappings().get(INDEX).get(TYPE).source(), equalTo(currentMapping.getMappings().get(INDEX).get(TYPE).source())); } diff --git a/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java index c9f5a268bd6..7ccad1ffd2a 100644 --- a/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/FuzzyQueryBuilderTests.java @@ -141,8 +141,8 @@ public class FuzzyQueryBuilderTests extends AbstractQueryTestCase 0); Query query = queryStringQuery("12~0.2").defaultField(INT_FIELD_NAME).toQuery(createShardContext()); NumericRangeQuery fuzzyQuery = (NumericRangeQuery) query; - assertThat(fuzzyQuery.getMin().longValue(), equalTo(12l)); - assertThat(fuzzyQuery.getMax().longValue(), equalTo(12l)); + assertThat(fuzzyQuery.getMin().longValue(), equalTo(12L)); + assertThat(fuzzyQuery.getMax().longValue(), equalTo(12L)); } public void testTimezone() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java index ffaf211b245..f7dc3b2d8e1 100644 --- a/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/TermsQueryBuilderTests.java @@ -242,7 +242,7 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase values = copy.values(); - assertEquals(Arrays.asList(1l, 3l, 4l), values); + assertEquals(Arrays.asList(1L, 3L, 4L), values); } } diff --git a/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java b/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java index 960a43416d6..886be82c36b 100644 --- a/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java +++ b/core/src/test/java/org/elasticsearch/index/query/plugin/CustomQueryParserIT.java @@ -59,11 +59,11 @@ public class CustomQueryParserIT extends ESIntegTestCase { } public void testCustomDummyQuery() { - assertHitCount(client().prepareSearch("index").setQuery(new DummyQueryParserPlugin.DummyQueryBuilder()).get(), 1l); + assertHitCount(client().prepareSearch("index").setQuery(new DummyQueryParserPlugin.DummyQueryBuilder()).get(), 1L); } public void testCustomDummyQueryWithinBooleanQuery() { - assertHitCount(client().prepareSearch("index").setQuery(new BoolQueryBuilder().must(new DummyQueryParserPlugin.DummyQueryBuilder())).get(), 1l); + assertHitCount(client().prepareSearch("index").setQuery(new BoolQueryBuilder().must(new DummyQueryParserPlugin.DummyQueryBuilder())).get(), 1L); } private static QueryShardContext queryShardContext() { diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index 13fa55e8295..ca0069e4eda 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -441,7 +441,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { client().prepareIndex("test", "bar", "1").setSource("{}").setRefresh(true).get(); client().admin().indices().prepareFlush("test").get(); SearchResponse response = client().prepareSearch("test").get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService test = indicesService.indexService("test"); IndexShard shard = test.getShardOrNull(0); @@ -456,7 +456,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { createIndex("test"); ensureGreen("test"); response = client().prepareSearch("test").get(); - assertHitCount(response, 0l); + assertHitCount(response, 0L); } public void testIndexDirIsDeletedWhenShardRemoved() throws Exception { @@ -470,7 +470,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { ensureGreen("test"); client().prepareIndex("test", "bar", "1").setSource("{}").setRefresh(true).get(); SearchResponse response = client().prepareSearch("test").get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); client().admin().indices().prepareDelete("test").get(); assertPathHasBeenCleared(idxPath); } @@ -995,7 +995,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { MappedFieldType foo = newShard.mapperService().fullName("foo"); IndexFieldData.Global ifd = shard.indexFieldDataService().getForField(foo); FieldDataStats before = shard.fieldData().stats("foo"); - assertThat(before.getMemorySizeInBytes(), equalTo(0l)); + assertThat(before.getMemorySizeInBytes(), equalTo(0L)); FieldDataStats after = null; try (Engine.Searcher searcher = newShard.acquireSearcher("test")) { assumeTrue("we have to have more than one segment", searcher.getDirectoryReader().leaves().size() > 1); @@ -1003,7 +1003,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { after = shard.fieldData().stats("foo"); assertEquals(after.getEvictions(), before.getEvictions()); // If a field doesn't exist an empty IndexFieldData is returned and that isn't cached: - assertThat(after.getMemorySizeInBytes(), equalTo(0l)); + assertThat(after.getMemorySizeInBytes(), equalTo(0L)); } assertEquals(shard.fieldData().stats("foo").getEvictions(), before.getEvictions()); assertEquals(shard.fieldData().stats("foo").getMemorySizeInBytes(), after.getMemorySizeInBytes()); diff --git a/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java b/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java index 234de11b516..715fac55a7a 100644 --- a/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java +++ b/core/src/test/java/org/elasticsearch/index/store/ExceptionRetryIT.java @@ -122,7 +122,7 @@ public class ExceptionRetryIT extends ESIntegTestCase { if (!uniqueIds.add(searchResponse.getHits().getHits()[i].getId())) { if (!found_duplicate_already) { SearchResponse dupIdResponse = client().prepareSearch("index").setQuery(termQuery("_id", searchResponse.getHits().getHits()[i].getId())).setExplain(true).get(); - assertThat(dupIdResponse.getHits().totalHits(), greaterThan(1l)); + assertThat(dupIdResponse.getHits().totalHits(), greaterThan(1L)); logger.info("found a duplicate id:"); for (SearchHit hit : dupIdResponse.getHits()) { logger.info("Doc {} was found on shard {}", hit.getId(), hit.getShard().getShardId()); @@ -134,7 +134,7 @@ public class ExceptionRetryIT extends ESIntegTestCase { } } assertSearchResponse(searchResponse); - assertThat(dupCounter, equalTo(0l)); + assertThat(dupCounter, equalTo(0L)); assertHitCount(searchResponse, numDocs); } } diff --git a/core/src/test/java/org/elasticsearch/index/store/StoreTests.java b/core/src/test/java/org/elasticsearch/index/store/StoreTests.java index 8b11e6b4867..1d77dd93d8d 100644 --- a/core/src/test/java/org/elasticsearch/index/store/StoreTests.java +++ b/core/src/test/java/org/elasticsearch/index/store/StoreTests.java @@ -791,7 +791,7 @@ public class StoreTests extends ESTestCase { public void assertDeleteContent(Store store, DirectoryService service) throws IOException { deleteContent(store.directory()); assertThat(Arrays.toString(store.directory().listAll()), store.directory().listAll().length, equalTo(0)); - assertThat(store.stats().sizeInBytes(), equalTo(0l)); + assertThat(store.stats().sizeInBytes(), equalTo(0L)); assertThat(service.newDirectory().listAll().length, equalTo(0)); } diff --git a/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java b/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java index 68c19d56e56..72be682e865 100644 --- a/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java +++ b/core/src/test/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java @@ -102,7 +102,7 @@ public class SuggestStatsIT extends ESIntegTestCase { IndicesStatsResponse indicesStats = client().admin().indices().prepareStats().execute().actionGet(); // check current - assertThat(indicesStats.getTotal().getSuggest().getCurrent(), equalTo(0l)); + assertThat(indicesStats.getTotal().getSuggest().getCurrent(), equalTo(0L)); // check suggest count assertThat(indicesStats.getTotal().getSuggest().getCount(), equalTo((long) (suggestAllIdx * totalShards + suggestIdx1 * shardsIdx1 + suggestIdx2 * shardsIdx2))); @@ -111,7 +111,7 @@ public class SuggestStatsIT extends ESIntegTestCase { logger.info("iter {}, iter1 {}, iter2 {}, {}", suggestAllIdx, suggestIdx1, suggestIdx2, endTime - startTime); // check suggest time - assertThat(indicesStats.getTotal().getSuggest().getTimeInMillis(), greaterThan(0l)); + assertThat(indicesStats.getTotal().getSuggest().getTimeInMillis(), greaterThan(0L)); // the upperbound is num shards * total time since we do searches in parallel assertThat(indicesStats.getTotal().getSuggest().getTimeInMillis(), lessThanOrEqualTo(totalShards * (endTime - startTime))); @@ -123,12 +123,12 @@ public class SuggestStatsIT extends ESIntegTestCase { SuggestStats suggestStats = stat.getIndices().getSuggest(); logger.info("evaluating {}", stat.getNode()); if (nodeIdsWithIndex.contains(stat.getNode().getId())) { - assertThat(suggestStats.getCount(), greaterThan(0l)); - assertThat(suggestStats.getTimeInMillis(), greaterThan(0l)); + assertThat(suggestStats.getCount(), greaterThan(0L)); + assertThat(suggestStats.getTimeInMillis(), greaterThan(0L)); num++; } else { - assertThat(suggestStats.getCount(), equalTo(0l)); - assertThat(suggestStats.getTimeInMillis(), equalTo(0l)); + assertThat(suggestStats.getCount(), equalTo(0L)); + assertThat(suggestStats.getTimeInMillis(), equalTo(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java index a46e12837a0..c888c884549 100644 --- a/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java +++ b/core/src/test/java/org/elasticsearch/index/translog/TranslogTests.java @@ -288,7 +288,7 @@ public class TranslogTests extends ESTestCase { public void testStats() throws IOException { final long firstOperationPosition = translog.getFirstOperationPosition(); TranslogStats stats = stats(); - assertThat(stats.estimatedNumberOfOperations(), equalTo(0l)); + assertThat(stats.estimatedNumberOfOperations(), equalTo(0L)); long lastSize = stats.getTranslogSizeInBytes(); assertThat((int) firstOperationPosition, greaterThan(CodecUtil.headerLength(TranslogWriter.TRANSLOG_CODEC))); assertThat(lastSize, equalTo(firstOperationPosition)); @@ -296,14 +296,14 @@ public class TranslogTests extends ESTestCase { translog.add(new Translog.Index("test", "1", new byte[]{1})); stats = stats(); total.add(stats); - assertThat(stats.estimatedNumberOfOperations(), equalTo(1l)); + assertThat(stats.estimatedNumberOfOperations(), equalTo(1L)); assertThat(stats.getTranslogSizeInBytes(), greaterThan(lastSize)); lastSize = stats.getTranslogSizeInBytes(); translog.add(new Translog.Delete(newUid("2"))); stats = stats(); total.add(stats); - assertThat(stats.estimatedNumberOfOperations(), equalTo(2l)); + assertThat(stats.estimatedNumberOfOperations(), equalTo(2L)); assertThat(stats.getTranslogSizeInBytes(), greaterThan(lastSize)); lastSize = stats.getTranslogSizeInBytes(); @@ -311,13 +311,13 @@ public class TranslogTests extends ESTestCase { translog.prepareCommit(); stats = stats(); total.add(stats); - assertThat(stats.estimatedNumberOfOperations(), equalTo(3l)); + assertThat(stats.estimatedNumberOfOperations(), equalTo(3L)); assertThat(stats.getTranslogSizeInBytes(), greaterThan(lastSize)); translog.commit(); stats = stats(); total.add(stats); - assertThat(stats.estimatedNumberOfOperations(), equalTo(0l)); + assertThat(stats.estimatedNumberOfOperations(), equalTo(0L)); assertThat(stats.getTranslogSizeInBytes(), equalTo(firstOperationPosition)); assertEquals(6, total.estimatedNumberOfOperations()); assertEquals(431, total.getTranslogSizeInBytes()); @@ -983,7 +983,7 @@ public class TranslogTests extends ESTestCase { if (op == prepareOp) { translogGeneration = translog.getGeneration(); translog.prepareCommit(); - assertEquals("expected this to be the first commit", 1l, translogGeneration.translogFileGeneration); + assertEquals("expected this to be the first commit", 1L, translogGeneration.translogFileGeneration); assertNotNull(translogGeneration.translogUUID); } } @@ -1034,7 +1034,7 @@ public class TranslogTests extends ESTestCase { if (op == prepareOp) { translogGeneration = translog.getGeneration(); translog.prepareCommit(); - assertEquals("expected this to be the first commit", 1l, translogGeneration.translogFileGeneration); + assertEquals("expected this to be the first commit", 1L, translogGeneration.translogFileGeneration); assertNotNull(translogGeneration.translogUUID); } } @@ -1090,7 +1090,7 @@ public class TranslogTests extends ESTestCase { if (op == prepareOp) { translogGeneration = translog.getGeneration(); translog.prepareCommit(); - assertEquals("expected this to be the first commit", 1l, translogGeneration.translogFileGeneration); + assertEquals("expected this to be the first commit", 1L, translogGeneration.translogFileGeneration); assertNotNull(translogGeneration.translogUUID); } } diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java index 6d0a8955116..aad4e34c3da 100644 --- a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java @@ -472,19 +472,19 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase { .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(matchAllQuery()) .execute().actionGet(); - assertHitCount(response, 0l); + assertHitCount(response, 0L); response = client().prepareSearch("test2","test3").setQuery(matchAllQuery()) .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .execute().actionGet(); - assertHitCount(response, 0l); + assertHitCount(response, 0L); //you should still be able to run empty searches without things blowing up response = client().prepareSearch() .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(matchAllQuery()) .execute().actionGet(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); } public void testAllMissingStrict() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/indices/cache/query/IndicesRequestCacheIT.java b/core/src/test/java/org/elasticsearch/indices/cache/query/IndicesRequestCacheIT.java index 65ba54dc458..bc646b3c6e8 100644 --- a/core/src/test/java/org/elasticsearch/indices/cache/query/IndicesRequestCacheIT.java +++ b/core/src/test/java/org/elasticsearch/indices/cache/query/IndicesRequestCacheIT.java @@ -57,7 +57,7 @@ public class IndicesRequestCacheIT extends ESIntegTestCase { assertSearchResponse(r1); // The cached is actually used - assertThat(client().admin().indices().prepareStats("index").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(client().admin().indices().prepareStats("index").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0L)); for (int i = 0; i < 10; ++i) { final SearchResponse r2 = client().prepareSearch("index").setSize(0) diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 52c21902939..12acea4f9ac 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -349,10 +349,10 @@ public class IndexRecoveryIT extends ESIntegTestCase { assertThat(recoveryStats.currentAsSource(), equalTo(0)); assertThat(recoveryStats.currentAsTarget(), equalTo(0)); if (nodeStats.getNode().name().equals(nodeA)) { - assertThat("node A throttling should be >0", recoveryStats.throttleTime().millis(), greaterThan(0l)); + assertThat("node A throttling should be >0", recoveryStats.throttleTime().millis(), greaterThan(0L)); } if (nodeStats.getNode().name().equals(nodeB)) { - assertThat("node B throttling should be >0 ", recoveryStats.throttleTime().millis(), greaterThan(0l)); + assertThat("node B throttling should be >0 ", recoveryStats.throttleTime().millis(), greaterThan(0L)); } } @@ -368,10 +368,10 @@ public class IndexRecoveryIT extends ESIntegTestCase { assertThat(recoveryStats.currentAsSource(), equalTo(0)); assertThat(recoveryStats.currentAsTarget(), equalTo(0)); if (nodeStats.getNode().name().equals(nodeA)) { - assertThat("node A throttling should be >0", recoveryStats.throttleTime().millis(), greaterThan(0l)); + assertThat("node A throttling should be >0", recoveryStats.throttleTime().millis(), greaterThan(0L)); } if (nodeStats.getNode().name().equals(nodeB)) { - assertThat("node B throttling should be >0 ", recoveryStats.throttleTime().millis(), greaterThan(0l)); + assertThat("node B throttling should be >0 ", recoveryStats.throttleTime().millis(), greaterThan(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java index 2f0b3a297eb..f81d9792187 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/RecoveryStateTests.java @@ -148,8 +148,8 @@ public class RecoveryStateTests extends ESTestCase { } timer.start(); - assertThat(timer.startTime(), greaterThan(0l)); - assertThat(timer.stopTime(), equalTo(0l)); + assertThat(timer.startTime(), greaterThan(0L)); + assertThat(timer.stopTime(), equalTo(0L)); Timer lastRead = streamer.serializeDeserialize(); final long time = lastRead.time(); assertThat(time, lessThanOrEqualTo(timer.time())); @@ -164,7 +164,7 @@ public class RecoveryStateTests extends ESTestCase { if (randomBoolean()) { timer.stop(); assertThat(timer.stopTime(), greaterThanOrEqualTo(timer.startTime())); - assertThat(timer.time(), greaterThan(0l)); + assertThat(timer.time(), greaterThan(0L)); lastRead = streamer.serializeDeserialize(); assertThat(lastRead.startTime(), equalTo(timer.startTime())); assertThat(lastRead.time(), equalTo(timer.time())); @@ -172,13 +172,13 @@ public class RecoveryStateTests extends ESTestCase { } timer.reset(); - assertThat(timer.startTime(), equalTo(0l)); - assertThat(timer.time(), equalTo(0l)); - assertThat(timer.stopTime(), equalTo(0l)); + assertThat(timer.startTime(), equalTo(0L)); + assertThat(timer.time(), equalTo(0L)); + assertThat(timer.stopTime(), equalTo(0L)); lastRead = streamer.serializeDeserialize(); - assertThat(lastRead.startTime(), equalTo(0l)); - assertThat(lastRead.time(), equalTo(0l)); - assertThat(lastRead.stopTime(), equalTo(0l)); + assertThat(lastRead.startTime(), equalTo(0L)); + assertThat(lastRead.time(), equalTo(0L)); + assertThat(lastRead.stopTime(), equalTo(0L)); } @@ -242,7 +242,7 @@ public class RecoveryStateTests extends ESTestCase { assertThat(index.reusedFileCount(), equalTo(totalReused)); assertThat(index.totalRecoverFiles(), equalTo(filesToRecover.size())); assertThat(index.recoveredFileCount(), equalTo(0)); - assertThat(index.recoveredBytes(), equalTo(0l)); + assertThat(index.recoveredBytes(), equalTo(0L)); assertThat(index.recoveredFilesPercent(), equalTo(filesToRecover.size() == 0 ? 100.0f : 0.0f)); assertThat(index.recoveredBytesPercent(), equalTo(filesToRecover.size() == 0 ? 100.0f : 0.0f)); @@ -296,7 +296,7 @@ public class RecoveryStateTests extends ESTestCase { if (completeRecovery) { assertThat(filesToRecover.size(), equalTo(0)); index.stop(); - assertThat(index.time(), greaterThanOrEqualTo(0l)); + assertThat(index.time(), greaterThanOrEqualTo(0L)); } logger.info("testing serialized information"); @@ -457,15 +457,15 @@ public class RecoveryStateTests extends ESTestCase { // we don't need to test the time aspect, it's done in the timer test verifyIndex.start(); - assertThat(verifyIndex.checkIndexTime(), equalTo(0l)); + assertThat(verifyIndex.checkIndexTime(), equalTo(0L)); // force one VerifyIndex lastRead = streamer.serializeDeserialize(); - assertThat(lastRead.checkIndexTime(), equalTo(0l)); + assertThat(lastRead.checkIndexTime(), equalTo(0L)); long took = randomLong(); if (took < 0) { took = -took; - took = Math.max(0l, took); + took = Math.max(0L, took); } verifyIndex.checkIndexTime(took); diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java b/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java index 6c20bfc6781..c7a7852e426 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/StartRecoveryRequestTests.java @@ -46,7 +46,7 @@ public class StartRecoveryRequestTests extends ESTestCase { true, Store.MetadataSnapshot.EMPTY, RecoveryState.Type.RELOCATION, - 1l + 1L ); ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); diff --git a/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java b/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java index dc48b96c23f..b257e3bcd5e 100644 --- a/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java +++ b/core/src/test/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java @@ -68,7 +68,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase { for (int i = 0; i < 10; i++) { SearchResponse countResponse = client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(); - assertHitCount(countResponse, 10l); + assertHitCount(countResponse, 10L); } logger.info("Increasing the number of replicas from 1 to 2"); @@ -98,7 +98,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase { for (int i = 0; i < 10; i++) { SearchResponse countResponse = client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(); - assertHitCount(countResponse, 10l); + assertHitCount(countResponse, 10L); } logger.info("Decreasing number of replicas from 2 to 0"); diff --git a/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java b/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java index 67fc5acd09a..78d5e2203f5 100644 --- a/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java +++ b/core/src/test/java/org/elasticsearch/indices/settings/UpdateSettingsIT.java @@ -205,7 +205,7 @@ public class UpdateSettingsIT extends ESIntegTestCase { // No merge IO throttling should have happened: NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true).get(); for(NodeStats stats : nodesStats.getNodes()) { - assertThat(stats.getIndices().getStore().getThrottleTime().getMillis(), equalTo(0l)); + assertThat(stats.getIndices().getStore().getThrottleTime().getMillis(), equalTo(0L)); } logger.info("test: set low merge throttling"); diff --git a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java index 756a9af43b1..38e81f7eba2 100644 --- a/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java +++ b/core/src/test/java/org/elasticsearch/indices/stats/IndexStatsIT.java @@ -92,18 +92,18 @@ public class IndexStatsIT extends ESIntegTestCase { client().admin().indices().prepareRefresh().execute().actionGet(); NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true).execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); IndicesStatsResponse indicesStats = client().admin().indices().prepareStats("test").clear().setFieldData(true).execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0L)); // sort to load it to field data... client().prepareSearch().addSort("field", SortOrder.ASC).execute().actionGet(); client().prepareSearch().addSort("field", SortOrder.ASC).execute().actionGet(); nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true).execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); indicesStats = client().admin().indices().prepareStats("test").clear().setFieldData(true).execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); // sort to load it to field data... client().prepareSearch().addSort("field2", SortOrder.ASC).execute().actionGet(); @@ -111,20 +111,20 @@ public class IndexStatsIT extends ESIntegTestCase { // now check the per field stats nodesStats = client().admin().cluster().prepareNodesStats().setIndices(new CommonStatsFlags().set(CommonStatsFlags.Flag.FieldData, true).fieldDataFields("*")).execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getFields().get("field") + nodesStats.getNodes()[1].getIndices().getFieldData().getFields().get("field"), greaterThan(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getFields().get("field") + nodesStats.getNodes()[1].getIndices().getFieldData().getFields().get("field"), greaterThan(0L)); assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getFields().get("field") + nodesStats.getNodes()[1].getIndices().getFieldData().getFields().get("field"), lessThan(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes())); indicesStats = client().admin().indices().prepareStats("test").clear().setFieldData(true).setFieldDataFields("*").execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getFieldData().getFields().get("field"), greaterThan(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getFieldData().getFields().get("field"), greaterThan(0L)); assertThat(indicesStats.getTotal().getFieldData().getFields().get("field"), lessThan(indicesStats.getTotal().getFieldData().getMemorySizeInBytes())); client().admin().indices().prepareClearCache().setFieldDataCache(true).execute().actionGet(); nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true).execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); indicesStats = client().admin().indices().prepareStats("test").clear().setFieldData(true).execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0L)); } @@ -140,14 +140,14 @@ public class IndexStatsIT extends ESIntegTestCase { NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true) .execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0l)); - assertThat(nodesStats.getNodes()[0].getIndices().getQueryCache().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); + assertThat(nodesStats.getNodes()[0].getIndices().getQueryCache().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); IndicesStatsResponse indicesStats = client().admin().indices().prepareStats("test") .clear().setFieldData(true).setQueryCache(true) .execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0l)); - assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0L)); + assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); // sort to load it to field data and filter to load filter cache client().prepareSearch() @@ -161,27 +161,27 @@ public class IndexStatsIT extends ESIntegTestCase { nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true) .execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); - assertThat(nodesStats.getNodes()[0].getIndices().getQueryCache().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getQueryCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); + assertThat(nodesStats.getNodes()[0].getIndices().getQueryCache().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getQueryCache().getMemorySizeInBytes(), greaterThan(0L)); indicesStats = client().admin().indices().prepareStats("test") .clear().setFieldData(true).setQueryCache(true) .execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), greaterThan(0L)); client().admin().indices().prepareClearCache().execute().actionGet(); Thread.sleep(100); // Make sure the filter cache entries have been removed... nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true) .execute().actionGet(); - assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0l)); - assertThat(nodesStats.getNodes()[0].getIndices().getQueryCache().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(nodesStats.getNodes()[0].getIndices().getFieldData().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); + assertThat(nodesStats.getNodes()[0].getIndices().getQueryCache().getMemorySizeInBytes() + nodesStats.getNodes()[1].getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); indicesStats = client().admin().indices().prepareStats("test") .clear().setFieldData(true).setQueryCache(true) .execute().actionGet(); - assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0l)); - assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(indicesStats.getTotal().getFieldData().getMemorySizeInBytes(), equalTo(0L)); + assertThat(indicesStats.getTotal().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); } public void testQueryCache() throws Exception { @@ -218,15 +218,15 @@ public class IndexStatsIT extends ESIntegTestCase { } } - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0l)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getHitCount(), equalTo(0l)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMissCount(), equalTo(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0L)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getHitCount(), equalTo(0L)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMissCount(), equalTo(0L)); for (int i = 0; i < 10; i++) { assertThat(client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0L)); } - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getHitCount(), greaterThan(0l)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMissCount(), greaterThan(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getHitCount(), greaterThan(0L)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMissCount(), greaterThan(0L)); // index the data again... IndexRequestBuilder[] builders = new IndexRequestBuilder[numDocs]; @@ -242,25 +242,25 @@ public class IndexStatsIT extends ESIntegTestCase { assertBusy(new Runnable() { @Override public void run() { - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0L)); } }); for (int i = 0; i < 10; i++) { assertThat(client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0L)); } client().admin().indices().prepareClearCache().setRequestCache(true).get(); // clean the cache - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0L)); // test explicit request parameter assertThat(client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(0).setRequestCache(false).get().getHits().getTotalHits(), equalTo((long) numDocs)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0L)); assertThat(client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(0).setRequestCache(true).get().getHits().getTotalHits(), equalTo((long) numDocs)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0L)); // set the index level setting to false, and see that the reverse works @@ -268,10 +268,10 @@ public class IndexStatsIT extends ESIntegTestCase { assertAcked(client().admin().indices().prepareUpdateSettings("idx").setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), false))); assertThat(client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(0).get().getHits().getTotalHits(), equalTo((long) numDocs)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), equalTo(0L)); assertThat(client().prepareSearch("idx").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(0).setRequestCache(true).get().getHits().getTotalHits(), equalTo((long) numDocs)); - assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(client().admin().indices().prepareStats("idx").setRequestCache(true).get().getTotal().getRequestCache().getMemorySizeInBytes(), greaterThan(0L)); } public void testNonThrottleStats() throws Exception { @@ -303,7 +303,7 @@ public class IndexStatsIT extends ESIntegTestCase { //nodesStats = client().admin().cluster().prepareNodesStats().setIndices(true).get(); stats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(stats.getPrimaries().getIndexing().getTotal().getThrottleTime().millis(), equalTo(0l)); + assertThat(stats.getPrimaries().getIndexing().getTotal().getThrottleTime().millis(), equalTo(0L)); } public void testThrottleStats() throws Exception { @@ -370,33 +370,33 @@ public class IndexStatsIT extends ESIntegTestCase { long totalExpectedWrites = test1ExpectedWrites + test2ExpectedWrites; IndicesStatsResponse stats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(stats.getPrimaries().getDocs().getCount(), equalTo(3l)); + assertThat(stats.getPrimaries().getDocs().getCount(), equalTo(3L)); assertThat(stats.getTotal().getDocs().getCount(), equalTo(totalExpectedWrites)); - assertThat(stats.getPrimaries().getIndexing().getTotal().getIndexCount(), equalTo(3l)); - assertThat(stats.getPrimaries().getIndexing().getTotal().getIndexFailedCount(), equalTo(0l)); + assertThat(stats.getPrimaries().getIndexing().getTotal().getIndexCount(), equalTo(3L)); + assertThat(stats.getPrimaries().getIndexing().getTotal().getIndexFailedCount(), equalTo(0L)); assertThat(stats.getPrimaries().getIndexing().getTotal().isThrottled(), equalTo(false)); - assertThat(stats.getPrimaries().getIndexing().getTotal().getThrottleTime().millis(), equalTo(0l)); + assertThat(stats.getPrimaries().getIndexing().getTotal().getThrottleTime().millis(), equalTo(0L)); assertThat(stats.getTotal().getIndexing().getTotal().getIndexCount(), equalTo(totalExpectedWrites)); assertThat(stats.getTotal().getStore(), notNullValue()); assertThat(stats.getTotal().getMerge(), notNullValue()); assertThat(stats.getTotal().getFlush(), notNullValue()); assertThat(stats.getTotal().getRefresh(), notNullValue()); - assertThat(stats.getIndex("test1").getPrimaries().getDocs().getCount(), equalTo(2l)); + assertThat(stats.getIndex("test1").getPrimaries().getDocs().getCount(), equalTo(2L)); assertThat(stats.getIndex("test1").getTotal().getDocs().getCount(), equalTo(test1ExpectedWrites)); assertThat(stats.getIndex("test1").getPrimaries().getStore(), notNullValue()); assertThat(stats.getIndex("test1").getPrimaries().getMerge(), notNullValue()); assertThat(stats.getIndex("test1").getPrimaries().getFlush(), notNullValue()); assertThat(stats.getIndex("test1").getPrimaries().getRefresh(), notNullValue()); - assertThat(stats.getIndex("test2").getPrimaries().getDocs().getCount(), equalTo(1l)); + assertThat(stats.getIndex("test2").getPrimaries().getDocs().getCount(), equalTo(1L)); assertThat(stats.getIndex("test2").getTotal().getDocs().getCount(), equalTo(test2ExpectedWrites)); // make sure that number of requests in progress is 0 - assertThat(stats.getIndex("test1").getTotal().getIndexing().getTotal().getIndexCurrent(), equalTo(0l)); - assertThat(stats.getIndex("test1").getTotal().getIndexing().getTotal().getDeleteCurrent(), equalTo(0l)); - assertThat(stats.getIndex("test1").getTotal().getSearch().getTotal().getFetchCurrent(), equalTo(0l)); - assertThat(stats.getIndex("test1").getTotal().getSearch().getTotal().getQueryCurrent(), equalTo(0l)); + assertThat(stats.getIndex("test1").getTotal().getIndexing().getTotal().getIndexCurrent(), equalTo(0L)); + assertThat(stats.getIndex("test1").getTotal().getIndexing().getTotal().getDeleteCurrent(), equalTo(0L)); + assertThat(stats.getIndex("test1").getTotal().getSearch().getTotal().getFetchCurrent(), equalTo(0L)); + assertThat(stats.getIndex("test1").getTotal().getSearch().getTotal().getQueryCurrent(), equalTo(0L)); // check flags stats = client().admin().indices().prepareStats().clear() @@ -414,32 +414,32 @@ public class IndexStatsIT extends ESIntegTestCase { // check types stats = client().admin().indices().prepareStats().setTypes("type1", "type").execute().actionGet(); - assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexCount(), equalTo(1l)); - assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type").getIndexCount(), equalTo(1l)); - assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexFailedCount(), equalTo(0l)); + assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexCount(), equalTo(1L)); + assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type").getIndexCount(), equalTo(1L)); + assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexFailedCount(), equalTo(0L)); assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type2"), nullValue()); - assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexCurrent(), equalTo(0l)); - assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getDeleteCurrent(), equalTo(0l)); + assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexCurrent(), equalTo(0L)); + assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getDeleteCurrent(), equalTo(0L)); - assertThat(stats.getTotal().getGet().getCount(), equalTo(0l)); + assertThat(stats.getTotal().getGet().getCount(), equalTo(0L)); // check get GetResponse getResponse = client().prepareGet("test1", "type1", "1").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); stats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(stats.getTotal().getGet().getCount(), equalTo(1l)); - assertThat(stats.getTotal().getGet().getExistsCount(), equalTo(1l)); - assertThat(stats.getTotal().getGet().getMissingCount(), equalTo(0l)); + assertThat(stats.getTotal().getGet().getCount(), equalTo(1L)); + assertThat(stats.getTotal().getGet().getExistsCount(), equalTo(1L)); + assertThat(stats.getTotal().getGet().getMissingCount(), equalTo(0L)); // missing get getResponse = client().prepareGet("test1", "type1", "2").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(false)); stats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(stats.getTotal().getGet().getCount(), equalTo(2l)); - assertThat(stats.getTotal().getGet().getExistsCount(), equalTo(1l)); - assertThat(stats.getTotal().getGet().getMissingCount(), equalTo(1l)); + assertThat(stats.getTotal().getGet().getCount(), equalTo(2L)); + assertThat(stats.getTotal().getGet().getExistsCount(), equalTo(1L)); + assertThat(stats.getTotal().getGet().getMissingCount(), equalTo(1L)); // clear all stats = client().admin().indices().prepareStats() @@ -476,8 +476,8 @@ public class IndexStatsIT extends ESIntegTestCase { } catch (VersionConflictEngineException e) {} stats = client().admin().indices().prepareStats().setTypes("type1", "type2").execute().actionGet(); - assertThat(stats.getIndex("test1").getTotal().getIndexing().getTotal().getIndexFailedCount(), equalTo(2l)); - assertThat(stats.getIndex("test2").getTotal().getIndexing().getTotal().getIndexFailedCount(), equalTo(1l)); + assertThat(stats.getIndex("test1").getTotal().getIndexing().getTotal().getIndexFailedCount(), equalTo(2L)); + assertThat(stats.getIndex("test2").getTotal().getIndexing().getTotal().getIndexFailedCount(), equalTo(1L)); assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type1").getIndexFailedCount(), equalTo(1L)); assertThat(stats.getPrimaries().getIndexing().getTypeStats().get("type2").getIndexFailedCount(), equalTo(1L)); assertThat(stats.getTotal().getIndexing().getTotal().getIndexFailedCount(), equalTo(3L)); @@ -516,7 +516,7 @@ public class IndexStatsIT extends ESIntegTestCase { .execute().actionGet(); assertThat(stats.getTotal().getMerge(), notNullValue()); - assertThat(stats.getTotal().getMerge().getTotal(), greaterThan(0l)); + assertThat(stats.getTotal().getMerge().getTotal(), greaterThan(0L)); } public void testSegmentsStats() { @@ -531,9 +531,9 @@ public class IndexStatsIT extends ESIntegTestCase { } IndicesStatsResponse stats = client().admin().indices().prepareStats().setSegments(true).get(); - assertThat(stats.getTotal().getSegments().getIndexWriterMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getTotal().getSegments().getIndexWriterMaxMemoryInBytes(), greaterThan(0l)); - assertThat(stats.getTotal().getSegments().getVersionMapMemoryInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().getSegments().getIndexWriterMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getTotal().getSegments().getIndexWriterMaxMemoryInBytes(), greaterThan(0L)); + assertThat(stats.getTotal().getSegments().getVersionMapMemoryInBytes(), greaterThan(0L)); client().admin().indices().prepareFlush().get(); client().admin().indices().prepareForceMerge().setMaxNumSegments(1).execute().actionGet(); @@ -542,7 +542,7 @@ public class IndexStatsIT extends ESIntegTestCase { assertThat(stats.getTotal().getSegments(), notNullValue()); assertThat(stats.getTotal().getSegments().getCount(), equalTo((long) test1.totalNumShards)); assumeTrue("test doesn't work with 4.6.0", org.elasticsearch.Version.CURRENT.luceneVersion != Version.LUCENE_4_6_0); - assertThat(stats.getTotal().getSegments().getMemoryInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().getSegments().getMemoryInBytes(), greaterThan(0L)); } public void testAllFlags() throws Exception { @@ -713,33 +713,33 @@ public class IndexStatsIT extends ESIntegTestCase { IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats(); IndicesStatsResponse stats = builder.execute().actionGet(); - assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields(), is(nullValue())); stats = builder.setFieldDataFields("bar").execute().actionGet(); - assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(false)); stats = builder.setFieldDataFields("bar", "baz").execute().actionGet(); - assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().get("baz"), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("baz"), greaterThan(0L)); stats = builder.setFieldDataFields("*").execute().actionGet(); - assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().get("baz"), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("baz"), greaterThan(0L)); stats = builder.setFieldDataFields("*r").execute().actionGet(); - assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getMemorySizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("bar"), is(true)); - assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0l)); + assertThat(stats.getTotal().fieldData.getFields().get("bar"), greaterThan(0L)); assertThat(stats.getTotal().fieldData.getFields().containsKey("baz"), is(false)); } @@ -758,33 +758,33 @@ public class IndexStatsIT extends ESIntegTestCase { IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats(); IndicesStatsResponse stats = builder.execute().actionGet(); - assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields(), is(nullValue())); stats = builder.setCompletionFields("bar.completion").execute().actionGet(); - assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(false)); stats = builder.setCompletionFields("bar.completion", "baz.completion").execute().actionGet(); - assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().get("baz.completion"), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("baz.completion"), greaterThan(0L)); stats = builder.setCompletionFields("*").execute().actionGet(); - assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().get("baz.completion"), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("baz.completion"), greaterThan(0L)); stats = builder.setCompletionFields("*r*").execute().actionGet(); - assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0l)); + assertThat(stats.getTotal().completion.getSizeInBytes(), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("bar.completion"), is(true)); - assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0l)); + assertThat(stats.getTotal().completion.getFields().get("bar.completion"), greaterThan(0L)); assertThat(stats.getTotal().completion.getFields().containsKey("baz.completion"), is(false)); } @@ -802,23 +802,23 @@ public class IndexStatsIT extends ESIntegTestCase { IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats(); IndicesStatsResponse stats = builder.execute().actionGet(); - assertThat(stats.getTotal().search.getTotal().getQueryCount(), greaterThan(0l)); + assertThat(stats.getTotal().search.getTotal().getQueryCount(), greaterThan(0L)); assertThat(stats.getTotal().search.getGroupStats(), is(nullValue())); stats = builder.setGroups("bar").execute().actionGet(); - assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0l)); + assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0L)); assertThat(stats.getTotal().search.getGroupStats().containsKey("baz"), is(false)); stats = builder.setGroups("bar", "baz").execute().actionGet(); - assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0l)); - assertThat(stats.getTotal().search.getGroupStats().get("baz").getQueryCount(), greaterThan(0l)); + assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0L)); + assertThat(stats.getTotal().search.getGroupStats().get("baz").getQueryCount(), greaterThan(0L)); stats = builder.setGroups("*").execute().actionGet(); - assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0l)); - assertThat(stats.getTotal().search.getGroupStats().get("baz").getQueryCount(), greaterThan(0l)); + assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0L)); + assertThat(stats.getTotal().search.getGroupStats().get("baz").getQueryCount(), greaterThan(0L)); stats = builder.setGroups("*r").execute().actionGet(); - assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0l)); + assertThat(stats.getTotal().search.getGroupStats().get("bar").getQueryCount(), greaterThan(0L)); assertThat(stats.getTotal().search.getGroupStats().containsKey("baz"), is(false)); } @@ -836,23 +836,23 @@ public class IndexStatsIT extends ESIntegTestCase { IndicesStatsRequestBuilder builder = client().admin().indices().prepareStats(); IndicesStatsResponse stats = builder.execute().actionGet(); - assertThat(stats.getTotal().indexing.getTotal().getIndexCount(), greaterThan(0l)); + assertThat(stats.getTotal().indexing.getTotal().getIndexCount(), greaterThan(0L)); assertThat(stats.getTotal().indexing.getTypeStats(), is(nullValue())); stats = builder.setTypes("bar").execute().actionGet(); - assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0l)); + assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0L)); assertThat(stats.getTotal().indexing.getTypeStats().containsKey("baz"), is(false)); stats = builder.setTypes("bar", "baz").execute().actionGet(); - assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0l)); - assertThat(stats.getTotal().indexing.getTypeStats().get("baz").getIndexCount(), greaterThan(0l)); + assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0L)); + assertThat(stats.getTotal().indexing.getTypeStats().get("baz").getIndexCount(), greaterThan(0L)); stats = builder.setTypes("*").execute().actionGet(); - assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0l)); - assertThat(stats.getTotal().indexing.getTypeStats().get("baz").getIndexCount(), greaterThan(0l)); + assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0L)); + assertThat(stats.getTotal().indexing.getTypeStats().get("baz").getIndexCount(), greaterThan(0L)); stats = builder.setTypes("*r").execute().actionGet(); - assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0l)); + assertThat(stats.getTotal().indexing.getTypeStats().get("bar").getIndexCount(), greaterThan(0L)); assertThat(stats.getTotal().indexing.getTypeStats().containsKey("baz"), is(false)); } diff --git a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index 63db0450551..fbfaa93df8c 100644 --- a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -369,21 +369,21 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch("test_index").get(); - assertHitCount(searchResponse, 5l); + assertHitCount(searchResponse, 5L); searchResponse = client().prepareSearch("simple_alias").get(); - assertHitCount(searchResponse, 5l); + assertHitCount(searchResponse, 5L); searchResponse = client().prepareSearch("templated_alias-test_index").get(); - assertHitCount(searchResponse, 5l); + assertHitCount(searchResponse, 5L); searchResponse = client().prepareSearch("filtered_alias").get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).type(), equalTo("type2")); // Search the complex filter alias searchResponse = client().prepareSearch("complex_filtered_alias").get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); Set types = new HashSet<>(); for (SearchHit searchHit : searchResponse.getHits().getHits()) { @@ -421,10 +421,10 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch("test_index").get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("my_alias").get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).type(), equalTo("type2")); } @@ -456,13 +456,13 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch("test_index").get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("alias1").get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("alias2").get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).type(), equalTo("type2")); } @@ -627,7 +627,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { assertThat(response.getItems()[0].getIndex(), equalTo("a2")); assertThat(response.getItems()[0].getType(), equalTo("test")); assertThat(response.getItems()[0].getId(), equalTo("test")); - assertThat(response.getItems()[0].getVersion(), equalTo(1l)); + assertThat(response.getItems()[0].getVersion(), equalTo(1L)); client().prepareIndex("b1", "test", "test").setSource("{}").get(); response = client().prepareBulk().add(new IndexRequest("b2", "test", "test").source("{}")).get(); @@ -636,7 +636,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { assertThat(response.getItems()[0].getIndex(), equalTo("b2")); assertThat(response.getItems()[0].getType(), equalTo("test")); assertThat(response.getItems()[0].getId(), equalTo("test")); - assertThat(response.getItems()[0].getVersion(), equalTo(1l)); + assertThat(response.getItems()[0].getVersion(), equalTo(1L)); client().prepareIndex("c1", "test", "test").setSource("{}").get(); response = client().prepareBulk().add(new IndexRequest("c2", "test", "test").source("{}")).get(); @@ -645,7 +645,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { assertThat(response.getItems()[0].getIndex(), equalTo("c2")); assertThat(response.getItems()[0].getType(), equalTo("test")); assertThat(response.getItems()[0].getId(), equalTo("test")); - assertThat(response.getItems()[0].getVersion(), equalTo(1l)); + assertThat(response.getItems()[0].getVersion(), equalTo(1L)); // Before 2.0 alias filters were parsed at alias creation time, in order // for filters to work correctly ES required that fields mentioned in those @@ -661,7 +661,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { assertThat(response.hasFailures(), is(false)); assertThat(response.getItems()[0].isFailed(), equalTo(false)); assertThat(response.getItems()[0].getId(), equalTo("test")); - assertThat(response.getItems()[0].getVersion(), equalTo(1l)); + assertThat(response.getItems()[0].getVersion(), equalTo(1L)); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java b/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java index 1a6e0c46df5..bcbe41dd66f 100644 --- a/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java +++ b/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java @@ -47,6 +47,7 @@ import java.util.Map; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; @@ -200,6 +201,39 @@ public class IngestClientIT extends ESIntegTestCase { assertThat(getResponse.pipelines().size(), equalTo(0)); } + public void testPutWithPipelineError() throws Exception { + BytesReference source = jsonBuilder().startObject() + .field("description", "my_pipeline") + .startArray("processors") + .startObject() + .startObject("not_found") + .endObject() + .endObject() + .endArray() + .endObject().bytes(); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source); + WritePipelineResponse response = client().admin().cluster().putPipeline(putPipelineRequest).get(); + assertThat(response.isAcknowledged(), equalTo(false)); + assertThat(response.getError().getReason(), equalTo("No processor type exists with name [not_found]")); + } + + public void testPutWithProcessorFactoryError() throws Exception { + BytesReference source = jsonBuilder().startObject() + .field("description", "my_pipeline") + .startArray("processors") + .startObject() + .startObject("test") + .field("unused", ":sad_face:") + .endObject() + .endObject() + .endArray() + .endObject().bytes(); + PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source); + WritePipelineResponse response = client().admin().cluster().putPipeline(putPipelineRequest).get(); + assertThat(response.isAcknowledged(), equalTo(false)); + assertThat(response.getError().getReason(), equalTo("processor [test] doesn't support one or more provided configuration parameters [unused]")); + } + @Override protected Collection> getMockPlugins() { return Collections.singletonList(TestSeedPlugin.class); diff --git a/core/src/test/java/org/elasticsearch/ingest/PipelineStoreTests.java b/core/src/test/java/org/elasticsearch/ingest/PipelineStoreTests.java index 117b95b2cd7..a75a84f0379 100644 --- a/core/src/test/java/org/elasticsearch/ingest/PipelineStoreTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/PipelineStoreTests.java @@ -22,6 +22,7 @@ package org.elasticsearch.ingest; import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ingest.DeletePipelineRequest; import org.elasticsearch.action.ingest.PutPipelineRequest; +import org.elasticsearch.action.ingest.WritePipelineResponse; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.MetaData; @@ -41,7 +42,6 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; -import static org.mockito.Mockito.mock; public class PipelineStoreTests extends ESTestCase { @@ -102,6 +102,45 @@ public class PipelineStoreTests extends ESTestCase { assertThat(pipeline.getProcessors().size(), equalTo(0)); } + public void testPutWithErrorResponse() { + + } + + public void testConstructPipelineResponseSuccess() { + Map processorConfig = new HashMap<>(); + processorConfig.put("field", "foo"); + processorConfig.put("value", "bar"); + Map pipelineConfig = new HashMap<>(); + pipelineConfig.put("description", "_description"); + pipelineConfig.put("processors", Collections.singletonList(Collections.singletonMap("set", processorConfig))); + WritePipelineResponse response = store.validatePipelineResponse("test_id", pipelineConfig); + assertThat(response, nullValue()); + } + + public void testConstructPipelineResponseMissingProcessorsFieldException() { + Map pipelineConfig = new HashMap<>(); + pipelineConfig.put("description", "_description"); + WritePipelineResponse response = store.validatePipelineResponse("test_id", pipelineConfig); + assertThat(response.getError().getProcessorType(), is(nullValue())); + assertThat(response.getError().getProcessorTag(), is(nullValue())); + assertThat(response.getError().getProcessorPropertyName(), equalTo("processors")); + assertThat(response.getError().getReason(), equalTo("[processors] required property is missing")); + } + + public void testConstructPipelineResponseConfigurationException() { + Map processorConfig = new HashMap<>(); + processorConfig.put("field", "foo"); + Map pipelineConfig = new HashMap<>(); + pipelineConfig.put("description", "_description"); + pipelineConfig.put("processors", Collections.singletonList(Collections.singletonMap("set", processorConfig))); + WritePipelineResponse response = store.validatePipelineResponse("test_id", pipelineConfig); + + assertThat(response.getError().getProcessorTag(), nullValue()); + assertThat(response.getError().getProcessorType(), equalTo("set")); + assertThat(response.getError().getProcessorPropertyName(), equalTo("value")); + assertThat(response.getError().getReason(), equalTo("[value] required property is missing")); + } + public void testDelete() { PipelineConfiguration config = new PipelineConfiguration( "_id",new BytesArray("{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\"}}]}") diff --git a/core/src/test/java/org/elasticsearch/ingest/core/ConfigurationUtilsTests.java b/core/src/test/java/org/elasticsearch/ingest/core/ConfigurationUtilsTests.java index 958378f355a..954a03c2172 100644 --- a/core/src/test/java/org/elasticsearch/ingest/core/ConfigurationUtilsTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/core/ConfigurationUtilsTests.java @@ -19,11 +19,13 @@ package org.elasticsearch.ingest.core; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import org.elasticsearch.test.ESTestCase; import org.junit.Before; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -49,21 +51,21 @@ public class ConfigurationUtilsTests extends ESTestCase { } public void testReadStringProperty() { - String val = ConfigurationUtils.readStringProperty(config, "foo"); + String val = ConfigurationUtils.readStringProperty(null, null, config, "foo"); assertThat(val, equalTo("bar")); } public void testReadStringPropertyInvalidType() { try { - ConfigurationUtils.readStringProperty(config, "arr"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("property [arr] isn't a string, but of type [java.util.Arrays$ArrayList]")); + ConfigurationUtils.readStringProperty(null, null, config, "arr"); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[arr] property isn't a string, but of type [java.util.Arrays$ArrayList]")); } } // TODO(talevy): Issue with generics. This test should fail, "int" is of type List public void testOptional_InvalidType() { - List val = ConfigurationUtils.readList(config, "int"); - assertThat(val, equalTo(Arrays.asList(2))); + List val = ConfigurationUtils.readList(null, null, config, "int"); + assertThat(val, equalTo(Collections.singletonList(2))); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/core/PipelineFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/core/PipelineFactoryTests.java index 229290372b6..746ac2f5617 100644 --- a/core/src/test/java/org/elasticsearch/ingest/core/PipelineFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/core/PipelineFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.core; import org.elasticsearch.ingest.TestProcessor; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import org.elasticsearch.test.ESTestCase; import java.util.Arrays; @@ -51,6 +52,18 @@ public class PipelineFactoryTests extends ESTestCase { assertThat(pipeline.getProcessors().get(1).getTag(), nullValue()); } + public void testCreateWithNoProcessorsField() throws Exception { + Map pipelineConfig = new HashMap<>(); + pipelineConfig.put(Pipeline.DESCRIPTION_KEY, "_description"); + Pipeline.Factory factory = new Pipeline.Factory(); + try { + factory.create("_id", pipelineConfig, Collections.emptyMap()); + fail("should fail, missing required [processors] field"); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[processors] required property is missing")); + } + } + public void testCreateWithPipelineOnFailure() throws Exception { Map processorConfig = new HashMap<>(); Map pipelineConfig = new HashMap<>(); @@ -78,7 +91,7 @@ public class PipelineFactoryTests extends ESTestCase { Map processorRegistry = Collections.singletonMap("test", new TestProcessor.Factory()); try { factory.create("_id", pipelineConfig, processorRegistry); - } catch (IllegalArgumentException e) { + } catch (ConfigurationPropertyException e) { assertThat(e.getMessage(), equalTo("processor [test] doesn't support one or more provided configuration parameters [unused]")); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/AppendProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/AppendProcessorFactoryTests.java index b72c144605f..c4c13a6ab7d 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/AppendProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/AppendProcessorFactoryTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -64,8 +65,8 @@ public class AppendProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -75,8 +76,8 @@ public class AppendProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [value] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } @@ -87,8 +88,8 @@ public class AppendProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [value] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/ConvertProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/ConvertProcessorFactoryTests.java index 706433141d4..a07cec5c4e7 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/ConvertProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/ConvertProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import org.hamcrest.Matchers; @@ -66,8 +67,8 @@ public class ConvertProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), Matchers.equalTo("required property [field] is missing")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), Matchers.equalTo("[field] required property is missing")); } } @@ -78,8 +79,8 @@ public class ConvertProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), Matchers.equalTo("required property [type] is missing")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), Matchers.equalTo("[type] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/DateProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/DateProcessorFactoryTests.java index a145a7c5149..1139f1968f7 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/DateProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/DateProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import org.joda.time.DateTimeZone; @@ -63,8 +64,8 @@ public class DateProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("processor creation should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), containsString("required property [match_field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), containsString("[match_field] required property is missing")); } } @@ -79,8 +80,8 @@ public class DateProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("processor creation should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), containsString("required property [match_formats] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), containsString("[match_formats] required property is missing")); } } @@ -169,8 +170,8 @@ public class DateProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("processor creation should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), containsString("property [match_formats] isn't a list, but of type [java.lang.String]")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), containsString("[match_formats] property isn't a list, but of type [java.lang.String]")); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/FailProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/FailProcessorFactoryTests.java index 993c7ccd904..661a6383dfd 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/FailProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/FailProcessorFactoryTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -54,8 +55,8 @@ public class FailProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [message] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[message] required property is missing")); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/GsubProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/GsubProcessorFactoryTests.java index fd62f6cdeac..bce033091ac 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/GsubProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/GsubProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -52,8 +53,8 @@ public class GsubProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -65,8 +66,8 @@ public class GsubProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [pattern] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[pattern] required property is missing")); } } @@ -78,8 +79,8 @@ public class GsubProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [replacement] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[replacement] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/JoinProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/JoinProcessorFactoryTests.java index 2af2b096417..51eb989beda 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/JoinProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/JoinProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -49,8 +50,8 @@ public class JoinProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -61,8 +62,8 @@ public class JoinProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [separator] is missing")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[separator] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/LowercaseProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/LowercaseProcessorFactoryTests.java index 6a4a67e40cf..32eefa07896 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/LowercaseProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/LowercaseProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -46,8 +47,8 @@ public class LowercaseProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/RemoveProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/RemoveProcessorFactoryTests.java index 0b03150adb6..5b03d288064 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/RemoveProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/RemoveProcessorFactoryTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -54,8 +55,8 @@ public class RemoveProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/RenameProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/RenameProcessorFactoryTests.java index 21f5c663671..ea6284f305a 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/RenameProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/RenameProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -49,8 +50,8 @@ public class RenameProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -61,8 +62,8 @@ public class RenameProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [to] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[to] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/SetProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/SetProcessorFactoryTests.java index a58ee491a7c..1c3cf15e48f 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/SetProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/SetProcessorFactoryTests.java @@ -21,6 +21,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.TestTemplateService; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -57,8 +58,8 @@ public class SetProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -68,8 +69,8 @@ public class SetProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [value] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } @@ -80,8 +81,8 @@ public class SetProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [value] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[value] required property is missing")); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/SplitProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/SplitProcessorFactoryTests.java index 7267544c1ff..3bd2f95e2bc 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/SplitProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/SplitProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -49,8 +50,8 @@ public class SplitProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } @@ -61,8 +62,8 @@ public class SplitProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [separator] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[separator] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/TrimProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/TrimProcessorFactoryTests.java index 350aaa66e6d..8012893bfcb 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/TrimProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/TrimProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -46,8 +47,8 @@ public class TrimProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/ingest/processor/UppercaseProcessorFactoryTests.java b/core/src/test/java/org/elasticsearch/ingest/processor/UppercaseProcessorFactoryTests.java index 2220438c75f..914909f9378 100644 --- a/core/src/test/java/org/elasticsearch/ingest/processor/UppercaseProcessorFactoryTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/processor/UppercaseProcessorFactoryTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.ingest.processor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -46,8 +47,8 @@ public class UppercaseProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("factory create should have failed"); - } catch(IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("required property [field] is missing")); + } catch(ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); } } } diff --git a/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java new file mode 100644 index 00000000000..29f497458c7 --- /dev/null +++ b/core/src/test/java/org/elasticsearch/monitor/jvm/JvmGcMonitorServiceSettingsTests.java @@ -0,0 +1,113 @@ +/* + * 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.monitor.jvm; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.threadpool.ThreadPool; + +import java.util.AbstractMap; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.BiFunction; +import java.util.function.Consumer; + +import static org.hamcrest.CoreMatchers.allOf; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.instanceOf; + +public class JvmGcMonitorServiceSettingsTests extends ESTestCase { + + public void testEmptySettingsAreOkay() throws InterruptedException { + AtomicBoolean scheduled = new AtomicBoolean(); + execute(Settings.EMPTY, (command, interval) -> { scheduled.set(true); return null; }, () -> assertTrue(scheduled.get())); + } + + public void testDisabledSetting() throws InterruptedException { + Settings settings = Settings.builder().put("monitor.jvm.gc.enabled", "false").build(); + AtomicBoolean scheduled = new AtomicBoolean(); + execute(settings, (command, interval) -> { scheduled.set(true); return null; }, () -> assertFalse(scheduled.get())); + } + + public void testNegativeSetting() throws InterruptedException { + String collector = randomAsciiOfLength(5); + Settings settings = Settings.builder().put("monitor.jvm.gc.collector." + collector + ".warn", "-" + randomTimeValue()).build(); + execute(settings, (command, interval) -> null, t -> { + assertThat(t, instanceOf(IllegalArgumentException.class)); + assertThat(t.getMessage(), allOf(containsString("invalid gc_threshold"), containsString("for [monitor.jvm.gc.collector." + collector + "."))); + }, true, null); + } + + public void testMissingSetting() throws InterruptedException { + String collector = randomAsciiOfLength(5); + Set> entries = new HashSet<>(); + entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".warn", randomTimeValue())); + entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".info", randomTimeValue())); + entries.add(new AbstractMap.SimpleEntry<>("monitor.jvm.gc.collector." + collector + ".debug", randomTimeValue())); + Settings.Builder builder = Settings.builder(); + + // drop a random setting or two + for (@SuppressWarnings("unchecked") AbstractMap.SimpleEntry entry : randomSubsetOf(randomIntBetween(1, 2), entries.toArray(new AbstractMap.SimpleEntry[0]))) { + builder.put(entry.getKey(), entry.getValue()); + } + + // we should get an exception that a setting is missing + execute(builder.build(), (command, interval) -> null, t -> { + assertThat(t, instanceOf(IllegalArgumentException.class)); + assertThat(t.getMessage(), containsString("missing gc_threshold for [monitor.jvm.gc.collector." + collector + ".")); + }, true, null); + } + + private static void execute(Settings settings, BiFunction> scheduler, Runnable asserts) throws InterruptedException { + execute(settings, scheduler, null, false, asserts); + } + + private static void execute(Settings settings, BiFunction> scheduler, Consumer consumer, boolean constructionShouldFail, Runnable asserts) throws InterruptedException { + assert constructionShouldFail == (consumer != null); + assert constructionShouldFail == (asserts == null); + ThreadPool threadPool = null; + try { + threadPool = new ThreadPool(JvmGcMonitorServiceSettingsTests.class.getCanonicalName()) { + @Override + public ScheduledFuture scheduleWithFixedDelay(Runnable command, TimeValue interval) { + return scheduler.apply(command, interval); + } + }; + try { + JvmGcMonitorService service = new JvmGcMonitorService(settings, threadPool); + if (constructionShouldFail) { + fail("construction of jvm gc service should have failed"); + } + service.doStart(); + asserts.run(); + service.doStop(); + } catch (Throwable t) { + consumer.accept(t); + } + } finally { + ThreadPool.terminate(threadPool, 30, TimeUnit.SECONDS); + } + } + +} diff --git a/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java b/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java index 2a121be509c..d1f25a8fb4f 100644 --- a/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java +++ b/core/src/test/java/org/elasticsearch/options/detailederrors/DetailedErrorsDisabledIT.java @@ -23,8 +23,7 @@ import org.apache.http.impl.client.HttpClients; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.http.netty.NettyHttpServerTransport; -import org.elasticsearch.node.Node; +import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; @@ -45,7 +44,7 @@ public class DetailedErrorsDisabledIT extends ESIntegTestCase { return Settings.settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) .put(NetworkModule.HTTP_ENABLED.getKey(), true) - .put(NettyHttpServerTransport.SETTING_HTTP_DETAILED_ERRORS_ENABLED.getKey(), false) + .put(HttpTransportSettings.SETTING_HTTP_DETAILED_ERRORS_ENABLED.getKey(), false) .build(); } diff --git a/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java index 178f070927c..5c046663755 100644 --- a/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/ConcurrentPercolatorIT.java @@ -210,7 +210,7 @@ public class ConcurrentPercolatorIT extends ESIntegTestCase { throw new IllegalStateException("Illegal x=" + x); } assertThat(response.getId(), equalTo(id)); - assertThat(response.getVersion(), equalTo(1l)); + assertThat(response.getVersion(), equalTo(1L)); } } catch (Throwable t) { exceptionsHolder.add(t); diff --git a/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java index abd158788f0..31115a2565b 100644 --- a/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/MultiPercolatorIT.java @@ -96,7 +96,7 @@ public class MultiPercolatorIT extends ESIntegTestCase { .execute().actionGet(); MultiPercolateResponse.Item item = response.getItems()[0]; - assertMatchCount(item.getResponse(), 2l); + assertMatchCount(item.getResponse(), 2L); assertThat(item.getResponse().getMatches(), arrayWithSize(2)); assertThat(item.getErrorMessage(), nullValue()); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContainingInAnyOrder("1", "4")); @@ -104,18 +104,18 @@ public class MultiPercolatorIT extends ESIntegTestCase { item = response.getItems()[1]; assertThat(item.getErrorMessage(), nullValue()); - assertMatchCount(item.getResponse(), 2l); + assertMatchCount(item.getResponse(), 2L); assertThat(item.getResponse().getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); item = response.getItems()[2]; assertThat(item.getErrorMessage(), nullValue()); - assertMatchCount(item.getResponse(), 4l); + assertMatchCount(item.getResponse(), 4L); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4")); item = response.getItems()[3]; assertThat(item.getErrorMessage(), nullValue()); - assertMatchCount(item.getResponse(), 1l); + assertMatchCount(item.getResponse(), 1L); assertThat(item.getResponse().getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContaining("4")); @@ -175,7 +175,7 @@ public class MultiPercolatorIT extends ESIntegTestCase { .execute().actionGet(); MultiPercolateResponse.Item item = response.getItems()[0]; - assertMatchCount(item.getResponse(), 2l); + assertMatchCount(item.getResponse(), 2L); assertThat(item.getResponse().getMatches(), arrayWithSize(2)); assertThat(item.getErrorMessage(), nullValue()); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContainingInAnyOrder("1", "4")); @@ -183,18 +183,18 @@ public class MultiPercolatorIT extends ESIntegTestCase { item = response.getItems()[1]; assertThat(item.getErrorMessage(), nullValue()); - assertMatchCount(item.getResponse(), 2l); + assertMatchCount(item.getResponse(), 2L); assertThat(item.getResponse().getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); item = response.getItems()[2]; assertThat(item.getErrorMessage(), nullValue()); - assertMatchCount(item.getResponse(), 4l); + assertMatchCount(item.getResponse(), 4L); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4")); item = response.getItems()[3]; assertThat(item.getErrorMessage(), nullValue()); - assertMatchCount(item.getResponse(), 1l); + assertMatchCount(item.getResponse(), 1L); assertThat(item.getResponse().getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(item.getResponse().getMatches(), "test"), arrayContaining("4")); diff --git a/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java index 55db76c0d7c..9bd5a74312c 100644 --- a/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/PercolatorIT.java @@ -135,7 +135,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "b").endObject())) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "4")); @@ -144,7 +144,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setPercolateDoc(docBuilder().setDoc(yamlBuilder().startObject().field("field1", "c").endObject())) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); @@ -153,7 +153,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setPercolateDoc(docBuilder().setDoc(smileBuilder().startObject().field("field1", "b c").endObject())) .execute().actionGet(); - assertMatchCount(response, 4l); + assertMatchCount(response, 4L); assertThat(response.getMatches(), arrayWithSize(4)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4")); @@ -162,7 +162,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "d").endObject())) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("4")); @@ -190,7 +190,7 @@ public class PercolatorIT extends ESIntegTestCase { PercolateResponse response = client().preparePercolate().setSource(doc) .setIndices("test").setDocumentType("type1") .execute().actionGet(); - assertMatchCount(response, 0l); + assertMatchCount(response, 0L); assertThat(response.getMatches(), emptyArray()); // add first query... @@ -202,7 +202,7 @@ public class PercolatorIT extends ESIntegTestCase { response = client().preparePercolate() .setIndices("test").setDocumentType("type1") .setSource(doc).execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("test1")); @@ -216,7 +216,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(doc) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("test1", "test2")); @@ -226,7 +226,7 @@ public class PercolatorIT extends ESIntegTestCase { response = client().preparePercolate() .setIndices("test").setDocumentType("type1") .setSource(doc).execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("test1")); } @@ -252,7 +252,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject())) .setSize(100) .execute().actionGet(); - assertMatchCount(response, 100l); + assertMatchCount(response, 100L); assertThat(response.getMatches(), arrayWithSize(100)); logger.info("--> Percolate doc with routing=0"); @@ -262,7 +262,7 @@ public class PercolatorIT extends ESIntegTestCase { .setSize(100) .setRouting("0") .execute().actionGet(); - assertMatchCount(response, 50l); + assertMatchCount(response, 50L); assertThat(response.getMatches(), arrayWithSize(50)); logger.info("--> Percolate doc with routing=1"); @@ -272,7 +272,7 @@ public class PercolatorIT extends ESIntegTestCase { .setSize(100) .setRouting("1") .execute().actionGet(); - assertMatchCount(response, 50l); + assertMatchCount(response, 50L); assertThat(response.getMatches(), arrayWithSize(50)); } @@ -339,7 +339,7 @@ public class PercolatorIT extends ESIntegTestCase { .field("query", termQuery("source", "productizer")) .endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); } @@ -361,7 +361,7 @@ public class PercolatorIT extends ESIntegTestCase { SearchResponse countResponse = client().prepareSearch().setSize(0) .setQuery(matchAllQuery()).setTypes(PercolatorService.TYPE_NAME) .execute().actionGet(); - assertThat(countResponse.getHits().totalHits(), equalTo(1l)); + assertThat(countResponse.getHits().totalHits(), equalTo(1L)); for (int i = 0; i < 10; i++) { @@ -369,7 +369,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value1").endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); } @@ -379,7 +379,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPreference("_local") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value1").endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); } @@ -390,7 +390,7 @@ public class PercolatorIT extends ESIntegTestCase { countResponse = client().prepareSearch().setSize(0) .setQuery(matchAllQuery()).setTypes(PercolatorService.TYPE_NAME) .execute().actionGet(); - assertHitCount(countResponse, 0l); + assertHitCount(countResponse, 0L); } public void testMultiplePercolators() throws Exception { @@ -419,7 +419,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value1").endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(percolate.getMatches(), "test"), arrayContaining("kuku")); @@ -427,7 +427,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value2").endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(percolate.getMatches(), "test"), arrayContaining("bubu")); @@ -453,7 +453,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value1").endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(percolate.getMatches(), "test"), arrayContaining("kuku")); @@ -470,7 +470,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value2").endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(percolate.getMatches(), "test"), arrayContaining("bubu")); @@ -490,7 +490,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(sourceBuilder) .execute().actionGet(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(percolate.getMatches(), "test"), arrayContaining("susu")); @@ -503,7 +503,7 @@ public class PercolatorIT extends ESIntegTestCase { .field("field1", "value1") .endObject().endObject().endObject()) .execute().actionGet(); - assertMatchCount(percolate, 0l); + assertMatchCount(percolate, 0L); assertThat(percolate.getMatches(), emptyArray()); } @@ -522,16 +522,16 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field", "val").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("1")); NumShards numShards = getNumShards("test"); IndicesStatsResponse indicesResponse = client().admin().indices().prepareStats("test").execute().actionGet(); assertThat(indicesResponse.getTotal().getPercolate().getCount(), equalTo((long) numShards.numPrimaries)); - assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0l)); + assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0L)); assertThat(indicesResponse.getTotal().getPercolate().getNumQueries(), equalTo((long)numShards.dataCopies)); //number of copies - assertThat(indicesResponse.getTotal().getPercolate().getMemorySizeInBytes(), equalTo(-1l)); + assertThat(indicesResponse.getTotal().getPercolate().getMemorySizeInBytes(), equalTo(-1L)); NodesStatsResponse nodesResponse = client().admin().cluster().prepareNodesStats().execute().actionGet(); long percolateCount = 0; @@ -545,15 +545,15 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field", "val").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("1")); indicesResponse = client().admin().indices().prepareStats().setPercolate(true).execute().actionGet(); assertThat(indicesResponse.getTotal().getPercolate().getCount(), equalTo((long) numShards.numPrimaries * 2)); - assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0l)); + assertThat(indicesResponse.getTotal().getPercolate().getCurrent(), equalTo(0L)); assertThat(indicesResponse.getTotal().getPercolate().getNumQueries(), equalTo((long)numShards.dataCopies)); //number of copies - assertThat(indicesResponse.getTotal().getPercolate().getMemorySizeInBytes(), equalTo(-1l)); + assertThat(indicesResponse.getTotal().getPercolate().getMemorySizeInBytes(), equalTo(-1L)); percolateCount = 0; nodesResponse = client().admin().cluster().prepareNodesStats().execute().actionGet(); @@ -588,7 +588,7 @@ public class PercolatorIT extends ESIntegTestCase { percolateCount += nodeStats.getIndices().getPercolate().getCount(); percolateSumTime += nodeStats.getIndices().getPercolate().getTimeInMillis(); } - assertThat(percolateSumTime, greaterThan(0l)); + assertThat(percolateSumTime, greaterThan(0L)); } public void testPercolatingExistingDocs() throws Exception { @@ -624,7 +624,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("1")) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "4")); @@ -633,7 +633,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("2")) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); @@ -642,7 +642,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("3")) .execute().actionGet(); - assertMatchCount(response, 4l); + assertMatchCount(response, 4L); assertThat(response.getMatches(), arrayWithSize(4)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4")); @@ -651,7 +651,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("4")) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("4")); } @@ -689,7 +689,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("1").routing("4")) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "4")); @@ -698,7 +698,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("2").routing("3")) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); @@ -707,7 +707,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("3").routing("2")) .execute().actionGet(); - assertMatchCount(response, 4l); + assertMatchCount(response, 4L); assertThat(response.getMatches(), arrayWithSize(4)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4")); @@ -716,7 +716,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setGetRequest(Requests.getRequest("test").type("type").id("4").routing("1")) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContaining("4")); } @@ -752,9 +752,9 @@ public class PercolatorIT extends ESIntegTestCase { logger.info("--> Percolate existing doc with id 2 and version 1"); PercolateResponse response = client().preparePercolate() .setIndices("test").setDocumentType("type") - .setGetRequest(Requests.getRequest("test").type("type").id("2").version(1l)) + .setGetRequest(Requests.getRequest("test").type("type").id("2").version(1L)) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); @@ -762,7 +762,7 @@ public class PercolatorIT extends ESIntegTestCase { try { client().preparePercolate() .setIndices("test").setDocumentType("type") - .setGetRequest(Requests.getRequest("test").type("type").id("2").version(2l)) + .setGetRequest(Requests.getRequest("test").type("type").id("2").version(2L)) .execute().actionGet(); fail("Error should have been thrown"); } catch (VersionConflictEngineException e) { @@ -774,9 +774,9 @@ public class PercolatorIT extends ESIntegTestCase { logger.info("--> Percolate existing doc with id 2 and version 2"); response = client().preparePercolate() .setIndices("test").setDocumentType("type") - .setGetRequest(Requests.getRequest("test").type("type").id("2").version(2l)) + .setGetRequest(Requests.getRequest("test").type("type").id("2").version(2L)) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("2", "4")); } @@ -799,7 +799,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test1").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); logger.info("--> Percolate doc to index test2"); @@ -807,7 +807,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test2").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); logger.info("--> Percolate doc to index test1 and test2"); @@ -815,7 +815,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test1", "test2").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 10l); + assertMatchCount(response, 10L); assertThat(response.getMatches(), arrayWithSize(10)); logger.info("--> Percolate doc to index test2 and test3, with ignore missing"); @@ -824,7 +824,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); logger.info("--> Adding aliases"); @@ -841,7 +841,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("my-alias1").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 10l); + assertMatchCount(response, 10L); assertThat(response.getMatches(), arrayWithSize(10)); for (PercolateResponse.Match match : response) { assertThat(match.getIndex().string(), anyOf(equalTo("test1"), equalTo("test2"))); @@ -852,7 +852,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("my-alias2").setDocumentType("type") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", "value").endObject().endObject()) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); for (PercolateResponse.Match match : response) { assertThat(match.getIndex().string(), equalTo("test2")); @@ -883,7 +883,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}")) .get(); assertNoFailures(response); - assertThat(response.getCount(), equalTo(1l)); + assertThat(response.getCount(), equalTo(1L)); assertThat(response.getMatches()[0].getId().string(), equalTo("1")); response = client().preparePercolate() @@ -892,7 +892,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}")) .get(); assertNoFailures(response); - assertThat(response.getCount(), equalTo(1l)); + assertThat(response.getCount(), equalTo(1L)); assertThat(response.getMatches()[0].getId().string(), equalTo("2")); @@ -902,7 +902,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc("{}")) .get(); assertNoFailures(response); - assertThat(response.getCount(), equalTo(0l)); + assertThat(response.getCount(), equalTo(0L)); // Testing that the alias filter and the filter specified while percolating are both taken into account. response = client().preparePercolate() @@ -912,7 +912,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateQuery(QueryBuilders.matchAllQuery()) .get(); assertNoFailures(response); - assertThat(response.getCount(), equalTo(1l)); + assertThat(response.getCount(), equalTo(1L)); assertThat(response.getMatches()[0].getId().string(), equalTo("1")); response = client().preparePercolate() @@ -922,7 +922,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateQuery(QueryBuilders.matchAllQuery()) .get(); assertNoFailures(response); - assertThat(response.getCount(), equalTo(1l)); + assertThat(response.getCount(), equalTo(1L)); assertThat(response.getMatches()[0].getId().string(), equalTo("2")); @@ -933,7 +933,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateQuery(QueryBuilders.matchAllQuery()) .get(); assertNoFailures(response); - assertThat(response.getCount(), equalTo(0l)); + assertThat(response.getCount(), equalTo(0L)); } public void testCountPercolation() throws Exception { @@ -966,7 +966,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "b").endObject())) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate doc with field1=c"); @@ -974,7 +974,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setPercolateDoc(docBuilder().setDoc(yamlBuilder().startObject().field("field1", "c").endObject())) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate doc with field1=b c"); @@ -982,7 +982,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setPercolateDoc(docBuilder().setDoc(smileBuilder().startObject().field("field1", "b c").endObject())) .execute().actionGet(); - assertMatchCount(response, 4l); + assertMatchCount(response, 4L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate doc with field1=d"); @@ -990,7 +990,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "d").endObject())) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate non existing doc"); @@ -1037,7 +1037,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setGetRequest(Requests.getRequest("test").type("type").id("1")) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate existing doc with id 2"); @@ -1045,7 +1045,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setGetRequest(Requests.getRequest("test").type("type").id("2")) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate existing doc with id 3"); @@ -1053,7 +1053,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setGetRequest(Requests.getRequest("test").type("type").id("3")) .execute().actionGet(); - assertMatchCount(response, 4l); + assertMatchCount(response, 4L); assertThat(response.getMatches(), nullValue()); logger.info("--> Count percolate existing doc with id 4"); @@ -1061,7 +1061,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type").setOnlyCount(true) .setGetRequest(Requests.getRequest("test").type("type").id("4")) .execute().actionGet(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), nullValue()); } @@ -1264,7 +1264,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(docBuilder().setDoc("field", "value")) .setPercolateQuery(QueryBuilders.functionScoreQuery(matchAllQuery(), fieldValueFactorFunction("level"))) .execute().actionGet(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches()[0].getId().string(), equalTo("2")); assertThat(response.getMatches()[0].getScore(), equalTo(2f)); assertThat(response.getMatches()[1].getId().string(), equalTo("1")); @@ -1308,7 +1308,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(docBuilder().setDoc("field", "value")) .setPercolateQuery(QueryBuilders.functionScoreQuery(matchAllQuery(), fieldValueFactorFunction("level"))) .execute().actionGet(); - assertMatchCount(response, 0l); + assertMatchCount(response, 0L); } public void testPercolatorWithHighlighting() throws Exception { @@ -1346,7 +1346,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "The quick brown fox jumps over the lazy dog").endObject())) .setHighlightBuilder(new HighlightBuilder().field("field1")) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4", "5")); @@ -1372,7 +1372,7 @@ public class PercolatorIT extends ESIntegTestCase { .setHighlightBuilder(new HighlightBuilder().field("field1")) .setPercolateQuery(matchAllQuery()) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4", "5")); @@ -1431,7 +1431,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateQuery(functionScoreQuery(new WeightBuilder().setWeight(5.5f))) .setSortByScore(true) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4", "5")); @@ -1463,7 +1463,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateQuery(functionScoreQuery(new WeightBuilder().setWeight(5.5f))) .setSortByScore(true) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4", "5")); @@ -1501,7 +1501,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateQuery(functionScoreQuery(new WeightBuilder().setWeight(5.5f))) .setSortByScore(true) .execute().actionGet(); - assertMatchCount(response, 5l); + assertMatchCount(response, 5L); assertThat(response.getMatches(), arrayWithSize(5)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2", "3", "4", "5")); @@ -1547,7 +1547,7 @@ public class PercolatorIT extends ESIntegTestCase { .endObject()) .execute().actionGet(); assertNoFailures(percolate); - assertMatchCount(percolate, 0l); + assertMatchCount(percolate, 0L); } public void testNestedPercolation() throws IOException { @@ -1597,7 +1597,7 @@ public class PercolatorIT extends ESIntegTestCase { .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field", "value").endObject())) .setPercolateQuery(QueryBuilders.matchAllQuery()) .get(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1")); } @@ -1644,7 +1644,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("my-type") .setPercolateDoc(docBuilder().setDoc("timestamp", System.currentTimeMillis())) .get(); - assertMatchCount(response, 2l); + assertMatchCount(response, 2L); assertThat(response.getMatches(), arrayWithSize(2)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("1", "2")); } @@ -1799,7 +1799,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("doc") .setPercolateDoc(docBuilder().setDoc(doc)) .get(); - assertMatchCount(response, 3l); + assertMatchCount(response, 3L); Set expectedIds = new HashSet<>(); expectedIds.add("q1"); expectedIds.add("q4"); @@ -1812,12 +1812,12 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("doc") .setPercolateDoc(docBuilder().setDoc(doc)) .get(); - assertMatchCount(response, 3l); + assertMatchCount(response, 3L); response = client().preparePercolate().setScore(randomBoolean()).setSortByScore(randomBoolean()).setOnlyCount(randomBoolean()).setSize(10).setPercolateQuery(QueryBuilders.termQuery("text", "foo")) .setIndices("test").setDocumentType("doc") .setPercolateDoc(docBuilder().setDoc(doc)) .get(); - assertMatchCount(response, 3l); + assertMatchCount(response, 3L); } public void testMapUnmappedFieldAsString() throws IOException{ @@ -1835,7 +1835,7 @@ public class PercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type") .setPercolateDoc(docBuilder().setDoc(jsonBuilder().startObject().field("field1", "value").endObject())) .execute().actionGet(); - assertMatchCount(response1, 1l); + assertMatchCount(response1, 1L); assertThat(response1.getMatches(), arrayWithSize(1)); } diff --git a/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java index c93bedf9e84..4005754f31f 100644 --- a/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/RecoveryPercolatorIT.java @@ -99,7 +99,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .field("field1", "value1") .endObject().endObject()) .get(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); } @@ -116,7 +116,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .setRefresh(true) .get(); - assertThat(client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get().getHits().totalHits(), equalTo(1L)); PercolateResponse percolate = client().preparePercolate() .setIndices("test").setDocumentType("type1") @@ -124,7 +124,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .field("field1", "value1") .endObject().endObject()) .get(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); internalCluster().rollingRestart(); @@ -134,7 +134,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { logger.info("Done Cluster Health, status " + clusterHealth.getStatus()); assertThat(clusterHealth.isTimedOut(), equalTo(false)); SearchResponse countResponse = client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); DeleteIndexResponse actionGet = client().admin().indices().prepareDelete("test").get(); assertThat(actionGet.isAcknowledged(), equalTo(true)); @@ -142,7 +142,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet(); logger.info("Done Cluster Health, status " + clusterHealth.getStatus()); assertThat(clusterHealth.isTimedOut(), equalTo(false)); - assertThat(client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get().getHits().totalHits(), equalTo(0l)); + assertThat(client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get().getHits().totalHits(), equalTo(0L)); percolate = client().preparePercolate() .setIndices("test").setDocumentType("type1") @@ -150,7 +150,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .field("field1", "value1") .endObject().endObject()) .get(); - assertMatchCount(percolate, 0l); + assertMatchCount(percolate, 0L); assertThat(percolate.getMatches(), emptyArray()); logger.info("--> register a query"); @@ -162,7 +162,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .setRefresh(true) .get(); - assertThat(client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setSize(0).setTypes(PercolatorService.TYPE_NAME).setQuery(matchAllQuery()).get().getHits().totalHits(), equalTo(1L)); percolate = client().preparePercolate() .setIndices("test").setDocumentType("type1") @@ -170,7 +170,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .field("field1", "value1") .endObject().endObject()) .get(); - assertMatchCount(percolate, 1l); + assertMatchCount(percolate, 1L); assertThat(percolate.getMatches(), arrayWithSize(1)); } @@ -202,7 +202,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", 95).endObject().endObject()) .get(); - assertMatchCount(response, 6l); + assertMatchCount(response, 6L); assertThat(response.getMatches(), arrayWithSize(6)); assertThat(convertFromTextArray(response.getMatches(), "test"), arrayContainingInAnyOrder("95", "96", "97", "98", "99", "100")); @@ -216,7 +216,7 @@ public class RecoveryPercolatorIT extends ESIntegTestCase { .setIndices("test").setDocumentType("type1") .setSource(jsonBuilder().startObject().startObject("doc").field("field1", 100).endObject().endObject()).get(); - assertMatchCount(response, 1l); + assertMatchCount(response, 1L); assertThat(response.getMatches(), arrayWithSize(1)); assertThat(response.getMatches()[0].getId().string(), equalTo("100")); } diff --git a/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java b/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java index 43ca89923f2..b1cd982e997 100644 --- a/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java +++ b/core/src/test/java/org/elasticsearch/percolator/TTLPercolatorIT.java @@ -148,7 +148,7 @@ public class TTLPercolatorIT extends ESIntegTestCase { .endObject() .endObject() ).execute().actionGet(); - assertMatchCount(percolateResponse, 0l); + assertMatchCount(percolateResponse, 0L); assertThat(percolateResponse.getMatches(), emptyArray()); } diff --git a/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java b/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java index 663d951a087..61dca3f37af 100644 --- a/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java +++ b/core/src/test/java/org/elasticsearch/recovery/FullRollingRestartIT.java @@ -91,7 +91,7 @@ public class FullRollingRestartIT extends ESIntegTestCase { logger.info("--> refreshing and checking data"); refresh(); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2000l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2000L); } // now start shutting nodes down @@ -109,7 +109,7 @@ public class FullRollingRestartIT extends ESIntegTestCase { logger.info("--> stopped two nodes, verifying data"); refresh(); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2000l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2000L); } // closing the 3rd node @@ -127,7 +127,7 @@ public class FullRollingRestartIT extends ESIntegTestCase { logger.info("--> one node left, verifying data"); refresh(); for (int i = 0; i < 10; i++) { - assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2000l); + assertHitCount(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).get(), 2000L); } } diff --git a/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java b/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java index 2d0c5079fd0..fac65cc8dca 100644 --- a/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java +++ b/core/src/test/java/org/elasticsearch/recovery/RelocationIT.java @@ -121,7 +121,7 @@ public class RelocationIT extends ESIntegTestCase { logger.info("--> verifying count"); client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch("test").setSize(0).execute().actionGet().getHits().totalHits(), equalTo(20l)); + assertThat(client().prepareSearch("test").setSize(0).execute().actionGet().getHits().totalHits(), equalTo(20L)); logger.info("--> start another node"); final String node_2 = internalCluster().startNode(); @@ -140,7 +140,7 @@ public class RelocationIT extends ESIntegTestCase { logger.info("--> verifying count again..."); client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch("test").setSize(0).execute().actionGet().getHits().totalHits(), equalTo(20l)); + assertThat(client().prepareSearch("test").setSize(0).execute().actionGet().getHits().totalHits(), equalTo(20L)); } public void testRelocationWhileIndexingRandom() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java b/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java index 1c624f98e2f..9740032ed7e 100644 --- a/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java +++ b/core/src/test/java/org/elasticsearch/rest/CorsRegexIT.java @@ -22,15 +22,14 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.node.Node; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.rest.client.http.HttpResponse; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_CREDENTIALS; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ALLOW_ORIGIN; -import static org.elasticsearch.http.netty.NettyHttpServerTransport.SETTING_CORS_ENABLED; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ALLOW_CREDENTIALS; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ALLOW_ORIGIN; +import static org.elasticsearch.http.HttpTransportSettings.SETTING_CORS_ENABLED; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -47,7 +46,7 @@ public class CorsRegexIT extends ESIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) - .put(SETTING_CORS_ALLOW_ORIGIN, "/https?:\\/\\/localhost(:[0-9]+)?/") + .put(SETTING_CORS_ALLOW_ORIGIN.getKey(), "/https?:\\/\\/localhost(:[0-9]+)?/") .put(SETTING_CORS_ALLOW_CREDENTIALS.getKey(), true) .put(SETTING_CORS_ENABLED.getKey(), true) .put(NetworkModule.HTTP_ENABLED.getKey(), true) diff --git a/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java b/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java index e73f7e510fc..cb880fc4fe0 100644 --- a/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java +++ b/core/src/test/java/org/elasticsearch/routing/AliasResolveRoutingIT.java @@ -54,7 +54,7 @@ public class AliasResolveRoutingIT extends ESIntegTestCase { client().prepareIndex("test-0", "type1", "2").setSource("field1", "quick brown"), client().prepareIndex("test-0", "type1", "3").setSource("field1", "quick")); refresh("test-*"); - assertHitCount(client().prepareSearch().setIndices("alias-*").setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(matchQuery("_all", "quick")).get(), 3l); + assertHitCount(client().prepareSearch().setIndices("alias-*").setIndicesOptions(IndicesOptions.lenientExpandOpen()).setQuery(matchQuery("_all", "quick")).get(), 3L); } public void testResolveIndexRouting() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java b/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java index 9fc6bcfb739..a43b481b2e8 100644 --- a/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java +++ b/core/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java @@ -122,23 +122,23 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search with no routing, should fine one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> search with wrong routing, should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch("alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); + assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch("alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); } logger.info("--> search with correct routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> indexing with id [2], and routing [1] using alias"); @@ -146,50 +146,50 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search with no routing, should fine two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with 0 routing, should find one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> search with 1 routing, should find one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> search with 0,1 routings , should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias01").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias01").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch().setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias01").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias01").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with two routing aliases , should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias0", "alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias0", "alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("alias0", "alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias0", "alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with alias0, alias1 and alias01, should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias0", "alias1", "alias01").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias0", "alias1", "alias01").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("alias0", "alias1", "alias01").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias0", "alias1", "alias01").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with test, alias0 and alias1, should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("test", "alias0", "alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("test", "alias0", "alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("test", "alias0", "alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("test", "alias0", "alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } } @@ -231,20 +231,20 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search with alias-a1,alias-b0, should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias-a1", "alias-b0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch("alias-a1", "alias-b0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); + assertThat(client().prepareSearch("alias-a1", "alias-b0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch("alias-a1", "alias-b0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); } logger.info("--> search with alias-ab, should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias-ab").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias-ab").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("alias-ab").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias-ab").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with alias-a0,alias-b1 should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias-a0", "alias-b1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias-a0", "alias-b1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("alias-a0", "alias-b1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias-a0", "alias-b1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } } @@ -268,7 +268,7 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search all on index_* should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("index_*").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("index_*").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } } @@ -313,8 +313,8 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> verifying get and search with routing, should find"); for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> creating alias with routing [4]"); @@ -323,8 +323,8 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> verifying search with wrong routing should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); + assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); } logger.info("--> creating alias with search routing [3,4] and index routing 4"); @@ -339,8 +339,8 @@ public class AliasRoutingIT extends ESIntegTestCase { for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); assertThat(client().prepareGet("test", "type1", "1").setRouting("4").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } } diff --git a/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index 3bbf7146ae4..a9c51d6ea96 100644 --- a/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -107,19 +107,19 @@ public class SimpleRoutingIT extends ESIntegTestCase { logger.info("--> search with no routing, should fine one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> search with wrong routing, should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0l)); + assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(0L)); } logger.info("--> search with correct routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> indexing with id [2], and routing [1]"); @@ -127,32 +127,32 @@ public class SimpleRoutingIT extends ESIntegTestCase { logger.info("--> search with no routing, should fine two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with 0 routing, should find one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> search with 1 routing, should find one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1l)); + assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); + assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(1L)); } logger.info("--> search with 0,1 routings , should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch().setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } logger.info("--> search with 0,1,0 routings , should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0", "1", "0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); - assertThat(client().prepareSearch().setSize(0).setRouting("0", "1", "0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2l)); + assertThat(client().prepareSearch().setRouting("0", "1", "0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); + assertThat(client().prepareSearch().setSize(0).setRouting("0", "1", "0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(2L)); } } @@ -300,7 +300,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1").setRouting("0") .setDoc("field1", "value1").get(); assertThat(updateResponse.getId(), equalTo("1")); - assertThat(updateResponse.getVersion(), equalTo(2l)); + assertThat(updateResponse.getVersion(), equalTo(2L)); try { client().prepareUpdate(indexOrAlias(), "type1", "1").setDoc("field1", "value1").get(); diff --git a/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java b/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java index 71a41750c9c..8f20d641169 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptFieldIT.java @@ -44,7 +44,7 @@ public class ScriptFieldIT extends ESIntegTestCase { } static int[] intArray = { Integer.MAX_VALUE, Integer.MIN_VALUE, 3 }; - static long[] longArray = { Long.MAX_VALUE, Long.MIN_VALUE, 9223372036854775807l }; + static long[] longArray = { Long.MAX_VALUE, Long.MIN_VALUE, 9223372036854775807L }; static float[] floatArray = { Float.MAX_VALUE, Float.MIN_VALUE, 3.3f }; static double[] doubleArray = { Double.MAX_VALUE, Double.MIN_VALUE, 3.3d }; diff --git a/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java b/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java index c3c80c50850..8cadbb3e95b 100644 --- a/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java +++ b/core/src/test/java/org/elasticsearch/script/ScriptParameterParserTests.java @@ -891,7 +891,7 @@ public class ScriptParameterParserTests extends ESTestCase { public void testConfigMultipleParametersInlineWrongType() throws IOException { Map config = new HashMap<>(); - config.put("foo", 1l); + config.put("foo", 1L); config.put("bar_file", "barScriptValue"); config.put("baz_id", "bazScriptValue"); config.put("lang", "myLang"); @@ -917,7 +917,7 @@ public class ScriptParameterParserTests extends ESTestCase { public void testConfigMultipleParametersFileWrongType() throws IOException { Map config = new HashMap<>(); config.put("foo", "fooScriptValue"); - config.put("bar_file", 1l); + config.put("bar_file", 1L); config.put("baz_id", "bazScriptValue"); config.put("lang", "myLang"); Set parameters = new HashSet<>(); @@ -944,7 +944,7 @@ public class ScriptParameterParserTests extends ESTestCase { Map config = new HashMap<>(); config.put("foo", "fooScriptValue"); config.put("bar_file", "barScriptValue"); - config.put("baz_id", 1l); + config.put("baz_id", 1L); config.put("lang", "myLang"); Set parameters = new HashSet<>(); parameters.add("foo"); @@ -970,7 +970,7 @@ public class ScriptParameterParserTests extends ESTestCase { config.put("foo", "fooScriptValue"); config.put("bar_file", "barScriptValue"); config.put("baz_id", "bazScriptValue"); - config.put("lang", 1l); + config.put("lang", 1L); Set parameters = new HashSet<>(); parameters.add("foo"); parameters.add("bar"); diff --git a/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java b/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java index d3e3de5fda1..63cbdb56fd3 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java +++ b/core/src/test/java/org/elasticsearch/search/SearchWithRejectionsIT.java @@ -50,7 +50,7 @@ public class SearchWithRejectionsIT extends ESIntegTestCase { client().prepareIndex("test", "type", Integer.toString(i)).setSource("field", "value").execute().actionGet(); } IndicesStatsResponse indicesStats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0l)); + assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0L)); refresh(); int numSearches = 10; @@ -71,6 +71,6 @@ public class SearchWithRejectionsIT extends ESIntegTestCase { } awaitBusy(() -> client().admin().indices().prepareStats().execute().actionGet().getTotal().getSearch().getOpenContexts() == 0, 1, TimeUnit.SECONDS); indicesStats = client().admin().indices().prepareStats().execute().actionGet(); - assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0l)); + assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java index 782ac3225f5..a07d0714b69 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/CombiIT.java @@ -131,7 +131,7 @@ public class CombiIT extends ESIntegTestCase { .collectMode(aggCollectionMode ))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), Matchers.equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), Matchers.equalTo(0L)); Histogram values = searchResponse.getAggregations().get("values"); assertThat(values, notNullValue()); assertThat(values.getBuckets().isEmpty(), is(true)); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java index 868ca23c64e..ea8fffd9e6c 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ChildrenIT.java @@ -196,13 +196,13 @@ children("to_comment", "comment") Terms.Bucket categoryBucket = categoryTerms.getBucketByKey("a"); assertThat(categoryBucket.getKeyAsString(), equalTo("a")); - assertThat(categoryBucket.getDocCount(), equalTo(3l)); + assertThat(categoryBucket.getDocCount(), equalTo(3L)); Children childrenBucket = categoryBucket.getAggregations().get("to_comment"); assertThat(childrenBucket.getName(), equalTo("to_comment")); - assertThat(childrenBucket.getDocCount(), equalTo(2l)); + assertThat(childrenBucket.getDocCount(), equalTo(2L)); TopHits topHits = childrenBucket.getAggregations().get("top_comments"); - assertThat(topHits.getHits().totalHits(), equalTo(2l)); + assertThat(topHits.getHits().totalHits(), equalTo(2L)); assertThat(topHits.getHits().getAt(0).getId(), equalTo("a")); assertThat(topHits.getHits().getAt(0).getType(), equalTo("comment")); assertThat(topHits.getHits().getAt(1).getId(), equalTo("c")); @@ -210,25 +210,25 @@ children("to_comment", "comment") categoryBucket = categoryTerms.getBucketByKey("b"); assertThat(categoryBucket.getKeyAsString(), equalTo("b")); - assertThat(categoryBucket.getDocCount(), equalTo(2l)); + assertThat(categoryBucket.getDocCount(), equalTo(2L)); childrenBucket = categoryBucket.getAggregations().get("to_comment"); assertThat(childrenBucket.getName(), equalTo("to_comment")); - assertThat(childrenBucket.getDocCount(), equalTo(1l)); + assertThat(childrenBucket.getDocCount(), equalTo(1L)); topHits = childrenBucket.getAggregations().get("top_comments"); - assertThat(topHits.getHits().totalHits(), equalTo(1l)); + assertThat(topHits.getHits().totalHits(), equalTo(1L)); assertThat(topHits.getHits().getAt(0).getId(), equalTo("c")); assertThat(topHits.getHits().getAt(0).getType(), equalTo("comment")); categoryBucket = categoryTerms.getBucketByKey("c"); assertThat(categoryBucket.getKeyAsString(), equalTo("c")); - assertThat(categoryBucket.getDocCount(), equalTo(2l)); + assertThat(categoryBucket.getDocCount(), equalTo(2L)); childrenBucket = categoryBucket.getAggregations().get("to_comment"); assertThat(childrenBucket.getName(), equalTo("to_comment")); - assertThat(childrenBucket.getDocCount(), equalTo(1l)); + assertThat(childrenBucket.getDocCount(), equalTo(1L)); topHits = childrenBucket.getAggregations().get("top_comments"); - assertThat(topHits.getHits().totalHits(), equalTo(1l)); + assertThat(topHits.getHits().totalHits(), equalTo(1L)); assertThat(topHits.getHits().getAt(0).getId(), equalTo("c")); assertThat(topHits.getHits().getAt(0).getType(), equalTo("comment")); } @@ -256,7 +256,7 @@ children("to_comment", "comment") assertNoFailures(searchResponse); Children children = searchResponse.getAggregations().get("children"); - assertThat(children.getDocCount(), equalTo(4l)); + assertThat(children.getDocCount(), equalTo(4L)); Sum count = children.getAggregations().get("counts"); assertThat(count.getValue(), equalTo(4.)); @@ -272,7 +272,7 @@ children("to_comment", "comment") .setDoc("count", 1) .setDetectNoop(false) .get(); - assertThat(updateResponse.getVersion(), greaterThan(1l)); + assertThat(updateResponse.getVersion(), greaterThan(1L)); refresh(); } } @@ -286,7 +286,7 @@ children("non-existing", "xyz") Children children = searchResponse.getAggregations().get("non-existing"); assertThat(children.getName(), equalTo("non-existing")); - assertThat(children.getDocCount(), equalTo(0l)); + assertThat(children.getDocCount(), equalTo(0L)); } public void testPostCollection() throws Exception { @@ -328,23 +328,23 @@ children("non-existing", "xyz") assertHitCount(response, 1); Children childrenAgg = response.getAggregations().get("my-refinements"); - assertThat(childrenAgg.getDocCount(), equalTo(7l)); + assertThat(childrenAgg.getDocCount(), equalTo(7L)); Terms termsAgg = childrenAgg.getAggregations().get("my-colors"); assertThat(termsAgg.getBuckets().size(), equalTo(4)); - assertThat(termsAgg.getBucketByKey("black").getDocCount(), equalTo(3l)); - assertThat(termsAgg.getBucketByKey("blue").getDocCount(), equalTo(2l)); - assertThat(termsAgg.getBucketByKey("green").getDocCount(), equalTo(1l)); - assertThat(termsAgg.getBucketByKey("orange").getDocCount(), equalTo(1l)); + assertThat(termsAgg.getBucketByKey("black").getDocCount(), equalTo(3L)); + assertThat(termsAgg.getBucketByKey("blue").getDocCount(), equalTo(2L)); + assertThat(termsAgg.getBucketByKey("green").getDocCount(), equalTo(1L)); + assertThat(termsAgg.getBucketByKey("orange").getDocCount(), equalTo(1L)); termsAgg = childrenAgg.getAggregations().get("my-sizes"); assertThat(termsAgg.getBuckets().size(), equalTo(6)); - assertThat(termsAgg.getBucketByKey("36").getDocCount(), equalTo(2l)); - assertThat(termsAgg.getBucketByKey("32").getDocCount(), equalTo(1l)); - assertThat(termsAgg.getBucketByKey("34").getDocCount(), equalTo(1l)); - assertThat(termsAgg.getBucketByKey("38").getDocCount(), equalTo(1l)); - assertThat(termsAgg.getBucketByKey("40").getDocCount(), equalTo(1l)); - assertThat(termsAgg.getBucketByKey("44").getDocCount(), equalTo(1l)); + assertThat(termsAgg.getBucketByKey("36").getDocCount(), equalTo(2L)); + assertThat(termsAgg.getBucketByKey("32").getDocCount(), equalTo(1L)); + assertThat(termsAgg.getBucketByKey("34").getDocCount(), equalTo(1L)); + assertThat(termsAgg.getBucketByKey("38").getDocCount(), equalTo(1L)); + assertThat(termsAgg.getBucketByKey("40").getDocCount(), equalTo(1L)); + assertThat(termsAgg.getBucketByKey("44").getDocCount(), equalTo(1L)); } public void testHierarchicalChildrenAggs() { @@ -382,14 +382,14 @@ children("non-existing", "xyz") Children children = response.getAggregations().get(parentType); assertThat(children.getName(), equalTo(parentType)); - assertThat(children.getDocCount(), equalTo(1l)); + assertThat(children.getDocCount(), equalTo(1L)); children = children.getAggregations().get(childType); assertThat(children.getName(), equalTo(childType)); - assertThat(children.getDocCount(), equalTo(1l)); + assertThat(children.getDocCount(), equalTo(1L)); Terms terms = children.getAggregations().get("name"); assertThat(terms.getBuckets().size(), equalTo(1)); assertThat(terms.getBuckets().get(0).getKey().toString(), equalTo("brussels")); - assertThat(terms.getBuckets().get(0).getDocCount(), equalTo(1l)); + assertThat(terms.getBuckets().get(0).getDocCount(), equalTo(1L)); } public void testPostCollectAllLeafReaders() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java index 58084337d4c..deb163895dc 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramIT.java @@ -179,21 +179,21 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } public void testSingleValuedFieldWithTimeZone() throws Exception { @@ -214,42 +214,42 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 1, 23, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 14, 23, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 3, 1, 23, 0, DateTimeZone.UTC); bucket = buckets.get(3); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 3, 14, 23, 0, DateTimeZone.UTC); bucket = buckets.get(4); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 3, 22, 23, 0, DateTimeZone.UTC); bucket = buckets.get(5); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } public void testSingleValuedFieldOrderedByKeyAsc() throws Exception { @@ -363,12 +363,12 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo(1.0)); assertThat((DateTime) propertiesKeys[0], equalTo(key)); - assertThat((long) propertiesDocCounts[0], equalTo(1l)); + assertThat((long) propertiesDocCounts[0], equalTo(1L)); assertThat((double) propertiesCounts[0], equalTo(1.0)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); @@ -376,12 +376,12 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo(5.0)); assertThat((DateTime) propertiesKeys[1], equalTo(key)); - assertThat((long) propertiesDocCounts[1], equalTo(2l)); + assertThat((long) propertiesDocCounts[1], equalTo(2L)); assertThat((double) propertiesCounts[1], equalTo(5.0)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); @@ -389,12 +389,12 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo(15.0)); assertThat((DateTime) propertiesKeys[2], equalTo(key)); - assertThat((long) propertiesDocCounts[2], equalTo(3l)); + assertThat((long) propertiesDocCounts[2], equalTo(3L)); assertThat((double) propertiesCounts[2], equalTo(15.0)); } @@ -417,7 +417,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) new DateTime(2012, 1, 2, 0, 0, DateTimeZone.UTC).getMillis())); @@ -427,7 +427,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) new DateTime(2012, 2, 15, 0, 0, DateTimeZone.UTC).getMillis())); @@ -437,7 +437,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) new DateTime(2012, 3, 23, 0, 0, DateTimeZone.UTC).getMillis())); @@ -556,21 +556,21 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); key = new DateTime(2012, 4, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } /* @@ -600,28 +600,28 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); key = new DateTime(2012, 4, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(3); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } public void testMultiValuedFieldOrderedByKeyDesc() throws Exception { @@ -644,19 +644,19 @@ public class DateHistogramIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(3); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } /** @@ -689,28 +689,28 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); key = new DateTime(2012, 4, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); key = new DateTime(2012, 5, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(3); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } /** @@ -743,7 +743,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 3, 3, 0, 0, DateTimeZone.UTC).getMillis())); @@ -753,7 +753,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 4, 16, 0, 0, DateTimeZone.UTC).getMillis())); @@ -763,7 +763,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 5, 24, 0, 0, DateTimeZone.UTC).getMillis())); @@ -773,7 +773,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 5, 24, 0, 0, DateTimeZone.UTC).getMillis())); @@ -805,21 +805,21 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } public void testScriptSingleValueWithSubAggregatorInherited() throws Exception { @@ -841,7 +841,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) new DateTime(2012, 1, 2, 0, 0, DateTimeZone.UTC).getMillis())); @@ -851,7 +851,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) new DateTime(2012, 2, 15, 0, 0, DateTimeZone.UTC).getMillis())); @@ -861,7 +861,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) new DateTime(2012, 3, 23, 0, 0, DateTimeZone.UTC).getMillis())); @@ -885,28 +885,28 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); key = new DateTime(2012, 4, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(3); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } @@ -939,7 +939,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 2, 3, 0, 0, DateTimeZone.UTC).getMillis())); @@ -949,7 +949,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 3, 16, 0, 0, DateTimeZone.UTC).getMillis())); @@ -959,7 +959,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 4, 24, 0, 0, DateTimeZone.UTC).getMillis())); @@ -969,7 +969,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat((long) max.getValue(), equalTo(new DateTime(2012, 4, 24, 0, 0, DateTimeZone.UTC).getMillis())); @@ -1006,30 +1006,30 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(dateHistogram("date_histo").interval(1))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(dateHistogram("date_histo").interval(1))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); List buckets = histo.getBuckets(); @@ -1065,7 +1065,7 @@ public class DateHistogramIT extends ESIntegTestCase { .format("yyyy-MM-dd:HH-mm-ssZZ")) .execute().actionGet(); - assertThat(response.getHits().getTotalHits(), equalTo(5l)); + assertThat(response.getHits().getTotalHits(), equalTo(5L)); Histogram histo = response.getAggregations().get("date_histo"); List buckets = histo.getBuckets(); @@ -1074,12 +1074,12 @@ public class DateHistogramIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo("2014-03-10:00-00-00-02:00")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo("2014-03-11:00-00-00-02:00")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } public void testSingleValueFieldWithExtendedBounds() throws Exception { @@ -1235,7 +1235,7 @@ public class DateHistogramIT extends ESIntegTestCase { ).execute().actionGet(); assertSearchResponse(response); - assertThat("Expected 24 buckets for one day aggregation with hourly interval", response.getHits().totalHits(), equalTo(2l)); + assertThat("Expected 24 buckets for one day aggregation with hourly interval", response.getHits().totalHits(), equalTo(2L)); Histogram histo = response.getAggregations().get("histo"); assertThat(histo, notNullValue()); @@ -1248,9 +1248,9 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat("InternalBucket " + i + " had wrong key", (DateTime) bucket.getKey(), equalTo(new DateTime(timeZoneStartToday.getMillis() + (i * 60 * 60 * 1000), DateTimeZone.UTC))); if (i == 0 || i == 12) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } } internalCluster().wipeIndices("test12278"); @@ -1283,7 +1283,7 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); } public void testIssue6965() { @@ -1306,21 +1306,21 @@ public class DateHistogramIT extends ESIntegTestCase { assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); key = new DateTime(2012, 1, 31, 23, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); key = new DateTime(2012, 2, 29, 23, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat(bucket.getKeyAsString(), equalTo(getBucketKeyAsString(key, tz))); assertThat(((DateTime) bucket.getKey()), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); } public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionException { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java index 1aa747d58fe..b0257690df0 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramOffsetIT.java @@ -95,14 +95,14 @@ public class DateHistogramOffsetIT extends ESIntegTestCase { .dateHistogramInterval(DateHistogramInterval.DAY)) .execute().actionGet(); - assertThat(response.getHits().getTotalHits(), equalTo(5l)); + assertThat(response.getHits().getTotalHits(), equalTo(5L)); Histogram histo = response.getAggregations().get("date_histo"); List buckets = histo.getBuckets(); assertThat(buckets.size(), equalTo(2)); - checkBucketFor(buckets.get(0), new DateTime(2014, 3, 10, 2, 0, DateTimeZone.UTC), 2l); - checkBucketFor(buckets.get(1), new DateTime(2014, 3, 11, 2, 0, DateTimeZone.UTC), 3l); + checkBucketFor(buckets.get(0), new DateTime(2014, 3, 10, 2, 0, DateTimeZone.UTC), 2L); + checkBucketFor(buckets.get(1), new DateTime(2014, 3, 11, 2, 0, DateTimeZone.UTC), 3L); } public void testSingleValueWithNegativeOffset() throws Exception { @@ -117,14 +117,14 @@ public class DateHistogramOffsetIT extends ESIntegTestCase { .dateHistogramInterval(DateHistogramInterval.DAY)) .execute().actionGet(); - assertThat(response.getHits().getTotalHits(), equalTo(5l)); + assertThat(response.getHits().getTotalHits(), equalTo(5L)); Histogram histo = response.getAggregations().get("date_histo"); List buckets = histo.getBuckets(); assertThat(buckets.size(), equalTo(2)); - checkBucketFor(buckets.get(0), new DateTime(2014, 3, 9, 22, 0, DateTimeZone.UTC), 2l); - checkBucketFor(buckets.get(1), new DateTime(2014, 3, 10, 22, 0, DateTimeZone.UTC), 3l); + checkBucketFor(buckets.get(0), new DateTime(2014, 3, 9, 22, 0, DateTimeZone.UTC), 2L); + checkBucketFor(buckets.get(1), new DateTime(2014, 3, 10, 22, 0, DateTimeZone.UTC), 3L); } /** @@ -144,7 +144,7 @@ public class DateHistogramOffsetIT extends ESIntegTestCase { .dateHistogramInterval(DateHistogramInterval.DAY)) .execute().actionGet(); - assertThat(response.getHits().getTotalHits(), equalTo(24l)); + assertThat(response.getHits().getTotalHits(), equalTo(24L)); Histogram histo = response.getAggregations().get("date_histo"); List buckets = histo.getBuckets(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java index be3dd83dd22..9a4b5ecc4c9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterIT.java @@ -182,11 +182,11 @@ public class FilterIT extends ESIntegTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(filter("filter", matchAllQuery()))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -195,6 +195,6 @@ public class FilterIT extends ESIntegTestCase { Filter filter = bucket.getAggregations().get("filter"); assertThat(filter, Matchers.notNullValue()); assertThat(filter.getName(), equalTo("filter")); - assertThat(filter.getDocCount(), is(0l)); + assertThat(filter.getDocCount(), is(0L)); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java index c84c5f5860e..bf252010705 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/FiltersIT.java @@ -243,11 +243,11 @@ public class FiltersIT extends ESIntegTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(filters("filters", new KeyedFilter("all", matchAllQuery())))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -258,7 +258,7 @@ public class FiltersIT extends ESIntegTestCase { Filters.Bucket all = filters.getBucketByKey("all"); assertThat(all, Matchers.notNullValue()); assertThat(all.getKeyAsString(), equalTo("all")); - assertThat(all.getDocCount(), is(0l)); + assertThat(all.getDocCount(), is(0L)); } public void testSimpleNonKeyed() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java index f6ebbbc4dc7..80211eba973 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java @@ -165,7 +165,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0)); assertThat(bucket.getFromAsString(), equalTo("0.0")); assertThat(bucket.getToAsString(), equalTo("500.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -174,7 +174,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0)); assertThat(bucket.getFromAsString(), equalTo("500.0")); assertThat(bucket.getToAsString(), equalTo("1000.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -183,7 +183,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } public void testSimpleWithCustomKeys() throws Exception { @@ -212,7 +212,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0)); assertThat(bucket.getFromAsString(), equalTo("0.0")); assertThat(bucket.getToAsString(), equalTo("500.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -221,7 +221,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0)); assertThat(bucket.getFromAsString(), equalTo("500.0")); assertThat(bucket.getToAsString(), equalTo("1000.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -230,7 +230,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } public void testUnmapped() throws Exception { @@ -261,7 +261,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0)); assertThat(bucket.getFromAsString(), equalTo("0.0")); assertThat(bucket.getToAsString(), equalTo("500.0")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -270,7 +270,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0)); assertThat(bucket.getFromAsString(), equalTo("500.0")); assertThat(bucket.getToAsString(), equalTo("1000.0")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -279,7 +279,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } public void testPartiallyUnmapped() throws Exception { @@ -308,7 +308,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0)); assertThat(bucket.getFromAsString(), equalTo("0.0")); assertThat(bucket.getToAsString(), equalTo("500.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -317,7 +317,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0)); assertThat(bucket.getFromAsString(), equalTo("500.0")); assertThat(bucket.getToAsString(), equalTo("1000.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -326,7 +326,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } public void testWithSubAggregation() throws Exception { @@ -360,7 +360,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0)); assertThat(bucket.getFromAsString(), equalTo("0.0")); assertThat(bucket.getToAsString(), equalTo("500.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); Terms cities = bucket.getAggregations().get("cities"); assertThat(cities, Matchers.notNullValue()); @@ -370,7 +370,7 @@ public class GeoDistanceIT extends ESIntegTestCase { } assertThat(names.contains("utrecht") && names.contains("haarlem"), is(true)); assertThat((String) propertiesKeys[0], equalTo("*-500.0")); - assertThat((long) propertiesDocCounts[0], equalTo(2l)); + assertThat((long) propertiesDocCounts[0], equalTo(2L)); assertThat((Terms) propertiesCities[0], sameInstance(cities)); bucket = buckets.get(1); @@ -380,7 +380,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0)); assertThat(bucket.getFromAsString(), equalTo("500.0")); assertThat(bucket.getToAsString(), equalTo("1000.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); cities = bucket.getAggregations().get("cities"); assertThat(cities, Matchers.notNullValue()); @@ -390,7 +390,7 @@ public class GeoDistanceIT extends ESIntegTestCase { } assertThat(names.contains("berlin") && names.contains("prague"), is(true)); assertThat((String) propertiesKeys[1], equalTo("500.0-1000.0")); - assertThat((long) propertiesDocCounts[1], equalTo(2l)); + assertThat((long) propertiesDocCounts[1], equalTo(2L)); assertThat((Terms) propertiesCities[1], sameInstance(cities)); bucket = buckets.get(2); @@ -400,7 +400,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); cities = bucket.getAggregations().get("cities"); assertThat(cities, Matchers.notNullValue()); @@ -410,18 +410,18 @@ public class GeoDistanceIT extends ESIntegTestCase { } assertThat(names.contains("tel-aviv"), is(true)); assertThat((String) propertiesKeys[2], equalTo("1000.0-*")); - assertThat((long) propertiesDocCounts[2], equalTo(1l)); + assertThat((long) propertiesDocCounts[2], equalTo(1L)); assertThat((Terms) propertiesCities[2], sameInstance(cities)); } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(geoDistance("geo_dist", new GeoPoint(52.3760, 4.894)).field("location").addRange("0-100", 0.0, 100.0))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -438,7 +438,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) buckets.get(0).getTo()).doubleValue(), equalTo(100.0)); assertThat(buckets.get(0).getFromAsString(), equalTo("0.0")); assertThat(buckets.get(0).getToAsString(), equalTo("100.0")); - assertThat(buckets.get(0).getDocCount(), equalTo(0l)); + assertThat(buckets.get(0).getDocCount(), equalTo(0L)); } public void testMultiValues() throws Exception { @@ -467,7 +467,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(500.0)); assertThat(bucket.getFromAsString(), equalTo("0.0")); assertThat(bucket.getToAsString(), equalTo("500.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -476,7 +476,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(1000.0)); assertThat(bucket.getFromAsString(), equalTo("500.0")); assertThat(bucket.getToAsString(), equalTo("1000.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -485,7 +485,7 @@ public class GeoDistanceIT extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java index 924ba7283f8..85e0c58eda6 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingIT.java @@ -184,11 +184,11 @@ public class MissingIT extends ESIntegTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(missing("missing"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -197,7 +197,7 @@ public class MissingIT extends ESIntegTestCase { Missing missing = bucket.getAggregations().get("missing"); assertThat(missing, Matchers.notNullValue()); assertThat(missing.getName(), equalTo("missing")); - assertThat(missing.getDocCount(), is(0l)); + assertThat(missing.getDocCount(), is(0L)); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java index 12d6b85ad9a..cd68fabda4c 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedIT.java @@ -212,7 +212,7 @@ public class NestedIT extends ESIntegTestCase { Nested nested = searchResponse.getAggregations().get("nested"); assertThat(nested, Matchers.notNullValue()); assertThat(nested.getName(), equalTo("nested")); - assertThat(nested.getDocCount(), is(0l)); + assertThat(nested.getDocCount(), is(0L)); } public void testNestedWithSubTermsAgg() throws Exception { @@ -308,23 +308,23 @@ public class NestedIT extends ESIntegTestCase { Nested level1 = response.getAggregations().get("level1"); assertThat(level1, notNullValue()); assertThat(level1.getName(), equalTo("level1")); - assertThat(level1.getDocCount(), equalTo(2l)); + assertThat(level1.getDocCount(), equalTo(2L)); StringTerms a = level1.getAggregations().get("a"); Terms.Bucket bBucket = a.getBucketByKey("a"); - assertThat(bBucket.getDocCount(), equalTo(1l)); + assertThat(bBucket.getDocCount(), equalTo(1L)); Nested level2 = bBucket.getAggregations().get("level2"); - assertThat(level2.getDocCount(), equalTo(1l)); + assertThat(level2.getDocCount(), equalTo(1L)); Sum sum = level2.getAggregations().get("sum"); assertThat(sum.getValue(), equalTo(2d)); a = level1.getAggregations().get("a"); bBucket = a.getBucketByKey("b"); - assertThat(bBucket.getDocCount(), equalTo(1l)); + assertThat(bBucket.getDocCount(), equalTo(1L)); level2 = bBucket.getAggregations().get("level2"); - assertThat(level2.getDocCount(), equalTo(1l)); + assertThat(level2.getDocCount(), equalTo(1L)); sum = level2.getAggregations().get("sum"); assertThat(sum.getValue(), equalTo(2d)); } @@ -332,11 +332,11 @@ public class NestedIT extends ESIntegTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(nested("nested", "nested"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -345,7 +345,7 @@ public class NestedIT extends ESIntegTestCase { Nested nested = bucket.getAggregations().get("nested"); assertThat(nested, Matchers.notNullValue()); assertThat(nested.getName(), equalTo("nested")); - assertThat(nested.getDocCount(), is(0l)); + assertThat(nested.getDocCount(), is(0L)); } public void testNestedOnObjectField() throws Exception { @@ -425,36 +425,36 @@ public class NestedIT extends ESIntegTestCase { Terms startDate = response.getAggregations().get("startDate"); assertThat(startDate.getBuckets().size(), equalTo(2)); Terms.Bucket bucket = startDate.getBucketByKey("2014-11-01T00:00:00.000Z"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Terms endDate = bucket.getAggregations().get("endDate"); bucket = endDate.getBucketByKey("2014-11-30T00:00:00.000Z"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Terms period = bucket.getAggregations().get("period"); bucket = period.getBucketByKey("2014-11"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Nested comments = bucket.getAggregations().get("ctxt_idfier_nested"); - assertThat(comments.getDocCount(), equalTo(2l)); + assertThat(comments.getDocCount(), equalTo(2L)); Filter filter = comments.getAggregations().get("comment_filter"); - assertThat(filter.getDocCount(), equalTo(1l)); + assertThat(filter.getDocCount(), equalTo(1L)); Nested nestedTags = filter.getAggregations().get("nested_tags"); - assertThat(nestedTags.getDocCount(), equalTo(0l)); // This must be 0 + assertThat(nestedTags.getDocCount(), equalTo(0L)); // This must be 0 Terms tags = nestedTags.getAggregations().get("tag"); assertThat(tags.getBuckets().size(), equalTo(0)); // and this must be empty bucket = startDate.getBucketByKey("2014-12-01T00:00:00.000Z"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); endDate = bucket.getAggregations().get("endDate"); bucket = endDate.getBucketByKey("2014-12-31T00:00:00.000Z"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); period = bucket.getAggregations().get("period"); bucket = period.getBucketByKey("2014-12"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); comments = bucket.getAggregations().get("ctxt_idfier_nested"); - assertThat(comments.getDocCount(), equalTo(2l)); + assertThat(comments.getDocCount(), equalTo(2L)); filter = comments.getAggregations().get("comment_filter"); - assertThat(filter.getDocCount(), equalTo(1l)); + assertThat(filter.getDocCount(), equalTo(1L)); nestedTags = filter.getAggregations().get("nested_tags"); - assertThat(nestedTags.getDocCount(), equalTo(0l)); // This must be 0 + assertThat(nestedTags.getDocCount(), equalTo(0L)); // This must be 0 tags = nestedTags.getAggregations().get("tag"); assertThat(tags.getBuckets().size(), equalTo(0)); // and this must be empty } @@ -501,47 +501,47 @@ public class NestedIT extends ESIntegTestCase { assertThat(category.getBuckets().size(), equalTo(4)); Terms.Bucket bucket = category.getBucketByKey("1"); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Nested property = bucket.getAggregations().get("property"); - assertThat(property.getDocCount(), equalTo(6l)); + assertThat(property.getDocCount(), equalTo(6L)); Terms propertyId = property.getAggregations().get("property_id"); assertThat(propertyId.getBuckets().size(), equalTo(5)); - assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(2l)); - assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("4").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("5").getDocCount(), equalTo(1l)); + assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(2L)); + assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("4").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("5").getDocCount(), equalTo(1L)); bucket = category.getBucketByKey("2"); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); property = bucket.getAggregations().get("property"); - assertThat(property.getDocCount(), equalTo(6l)); + assertThat(property.getDocCount(), equalTo(6L)); propertyId = property.getAggregations().get("property_id"); assertThat(propertyId.getBuckets().size(), equalTo(5)); - assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(2l)); - assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("4").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("5").getDocCount(), equalTo(1l)); + assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(2L)); + assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("4").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("5").getDocCount(), equalTo(1L)); bucket = category.getBucketByKey("3"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); property = bucket.getAggregations().get("property"); - assertThat(property.getDocCount(), equalTo(3l)); + assertThat(property.getDocCount(), equalTo(3L)); propertyId = property.getAggregations().get("property_id"); assertThat(propertyId.getBuckets().size(), equalTo(3)); - assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1l)); + assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1L)); bucket = category.getBucketByKey("4"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); property = bucket.getAggregations().get("property"); - assertThat(property.getDocCount(), equalTo(3l)); + assertThat(property.getDocCount(), equalTo(3L)); propertyId = property.getAggregations().get("property_id"); assertThat(propertyId.getBuckets().size(), equalTo(3)); - assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1l)); - assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1l)); + assertThat(propertyId.getBucketByKey("1").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("2").getDocCount(), equalTo(1L)); + assertThat(propertyId.getBucketByKey("3").getDocCount(), equalTo(1L)); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java index bff5e7d0fc5..0c01825d7e5 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ParentIdAggIT.java @@ -48,10 +48,10 @@ public class ParentIdAggIT extends ESIntegTestCase { refresh(); ensureGreen("testidx"); SearchResponse searchResponse = client().prepareSearch("testidx").setTypes("childtype").setQuery(matchAllQuery()).addAggregation(AggregationBuilders.terms("children").field("_parent#parenttype")).get(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); assertSearchResponse(searchResponse); assertThat(searchResponse.getAggregations().getAsMap().get("children"), instanceOf(Terms.class)); Terms terms = (Terms) searchResponse.getAggregations().getAsMap().get("children"); - assertThat(terms.getBuckets().iterator().next().getDocCount(), equalTo(2l)); + assertThat(terms.getBuckets().iterator().next().getDocCount(), equalTo(2L)); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java index 438f9b49568..5f38f1ba5a6 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java @@ -156,7 +156,7 @@ public class ReverseNestedIT extends ESIntegTestCase { Nested nested = response.getAggregations().get("nested1"); assertThat(nested, notNullValue()); assertThat(nested.getName(), equalTo("nested1")); - assertThat(nested.getDocCount(), equalTo(25l)); + assertThat(nested.getDocCount(), equalTo(25L)); assertThat(nested.getAggregations().asList().isEmpty(), is(false)); Terms usernames = nested.getAggregations().get("field2"); @@ -167,161 +167,161 @@ public class ReverseNestedIT extends ESIntegTestCase { // nested.field2: 1 Terms.Bucket bucket = usernameBuckets.get(0); assertThat(bucket.getKeyAsString(), equalTo("1")); - assertThat(bucket.getDocCount(), equalTo(6l)); + assertThat(bucket.getDocCount(), equalTo(6L)); ReverseNested reverseNested = bucket.getAggregations().get("nested1_to_field1"); - assertThat((long) reverseNested.getProperty("_count"), equalTo(5l)); + assertThat((long) reverseNested.getProperty("_count"), equalTo(5L)); Terms tags = reverseNested.getAggregations().get("field1"); assertThat((Terms) reverseNested.getProperty("field1"), sameInstance(tags)); List tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(6)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(4l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(4L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(3l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(3L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(4).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(4).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(4).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(5).getKeyAsString(), equalTo("x")); - assertThat(tagsBuckets.get(5).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(5).getDocCount(), equalTo(1L)); // nested.field2: 4 bucket = usernameBuckets.get(1); assertThat(bucket.getKeyAsString(), equalTo("4")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(5)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(3l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(3L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(4).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(4).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(4).getDocCount(), equalTo(1L)); // nested.field2: 7 bucket = usernameBuckets.get(2); assertThat(bucket.getKeyAsString(), equalTo("7")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(5)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(4).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(4).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(4).getDocCount(), equalTo(1L)); // nested.field2: 2 bucket = usernameBuckets.get(3); assertThat(bucket.getKeyAsString(), equalTo("2")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(3)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); // nested.field2: 3 bucket = usernameBuckets.get(4); assertThat(bucket.getKeyAsString(), equalTo("3")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(3)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); // nested.field2: 5 bucket = usernameBuckets.get(5); assertThat(bucket.getKeyAsString(), equalTo("5")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(4)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("z")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); // nested.field2: 6 bucket = usernameBuckets.get(6); assertThat(bucket.getKeyAsString(), equalTo("6")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(4)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("y")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); // nested.field2: 8 bucket = usernameBuckets.get(7); assertThat(bucket.getKeyAsString(), equalTo("8")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(4)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(2L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("x")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); // nested.field2: 9 bucket = usernameBuckets.get(8); assertThat(bucket.getKeyAsString(), equalTo("9")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(4)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("z")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); } public void testSimpleNested1ToRootToNested2() throws Exception { @@ -337,13 +337,13 @@ public class ReverseNestedIT extends ESIntegTestCase { assertSearchResponse(response); Nested nested = response.getAggregations().get("nested1"); assertThat(nested.getName(), equalTo("nested1")); - assertThat(nested.getDocCount(), equalTo(9l)); + assertThat(nested.getDocCount(), equalTo(9L)); ReverseNested reverseNested = nested.getAggregations().get("nested1_to_root"); assertThat(reverseNested.getName(), equalTo("nested1_to_root")); - assertThat(reverseNested.getDocCount(), equalTo(4l)); + assertThat(reverseNested.getDocCount(), equalTo(4L)); nested = reverseNested.getAggregations().get("root_to_nested2"); assertThat(nested.getName(), equalTo("root_to_nested2")); - assertThat(nested.getDocCount(), equalTo(27l)); + assertThat(nested.getDocCount(), equalTo(27L)); } public void testSimpleReverseNestedToNested1() throws Exception { @@ -368,7 +368,7 @@ public class ReverseNestedIT extends ESIntegTestCase { Nested nested = response.getAggregations().get("nested1"); assertThat(nested, notNullValue()); assertThat(nested.getName(), equalTo("nested1")); - assertThat(nested.getDocCount(), equalTo(27l)); + assertThat(nested.getDocCount(), equalTo(27L)); assertThat(nested.getAggregations().asList().isEmpty(), is(false)); Terms usernames = nested.getAggregations().get("field2"); @@ -378,73 +378,73 @@ public class ReverseNestedIT extends ESIntegTestCase { Terms.Bucket bucket = usernameBuckets.get(0); assertThat(bucket.getKeyAsString(), equalTo("0")); - assertThat(bucket.getDocCount(), equalTo(12l)); + assertThat(bucket.getDocCount(), equalTo(12L)); ReverseNested reverseNested = bucket.getAggregations().get("nested1_to_field1"); - assertThat(reverseNested.getDocCount(), equalTo(5l)); + assertThat(reverseNested.getDocCount(), equalTo(5L)); Terms tags = reverseNested.getAggregations().get("field1"); List tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(2)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(3l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(3L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(2L)); bucket = usernameBuckets.get(1); assertThat(bucket.getKeyAsString(), equalTo("1")); - assertThat(bucket.getDocCount(), equalTo(6l)); + assertThat(bucket.getDocCount(), equalTo(6L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); - assertThat(reverseNested.getDocCount(), equalTo(4l)); + assertThat(reverseNested.getDocCount(), equalTo(4L)); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(4)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); bucket = usernameBuckets.get(2); assertThat(bucket.getKeyAsString(), equalTo("2")); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); - assertThat(reverseNested.getDocCount(), equalTo(4l)); + assertThat(reverseNested.getDocCount(), equalTo(4L)); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(4)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("a")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("b")); - assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(1).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(2).getKeyAsString(), equalTo("c")); - assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(2).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(3).getKeyAsString(), equalTo("e")); - assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(3).getDocCount(), equalTo(1L)); bucket = usernameBuckets.get(3); assertThat(bucket.getKeyAsString(), equalTo("3")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); - assertThat(reverseNested.getDocCount(), equalTo(2l)); + assertThat(reverseNested.getDocCount(), equalTo(2L)); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(2)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("f")); bucket = usernameBuckets.get(4); assertThat(bucket.getKeyAsString(), equalTo("4")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); reverseNested = bucket.getAggregations().get("nested1_to_field1"); - assertThat(reverseNested.getDocCount(), equalTo(2l)); + assertThat(reverseNested.getDocCount(), equalTo(2L)); tags = reverseNested.getAggregations().get("field1"); tagsBuckets = new ArrayList<>(tags.getBuckets()); assertThat(tagsBuckets.size(), equalTo(2)); assertThat(tagsBuckets.get(0).getKeyAsString(), equalTo("d")); - assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1l)); + assertThat(tagsBuckets.get(0).getDocCount(), equalTo(1L)); assertThat(tagsBuckets.get(1).getKeyAsString(), equalTo("f")); } @@ -478,7 +478,7 @@ public class ReverseNestedIT extends ESIntegTestCase { assertThat(nested.getName(), equalTo("nested2")); ReverseNested reverseNested = nested.getAggregations().get("incorrect"); - assertThat(reverseNested.getDocCount(), is(0l)); + assertThat(reverseNested.getDocCount(), is(0L)); } public void testSameParentDocHavingMultipleBuckets() throws Exception { @@ -574,21 +574,21 @@ public class ReverseNestedIT extends ESIntegTestCase { assertHitCount(response, 1); Nested nested0 = response.getAggregations().get("nested_0"); - assertThat(nested0.getDocCount(), equalTo(3l)); + assertThat(nested0.getDocCount(), equalTo(3L)); Terms terms = nested0.getAggregations().get("group_by_category"); assertThat(terms.getBuckets().size(), equalTo(3)); for (String bucketName : new String[]{"abc", "klm", "xyz"}) { logger.info("Checking results for bucket {}", bucketName); Terms.Bucket bucket = terms.getBucketByKey(bucketName); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ReverseNested toRoot = bucket.getAggregations().get("to_root"); - assertThat(toRoot.getDocCount(), equalTo(1l)); + assertThat(toRoot.getDocCount(), equalTo(1L)); Nested nested1 = toRoot.getAggregations().get("nested_1"); - assertThat(nested1.getDocCount(), equalTo(5l)); + assertThat(nested1.getDocCount(), equalTo(5L)); Filter filterByBar = nested1.getAggregations().get("filter_by_sku"); - assertThat(filterByBar.getDocCount(), equalTo(3l)); + assertThat(filterByBar.getDocCount(), equalTo(3L)); ValueCount barCount = filterByBar.getAggregations().get("sku_count"); - assertThat(barCount.getValue(), equalTo(3l)); + assertThat(barCount.getValue(), equalTo(3L)); } response = client().prepareSearch("idx3") @@ -615,27 +615,27 @@ public class ReverseNestedIT extends ESIntegTestCase { assertHitCount(response, 1); nested0 = response.getAggregations().get("nested_0"); - assertThat(nested0.getDocCount(), equalTo(3l)); + assertThat(nested0.getDocCount(), equalTo(3L)); terms = nested0.getAggregations().get("group_by_category"); assertThat(terms.getBuckets().size(), equalTo(3)); for (String bucketName : new String[]{"abc", "klm", "xyz"}) { logger.info("Checking results for bucket {}", bucketName); Terms.Bucket bucket = terms.getBucketByKey(bucketName); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ReverseNested toRoot = bucket.getAggregations().get("to_root"); - assertThat(toRoot.getDocCount(), equalTo(1l)); + assertThat(toRoot.getDocCount(), equalTo(1L)); Nested nested1 = toRoot.getAggregations().get("nested_1"); - assertThat(nested1.getDocCount(), equalTo(5l)); + assertThat(nested1.getDocCount(), equalTo(5L)); Filter filterByBar = nested1.getAggregations().get("filter_by_sku"); - assertThat(filterByBar.getDocCount(), equalTo(3l)); + assertThat(filterByBar.getDocCount(), equalTo(3L)); Nested nested2 = filterByBar.getAggregations().get("nested_2"); - assertThat(nested2.getDocCount(), equalTo(8l)); + assertThat(nested2.getDocCount(), equalTo(8L)); Filter filterBarColor = nested2.getAggregations().get("filter_sku_color"); - assertThat(filterBarColor.getDocCount(), equalTo(2l)); + assertThat(filterBarColor.getDocCount(), equalTo(2L)); ReverseNested reverseToBar = filterBarColor.getAggregations().get("reverse_to_sku"); - assertThat(reverseToBar.getDocCount(), equalTo(2l)); + assertThat(reverseToBar.getDocCount(), equalTo(2L)); ValueCount barCount = reverseToBar.getAggregations().get("sku_count"); - assertThat(barCount.getValue(), equalTo(2l)); + assertThat(barCount.getValue(), equalTo(2L)); } } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java index d0ed8bc39f1..5278aa903b4 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/SamplerIT.java @@ -137,7 +137,7 @@ public class SamplerIT extends ESIntegTestCase { for (Terms.Bucket testBucket : testBuckets) { maxBooksPerAuthor = Math.max(testBucket.getDocCount(), maxBooksPerAuthor); } - assertThat(maxBooksPerAuthor, equalTo(3l)); + assertThat(maxBooksPerAuthor, equalTo(3L)); } public void testUnmappedChildAggNoDiversity() throws Exception { @@ -152,7 +152,7 @@ public class SamplerIT extends ESIntegTestCase { .actionGet(); assertSearchResponse(response); Sampler sample = response.getAggregations().get("sample"); - assertThat(sample.getDocCount(), equalTo(0l)); + assertThat(sample.getDocCount(), equalTo(0L)); Terms authors = sample.getAggregations().get("authors"); assertThat(authors.getBuckets().size(), equalTo(0)); } @@ -169,7 +169,7 @@ public class SamplerIT extends ESIntegTestCase { .actionGet(); assertSearchResponse(response); Sampler sample = response.getAggregations().get("sample"); - assertThat(sample.getDocCount(), greaterThan(0l)); + assertThat(sample.getDocCount(), greaterThan(0L)); Terms authors = sample.getAggregations().get("authors"); assertThat(authors.getBuckets().size(), greaterThan(0)); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java index 78e4f7a099e..0616fa01b17 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsIT.java @@ -46,9 +46,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put("1", 8l); - expected.put("3", 8l); - expected.put("2", 5l); + expected.put("1", 8L); + expected.put("3", 8L); + expected.put("2", 5L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsString()))); } @@ -69,9 +69,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put("1", 8l); - expected.put("3", 8l); - expected.put("2", 4l); + expected.put("1", 8L); + expected.put("3", 8L); + expected.put("2", 4L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsString()))); } @@ -93,9 +93,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); // we still only return 3 entries (based on the 'size' param) Map expected = new HashMap<>(); - expected.put("1", 8l); - expected.put("3", 8l); - expected.put("2", 5l); // <-- count is now fixed + expected.put("1", 8L); + expected.put("3", 8L); + expected.put("2", 5L); // <-- count is now fixed for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsString()))); } @@ -117,9 +117,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); // we still only return 3 entries (based on the 'size' param) Map expected = new HashMap<>(); - expected.put("1", 5l); - expected.put("2", 4l); - expected.put("3", 3l); // <-- count is now fixed + expected.put("1", 5L); + expected.put("2", 4L); + expected.put("3", 3L); // <-- count is now fixed for (Terms.Bucket bucket: buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKey()))); } @@ -140,9 +140,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put("1", 8l); - expected.put("2", 5l); - expected.put("3", 8l); + expected.put("1", 8L); + expected.put("2", 5L); + expected.put("3", 8L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsString()))); } @@ -163,9 +163,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(3, 8l); - expected.put(2, 5l); + expected.put(1, 8L); + expected.put(3, 8L); + expected.put(2, 5L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -186,9 +186,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(3, 8l); - expected.put(2, 4l); + expected.put(1, 8L); + expected.put(3, 8L); + expected.put(2, 4L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -209,9 +209,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); // we still only return 3 entries (based on the 'size' param) Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(3, 8l); - expected.put(2, 5l); // <-- count is now fixed + expected.put(1, 8L); + expected.put(3, 8L); + expected.put(2, 5L); // <-- count is now fixed for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -233,9 +233,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); // we still only return 3 entries (based on the 'size' param) Map expected = new HashMap<>(); - expected.put(1, 5l); - expected.put(2, 4l); - expected.put(3, 3l); + expected.put(1, 5L); + expected.put(2, 4L); + expected.put(3, 3L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -256,9 +256,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(2, 5l); - expected.put(3, 8l); + expected.put(1, 8L); + expected.put(2, 5L); + expected.put(3, 8L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -279,9 +279,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(3, 8l); - expected.put(2, 5l); + expected.put(1, 8L); + expected.put(3, 8L); + expected.put(2, 5L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -302,9 +302,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(3, 8l); - expected.put(2, 4l); + expected.put(1, 8L); + expected.put(3, 8L); + expected.put(2, 4L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -325,9 +325,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(3, 8l); - expected.put(2, 5l); // <-- count is now fixed + expected.put(1, 8L); + expected.put(3, 8L); + expected.put(2, 5L); // <-- count is now fixed for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -348,9 +348,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 5l); - expected.put(2, 4l); - expected.put(3, 3l); + expected.put(1, 5L); + expected.put(2, 4L); + expected.put(3, 3L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } @@ -371,9 +371,9 @@ public class ShardSizeTermsIT extends ShardSizeTestCase { Collection buckets = terms.getBuckets(); assertThat(buckets.size(), equalTo(3)); Map expected = new HashMap<>(); - expected.put(1, 8l); - expected.put(2, 5l); - expected.put(3, 8l); + expected.put(1, 8L); + expected.put(2, 5L); + expected.put(3, 8L); for (Terms.Bucket bucket : buckets) { assertThat(bucket.getDocCount(), equalTo(expected.get(bucket.getKeyAsNumber().intValue()))); } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTestCase.java index 607b6902f8c..a3723428874 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTestCase.java @@ -93,11 +93,11 @@ public abstract class ShardSizeTestCase extends ESIntegTestCase { SearchResponse resp = client().prepareSearch("idx").setTypes("type").setRouting(routing1).setQuery(matchAllQuery()).execute().actionGet(); assertSearchResponse(resp); long totalOnOne = resp.getHits().getTotalHits(); - assertThat(totalOnOne, is(15l)); + assertThat(totalOnOne, is(15L)); resp = client().prepareSearch("idx").setTypes("type").setRouting(routing2).setQuery(matchAllQuery()).execute().actionGet(); assertSearchResponse(resp); long totalOnTwo = resp.getHits().getTotalHits(); - assertThat(totalOnTwo, is(12l)); + assertThat(totalOnTwo, is(12L)); } protected List indexDoc(String shard, String key, int times) throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java index 79aa6b2d5c9..1780911ccfd 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/TermsDocCountErrorIT.java @@ -101,12 +101,12 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { Terms accurateTerms = accurateResponse.getAggregations().get("terms"); assertThat(accurateTerms, notNullValue()); assertThat(accurateTerms.getName(), equalTo("terms")); - assertThat(accurateTerms.getDocCountError(), equalTo(0l)); + assertThat(accurateTerms.getDocCountError(), equalTo(0L)); Terms testTerms = testResponse.getAggregations().get("terms"); assertThat(testTerms, notNullValue()); assertThat(testTerms.getName(), equalTo("terms")); - assertThat(testTerms.getDocCountError(), greaterThanOrEqualTo(0l)); + assertThat(testTerms.getDocCountError(), greaterThanOrEqualTo(0L)); Collection testBuckets = testTerms.getBuckets(); assertThat(testBuckets.size(), lessThanOrEqualTo(size)); assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size())); @@ -115,7 +115,7 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { assertThat(testBucket, notNullValue()); Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString()); assertThat(accurateBucket, notNullValue()); - assertThat(accurateBucket.getDocCountError(), equalTo(0l)); + assertThat(accurateBucket.getDocCountError(), equalTo(0L)); assertThat(testBucket.getDocCountError(), lessThanOrEqualTo(testTerms.getDocCountError())); assertThat(testBucket.getDocCount() + testBucket.getDocCountError(), greaterThanOrEqualTo(accurateBucket.getDocCount())); assertThat(testBucket.getDocCount() - testBucket.getDocCountError(), lessThanOrEqualTo(accurateBucket.getDocCount())); @@ -135,12 +135,12 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { Terms accurateTerms = accurateResponse.getAggregations().get("terms"); assertThat(accurateTerms, notNullValue()); assertThat(accurateTerms.getName(), equalTo("terms")); - assertThat(accurateTerms.getDocCountError(), equalTo(0l)); + assertThat(accurateTerms.getDocCountError(), equalTo(0L)); Terms testTerms = testResponse.getAggregations().get("terms"); assertThat(testTerms, notNullValue()); assertThat(testTerms.getName(), equalTo("terms")); - assertThat(testTerms.getDocCountError(), equalTo(0l)); + assertThat(testTerms.getDocCountError(), equalTo(0L)); Collection testBuckets = testTerms.getBuckets(); assertThat(testBuckets.size(), lessThanOrEqualTo(size)); assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size())); @@ -149,8 +149,8 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { assertThat(testBucket, notNullValue()); Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString()); assertThat(accurateBucket, notNullValue()); - assertThat(accurateBucket.getDocCountError(), equalTo(0l)); - assertThat(testBucket.getDocCountError(), equalTo(0l)); + assertThat(accurateBucket.getDocCountError(), equalTo(0L)); + assertThat(testBucket.getDocCountError(), equalTo(0L)); } } @@ -158,13 +158,13 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { Terms testTerms = testResponse.getAggregations().get("terms"); assertThat(testTerms, notNullValue()); assertThat(testTerms.getName(), equalTo("terms")); - assertThat(testTerms.getDocCountError(), equalTo(0l)); + assertThat(testTerms.getDocCountError(), equalTo(0L)); Collection testBuckets = testTerms.getBuckets(); assertThat(testBuckets.size(), lessThanOrEqualTo(size)); for (Terms.Bucket testBucket : testBuckets) { assertThat(testBucket, notNullValue()); - assertThat(testBucket.getDocCountError(), equalTo(0l)); + assertThat(testBucket.getDocCountError(), equalTo(0L)); } } @@ -172,12 +172,12 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { Terms accurateTerms = accurateResponse.getAggregations().get("terms"); assertThat(accurateTerms, notNullValue()); assertThat(accurateTerms.getName(), equalTo("terms")); - assertThat(accurateTerms.getDocCountError(), equalTo(0l)); + assertThat(accurateTerms.getDocCountError(), equalTo(0L)); Terms testTerms = testResponse.getAggregations().get("terms"); assertThat(testTerms, notNullValue()); assertThat(testTerms.getName(), equalTo("terms")); - assertThat(testTerms.getDocCountError(),anyOf(equalTo(-1l), equalTo(0l))); + assertThat(testTerms.getDocCountError(),anyOf(equalTo(-1L), equalTo(0L))); Collection testBuckets = testTerms.getBuckets(); assertThat(testBuckets.size(), lessThanOrEqualTo(size)); assertThat(accurateTerms.getBuckets().size(), greaterThanOrEqualTo(testBuckets.size())); @@ -186,8 +186,8 @@ public class TermsDocCountErrorIT extends ESIntegTestCase { assertThat(testBucket, notNullValue()); Terms.Bucket accurateBucket = accurateTerms.getBucketByKey(testBucket.getKeyAsString()); assertThat(accurateBucket, notNullValue()); - assertThat(accurateBucket.getDocCountError(), equalTo(0l)); - assertThat(testBucket.getDocCountError(), anyOf(equalTo(-1l), equalTo(0l))); + assertThat(accurateBucket.getDocCountError(), equalTo(0L)); + assertThat(testBucket.getDocCountError(), anyOf(equalTo(-1L), equalTo(0L))); } } diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java index c09e46901a3..952045f6f9f 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java @@ -142,7 +142,7 @@ public class NestedAggregatorTests extends ESSingleNodeTestCase { Nested nested = (Nested) aggs[0].buildAggregation(0); // The bug manifests if 6 docs are returned, because currentRootDoc isn't reset the previous child docs from the first segment are emitted as hits. - assertThat(nested.getDocCount(), equalTo(4l)); + assertThat(nested.getDocCount(), equalTo(4L)); directoryReader.close(); directory.close(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java index 3336c672550..eec427ef80f 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/significant/SignificanceHeuristicTests.java @@ -108,8 +108,8 @@ public class SignificanceHeuristicTests extends ESTestCase { assertThat(originalBucket.getKeyAsString(), equalTo(streamedBucket.getKeyAsString())); assertThat(originalBucket.getSupersetDf(), equalTo(streamedBucket.getSupersetDf())); assertThat(originalBucket.getSubsetDf(), equalTo(streamedBucket.getSubsetDf())); - assertThat(streamedBucket.getSubsetSize(), equalTo(10l)); - assertThat(streamedBucket.getSupersetSize(), equalTo(20l)); + assertThat(streamedBucket.getSubsetSize(), equalTo(10L)); + assertThat(streamedBucket.getSupersetSize(), equalTo(20L)); } InternalSignificantTerms[] getRandomSignificantTerms(SignificanceHeuristic heuristic) { @@ -144,14 +144,14 @@ public class SignificanceHeuristicTests extends ESTestCase { List aggs = createInternalAggregations(); SignificantTerms reducedAgg = (SignificantTerms) aggs.get(0).doReduce(aggs, null); assertThat(reducedAgg.getBuckets().size(), equalTo(2)); - assertThat(reducedAgg.getBuckets().get(0).getSubsetDf(), equalTo(8l)); - assertThat(reducedAgg.getBuckets().get(0).getSubsetSize(), equalTo(16l)); - assertThat(reducedAgg.getBuckets().get(0).getSupersetDf(), equalTo(10l)); - assertThat(reducedAgg.getBuckets().get(0).getSupersetSize(), equalTo(30l)); - assertThat(reducedAgg.getBuckets().get(1).getSubsetDf(), equalTo(8l)); - assertThat(reducedAgg.getBuckets().get(1).getSubsetSize(), equalTo(16l)); - assertThat(reducedAgg.getBuckets().get(1).getSupersetDf(), equalTo(10l)); - assertThat(reducedAgg.getBuckets().get(1).getSupersetSize(), equalTo(30l)); + assertThat(reducedAgg.getBuckets().get(0).getSubsetDf(), equalTo(8L)); + assertThat(reducedAgg.getBuckets().get(0).getSubsetSize(), equalTo(16L)); + assertThat(reducedAgg.getBuckets().get(0).getSupersetDf(), equalTo(10L)); + assertThat(reducedAgg.getBuckets().get(0).getSupersetSize(), equalTo(30L)); + assertThat(reducedAgg.getBuckets().get(1).getSubsetDf(), equalTo(8L)); + assertThat(reducedAgg.getBuckets().get(1).getSubsetSize(), equalTo(16L)); + assertThat(reducedAgg.getBuckets().get(1).getSupersetDf(), equalTo(10L)); + assertThat(reducedAgg.getBuckets().get(1).getSupersetSize(), equalTo(30L)); } // Create aggregations as they might come from three different shards and return as list. @@ -269,7 +269,7 @@ public class SignificanceHeuristicTests extends ESTestCase { SignificantTermsAggregatorFactory aggregatorFactory = (SignificantTermsAggregatorFactory) new SignificantTermsParser( heuristicParserMapper, registry).parse("testagg", stParser, parseContext); stParser.nextToken(); - assertThat(aggregatorFactory.getBucketCountThresholds().getMinDocCount(), equalTo(200l)); + assertThat(aggregatorFactory.getBucketCountThresholds().getMinDocCount(), equalTo(200L)); assertThat(stParser.currentToken(), equalTo(null)); stParser.close(); return aggregatorFactory.getSignificanceHeuristic(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java index 390e0cf5473..695fb87efa9 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java @@ -199,7 +199,7 @@ public abstract class AbstractGeoTestCase extends ESIntegTestCase { Long value = hitField.getValue(); assertThat("Hit " + i + " has wrong value", value.intValue(), equalTo(i)); } - assertThat(totalHits, equalTo(2000l)); + assertThat(totalHits, equalTo(2000L)); } private void updateGeohashBucketsCentroid(final GeoPoint location) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java index 4e5d34f1e71..2ce78e451ce 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgIT.java @@ -72,10 +72,10 @@ public class AvgIT extends AbstractNumericTestCase { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(avg("avg"))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(avg("avg"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -94,7 +94,7 @@ public class AvgIT extends AbstractNumericTestCase { .addAggregation(avg("avg").field("value")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Avg avg = searchResponse.getAggregations().get("avg"); assertThat(avg, notNullValue()); @@ -128,7 +128,7 @@ public class AvgIT extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java index 0f94f142133..d97bc824602 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoBoundsIT.java @@ -166,7 +166,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase { .wrapLongitude(false)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); GeoBounds geoBounds = searchResponse.getAggregations().get(aggName); assertThat(geoBounds, notNullValue()); assertThat(geoBounds.getName(), equalTo(aggName)); @@ -238,7 +238,7 @@ public class GeoBoundsIT extends AbstractGeoTestCase { for (int i = 0; i < 10; i++) { Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); - assertThat("InternalBucket " + bucket.getKey() + " has wrong number of documents", bucket.getDocCount(), equalTo(1l)); + assertThat("InternalBucket " + bucket.getKey() + " has wrong number of documents", bucket.getDocCount(), equalTo(1L)); GeoBounds geoBounds = bucket.getAggregations().get(aggName); assertThat(geoBounds, notNullValue()); assertThat(geoBounds.getName(), equalTo(aggName)); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java index e0d260f5435..8c21cbd7a56 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/GeoCentroidIT.java @@ -53,7 +53,7 @@ public class GeoCentroidIT extends AbstractGeoTestCase { assertSearchResponse(response); GeoCentroid geoCentroid = response.getAggregations().get(aggName); - assertThat(response.getHits().getTotalHits(), equalTo(0l)); + assertThat(response.getHits().getTotalHits(), equalTo(0L)); assertThat(geoCentroid, notNullValue()); assertThat(geoCentroid.getName(), equalTo(aggName)); GeoPoint centroid = geoCentroid.centroid(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java index 8c1df006a27..f2c05ee4eeb 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/SumIT.java @@ -69,10 +69,10 @@ public class SumIT extends AbstractNumericTestCase { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(sum("sum"))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(sum("sum"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -91,7 +91,7 @@ public class SumIT extends AbstractNumericTestCase { .addAggregation(sum("sum").field("value")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Sum sum = searchResponse.getAggregations().get("sum"); assertThat(sum, notNullValue()); @@ -138,7 +138,7 @@ public class SumIT extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java index 6c1ff6a380b..fe4fafc6021 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java @@ -210,7 +210,7 @@ public class TopHitsIT extends ESIntegTestCase { client().prepareIndex("articles", "article", "1") .setSource(jsonBuilder().startObject().field("title", "title 1").field("body", "some text").startArray("comments") .startObject() - .field("user", "a").field("date", 1l).field("message", "some comment") + .field("user", "a").field("date", 1L).field("message", "some comment") .startArray("reviewers") .startObject().field("name", "user a").endObject() .startObject().field("name", "user b").endObject() @@ -218,7 +218,7 @@ public class TopHitsIT extends ESIntegTestCase { .endArray() .endObject() .startObject() - .field("user", "b").field("date", 2l).field("message", "some other comment") + .field("user", "b").field("date", 2L).field("message", "some other comment") .startArray("reviewers") .startObject().field("name", "user c").endObject() .startObject().field("name", "user d").endObject() @@ -231,12 +231,12 @@ public class TopHitsIT extends ESIntegTestCase { client().prepareIndex("articles", "article", "2") .setSource(jsonBuilder().startObject().field("title", "title 2").field("body", "some different text").startArray("comments") .startObject() - .field("user", "b").field("date", 3l).field("message", "some comment") + .field("user", "b").field("date", 3L).field("message", "some comment") .startArray("reviewers") .startObject().field("name", "user f").endObject() .endArray() .endObject() - .startObject().field("user", "c").field("date", 4l).field("message", "some other comment").endObject() + .startObject().field("user", "c").field("date", 4L).field("message", "some other comment").endObject() .endArray().endObject()) ); @@ -273,10 +273,10 @@ public class TopHitsIT extends ESIntegTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(10l)); + assertThat(bucket.getDocCount(), equalTo(10L)); TopHits topHits = bucket.getAggregations().get("hits"); SearchHits hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(10l)); + assertThat(hits.totalHits(), equalTo(10L)); assertThat(hits.getHits().length, equalTo(3)); higestSortValue += 10; assertThat((Long) hits.getAt(0).sortValues()[0], equalTo(higestSortValue)); @@ -299,7 +299,7 @@ public class TopHitsIT extends ESIntegTestCase { assertSearchResponse(response); - assertThat(response.getHits().getTotalHits(), equalTo(8l)); + assertThat(response.getHits().getTotalHits(), equalTo(8L)); assertThat(response.getHits().hits().length, equalTo(0)); assertThat(response.getHits().maxScore(), equalTo(0f)); Terms terms = response.getAggregations().get("terms"); @@ -335,7 +335,7 @@ public class TopHitsIT extends ESIntegTestCase { assertSearchResponse(response); - assertThat(response.getHits().getTotalHits(), equalTo(8l)); + assertThat(response.getHits().getTotalHits(), equalTo(8L)); assertThat(response.getHits().hits().length, equalTo(0)); assertThat(response.getHits().maxScore(), equalTo(0f)); terms = response.getAggregations().get("terms"); @@ -366,10 +366,10 @@ public class TopHitsIT extends ESIntegTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(10l)); + assertThat(bucket.getDocCount(), equalTo(10L)); TopHits topHits = bucket.getAggregations().get("hits"); SearchHits hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(10l)); + assertThat(hits.totalHits(), equalTo(10L)); assertThat(hits.getHits().length, equalTo(3)); assertThat(hits.getAt(0).sourceAsMap().size(), equalTo(4)); @@ -428,7 +428,7 @@ public class TopHitsIT extends ESIntegTestCase { Terms.Bucket bucket = terms.getBucketByKey("val0"); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(10l)); + assertThat(bucket.getDocCount(), equalTo(10L)); TopHits topHits = bucket.getAggregations().get("hits"); SearchHits hits = topHits.getHits(); assertThat(hits.totalHits(), equalTo(controlHits.totalHits())); @@ -465,10 +465,10 @@ public class TopHitsIT extends ESIntegTestCase { int currentBucket = 4; for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(key(bucket), equalTo("val" + currentBucket--)); - assertThat(bucket.getDocCount(), equalTo(10l)); + assertThat(bucket.getDocCount(), equalTo(10L)); TopHits topHits = bucket.getAggregations().get("hits"); SearchHits hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(10l)); + assertThat(hits.totalHits(), equalTo(10L)); assertThat(hits.getHits().length, equalTo(3)); assertThat((Long) hits.getAt(0).sortValues()[0], equalTo(higestSortValue)); assertThat((Long) hits.getAt(1).sortValues()[0], equalTo(higestSortValue - 1)); @@ -501,7 +501,7 @@ public class TopHitsIT extends ESIntegTestCase { assertThat(key(bucket), equalTo("b")); TopHits topHits = bucket.getAggregations().get("hits"); SearchHits hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(4l)); + assertThat(hits.totalHits(), equalTo(4L)); assertThat(hits.getHits().length, equalTo(1)); assertThat(hits.getAt(0).id(), equalTo("6")); @@ -509,7 +509,7 @@ public class TopHitsIT extends ESIntegTestCase { assertThat(key(bucket), equalTo("c")); topHits = bucket.getAggregations().get("hits"); hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(3l)); + assertThat(hits.totalHits(), equalTo(3L)); assertThat(hits.getHits().length, equalTo(1)); assertThat(hits.getAt(0).id(), equalTo("9")); @@ -517,7 +517,7 @@ public class TopHitsIT extends ESIntegTestCase { assertThat(key(bucket), equalTo("a")); topHits = bucket.getAggregations().get("hits"); hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(2l)); + assertThat(hits.totalHits(), equalTo(2L)); assertThat(hits.getHits().length, equalTo(1)); assertThat(hits.getAt(0).id(), equalTo("2")); } @@ -550,7 +550,7 @@ public class TopHitsIT extends ESIntegTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { TopHits topHits = bucket.getAggregations().get("hits"); SearchHits hits = topHits.getHits(); - assertThat(hits.totalHits(), equalTo(10l)); + assertThat(hits.totalHits(), equalTo(10L)); assertThat(hits.getHits().length, equalTo(1)); SearchHit hit = hits.getAt(0); @@ -562,7 +562,7 @@ public class TopHitsIT extends ESIntegTestCase { assertThat(explanation.toString(), containsString("text:text")); long version = hit.version(); - assertThat(version, equalTo(1l)); + assertThat(version, equalTo(1L)); assertThat(hit.matchedQueries()[0], equalTo("test")); @@ -637,7 +637,7 @@ public class TopHitsIT extends ESIntegTestCase { TopHits hits = response.getAggregations().get("hits"); assertThat(hits, notNullValue()); assertThat(hits.getName(), equalTo("hits")); - assertThat(hits.getHits().totalHits(), equalTo(0l)); + assertThat(hits.getHits().totalHits(), equalTo(0L)); } public void testTrackScores() throws Exception { @@ -702,23 +702,23 @@ public class TopHitsIT extends ESIntegTestCase { .get(); Nested nested = searchResponse.getAggregations().get("to-comments"); - assertThat(nested.getDocCount(), equalTo(4l)); + assertThat(nested.getDocCount(), equalTo(4L)); Terms terms = nested.getAggregations().get("users"); Terms.Bucket bucket = terms.getBucketByKey("a"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); TopHits topHits = bucket.getAggregations().get("top-comments"); SearchHits searchHits = topHits.getHits(); - assertThat(searchHits.totalHits(), equalTo(1l)); + assertThat(searchHits.totalHits(), equalTo(1L)); assertThat(searchHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(searchHits.getAt(0).getNestedIdentity().getOffset(), equalTo(0)); assertThat((Integer) searchHits.getAt(0).getSource().get("date"), equalTo(1)); bucket = terms.getBucketByKey("b"); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); topHits = bucket.getAggregations().get("top-comments"); searchHits = topHits.getHits(); - assertThat(searchHits.totalHits(), equalTo(2l)); + assertThat(searchHits.totalHits(), equalTo(2L)); assertThat(searchHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(searchHits.getAt(0).getNestedIdentity().getOffset(), equalTo(1)); assertThat((Integer) searchHits.getAt(0).getSource().get("date"), equalTo(2)); @@ -727,10 +727,10 @@ public class TopHitsIT extends ESIntegTestCase { assertThat((Integer) searchHits.getAt(1).getSource().get("date"), equalTo(3)); bucket = terms.getBucketByKey("c"); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); topHits = bucket.getAggregations().get("top-comments"); searchHits = topHits.getHits(); - assertThat(searchHits.totalHits(), equalTo(1l)); + assertThat(searchHits.totalHits(), equalTo(1L)); assertThat(searchHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(searchHits.getAt(0).getNestedIdentity().getOffset(), equalTo(1)); assertThat((Integer) searchHits.getAt(0).getSource().get("date"), equalTo(4)); @@ -752,10 +752,10 @@ public class TopHitsIT extends ESIntegTestCase { assertNoFailures(searchResponse); Nested toComments = searchResponse.getAggregations().get("to-comments"); - assertThat(toComments.getDocCount(), equalTo(4l)); + assertThat(toComments.getDocCount(), equalTo(4L)); TopHits topComments = toComments.getAggregations().get("top-comments"); - assertThat(topComments.getHits().totalHits(), equalTo(4l)); + assertThat(topComments.getHits().totalHits(), equalTo(4L)); assertThat(topComments.getHits().getHits().length, equalTo(4)); assertThat(topComments.getHits().getAt(0).getId(), equalTo("2")); @@ -779,10 +779,10 @@ public class TopHitsIT extends ESIntegTestCase { assertThat(topComments.getHits().getAt(3).getNestedIdentity().getChild(), nullValue()); Nested toReviewers = toComments.getAggregations().get("to-reviewers"); - assertThat(toReviewers.getDocCount(), equalTo(7l)); + assertThat(toReviewers.getDocCount(), equalTo(7L)); TopHits topReviewers = toReviewers.getAggregations().get("top-reviewers"); - assertThat(topReviewers.getHits().totalHits(), equalTo(7l)); + assertThat(topReviewers.getHits().totalHits(), equalTo(7L)); assertThat(topReviewers.getHits().getHits().length, equalTo(7)); assertThat(topReviewers.getHits().getAt(0).getId(), equalTo("1")); @@ -853,10 +853,10 @@ public class TopHitsIT extends ESIntegTestCase { .version(true).sort("comments.date", SortOrder.ASC))).get(); assertHitCount(searchResponse, 2); Nested nested = searchResponse.getAggregations().get("to-comments"); - assertThat(nested.getDocCount(), equalTo(4l)); + assertThat(nested.getDocCount(), equalTo(4L)); SearchHits hits = ((TopHits) nested.getAggregations().get("top-comments")).getHits(); - assertThat(hits.totalHits(), equalTo(4l)); + assertThat(hits.totalHits(), equalTo(4L)); SearchHit searchHit = hits.getAt(0); assertThat(searchHit.getId(), equalTo("1")); assertThat(searchHit.getNestedIdentity().getField().string(), equalTo("comments")); @@ -873,7 +873,7 @@ public class TopHitsIT extends ESIntegTestCase { // Returns the version of the root document. Nested docs don't have a separate version long version = searchHit.version(); - assertThat(version, equalTo(1l)); + assertThat(version, equalTo(1L)); assertThat(searchHit.matchedQueries(), arrayContaining("test")); @@ -906,7 +906,7 @@ public class TopHitsIT extends ESIntegTestCase { Histogram histogram = searchResponse.getAggregations().get("dates"); for (int i = 0; i < numArticles; i += 5) { Histogram.Bucket bucket = histogram.getBuckets().get(i / 5); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); long numNestedDocs = 10 + (5 * i); Nested nested = bucket.getAggregations().get("to-comments"); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java index e130189eabc..381335cb005 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ValueCountIT.java @@ -85,12 +85,12 @@ public class ValueCountIT extends ESIntegTestCase { .addAggregation(count("count").field("value")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(0l)); + assertThat(valueCount.getValue(), equalTo(0L)); } public void testSingleValuedField() throws Exception { @@ -104,7 +104,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); + assertThat(valueCount.getValue(), equalTo(10L)); } public void testSingleValuedFieldGetProperty() throws Exception { @@ -116,14 +116,14 @@ public class ValueCountIT extends ESIntegTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); ValueCount valueCount = global.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); + assertThat(valueCount.getValue(), equalTo(10L)); assertThat((ValueCount) global.getProperty("count"), equalTo(valueCount)); assertThat((double) global.getProperty("count.value"), equalTo(10d)); assertThat((double) valueCount.getProperty("value"), equalTo(10d)); @@ -140,7 +140,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); + assertThat(valueCount.getValue(), equalTo(10L)); } public void testMultiValuedField() throws Exception { @@ -154,7 +154,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(20l)); + assertThat(valueCount.getValue(), equalTo(20L)); } public void testSingleValuedScript() throws Exception { @@ -166,7 +166,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); + assertThat(valueCount.getValue(), equalTo(10L)); } public void testMultiValuedScript() throws Exception { @@ -178,7 +178,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(20l)); + assertThat(valueCount.getValue(), equalTo(20L)); } public void testSingleValuedScriptWithParams() throws Exception { @@ -191,7 +191,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(10l)); + assertThat(valueCount.getValue(), equalTo(10L)); } public void testMultiValuedScriptWithParams() throws Exception { @@ -204,7 +204,7 @@ public class ValueCountIT extends ESIntegTestCase { ValueCount valueCount = searchResponse.getAggregations().get("count"); assertThat(valueCount, notNullValue()); assertThat(valueCount.getName(), equalTo("count")); - assertThat(valueCount.getValue(), equalTo(20l)); + assertThat(valueCount.getValue(), equalTo(20L)); } /** diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java index 074ad419858..17f06bec2be 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/AvgBucketIT.java @@ -191,7 +191,7 @@ public class AvgBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); count++; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java index e5b816d0e81..73ec2c9c0bd 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DateDerivativeIT.java @@ -123,7 +123,7 @@ public class DateDerivativeIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); SimpleValue docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, nullValue()); @@ -131,7 +131,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); assertThat(docCountDeriv.value(), equalTo(1d)); @@ -140,7 +140,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); assertThat(docCountDeriv.value(), equalTo(1d)); @@ -166,7 +166,7 @@ public class DateDerivativeIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Derivative docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, nullValue()); @@ -174,7 +174,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); assertThat(docCountDeriv.value(), closeTo(1d, 0.00001)); @@ -184,7 +184,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); assertThat(docCountDeriv.value(), closeTo(1d, 0.00001)); @@ -214,7 +214,7 @@ public class DateDerivativeIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); @@ -222,14 +222,14 @@ public class DateDerivativeIT extends ESIntegTestCase { SimpleValue deriv = bucket.getAggregations().get("deriv"); assertThat(deriv, nullValue()); assertThat((DateTime) propertiesKeys[0], equalTo(key)); - assertThat((long) propertiesDocCounts[0], equalTo(1l)); + assertThat((long) propertiesDocCounts[0], equalTo(1L)); assertThat((double) propertiesCounts[0], equalTo(1.0)); key = new DateTime(2012, 2, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); @@ -239,14 +239,14 @@ public class DateDerivativeIT extends ESIntegTestCase { assertThat(deriv.value(), equalTo(4.0)); assertThat((double) bucket.getProperty("histo", AggregationPath.parse("deriv.value").getPathElementsAsStringList()), equalTo(4.0)); assertThat((DateTime) propertiesKeys[1], equalTo(key)); - assertThat((long) propertiesDocCounts[1], equalTo(2l)); + assertThat((long) propertiesDocCounts[1], equalTo(2L)); assertThat((double) propertiesCounts[1], equalTo(5.0)); key = new DateTime(2012, 3, 1, 0, 0, DateTimeZone.UTC); bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); @@ -256,7 +256,7 @@ public class DateDerivativeIT extends ESIntegTestCase { assertThat(deriv.value(), equalTo(10.0)); assertThat((double) bucket.getProperty("histo", AggregationPath.parse("deriv.value").getPathElementsAsStringList()), equalTo(10.0)); assertThat((DateTime) propertiesKeys[2], equalTo(key)); - assertThat((long) propertiesDocCounts[2], equalTo(3l)); + assertThat((long) propertiesDocCounts[2], equalTo(3L)); assertThat((double) propertiesCounts[2], equalTo(15.0)); } @@ -279,7 +279,7 @@ public class DateDerivativeIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(true)); SimpleValue docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, nullValue()); @@ -288,7 +288,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); @@ -298,7 +298,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); @@ -308,7 +308,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(3); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); @@ -349,7 +349,7 @@ public class DateDerivativeIT extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(true)); SimpleValue docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, nullValue()); @@ -358,7 +358,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); @@ -368,7 +368,7 @@ public class DateDerivativeIT extends ESIntegTestCase { bucket = buckets.get(2); assertThat(bucket, notNullValue()); assertThat((DateTime) bucket.getKey(), equalTo(key)); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); assertThat(bucket.getAggregations().asList().isEmpty(), is(false)); docCountDeriv = bucket.getAggregations().get("deriv"); assertThat(docCountDeriv, notNullValue()); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java index f1ad0810845..9e0850bc2b8 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/DerivativeIT.java @@ -122,7 +122,7 @@ public class DerivativeIT extends ESIntegTestCase { } // setup for index with empty buckets - valueCounts_empty = new Long[] { 1l, 1l, 2l, 0l, 2l, 2l, 0l, 0l, 0l, 3l, 2l, 1l }; + valueCounts_empty = new Long[] { 1L, 1L, 2L, 0L, 2L, 2L, 0L, 0L, 0L, 3L, 2L, 1L }; firstDerivValueCounts_empty = new Double[] { null, 0d, 1d, -2d, 2d, 0d, -2d, 0d, 0d, 3d, -1d, -1d }; assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); @@ -144,7 +144,7 @@ public class DerivativeIT extends ESIntegTestCase { valueCounts_empty_rnd[i] = (long) randomIntBetween(1, 10); // make approximately half of the buckets empty if (randomBoolean()) - valueCounts_empty_rnd[i] = 0l; + valueCounts_empty_rnd[i] = 0L; for (int docs = 0; docs < valueCounts_empty_rnd[i]; docs++) { builders.add(client().prepareIndex("empty_bucket_idx_rnd", "type").setSource(newDocBuilder(i))); numDocsEmptyIdx_rnd++; @@ -410,7 +410,7 @@ public class DerivativeIT extends ESIntegTestCase { .setQuery(matchAllQuery()) .addAggregation( histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1) - .extendedBounds(new ExtendedBounds(0l, (long) numBuckets_empty_rnd - 1)) + .extendedBounds(new ExtendedBounds(0L, (long) numBuckets_empty_rnd - 1)) .subAggregation(derivative("deriv", "_count").gapPolicy(randomFrom(GapPolicy.values())))) .execute().actionGet(); @@ -549,7 +549,7 @@ public class DerivativeIT extends ESIntegTestCase { .setQuery(matchAllQuery()) .addAggregation( histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1) - .extendedBounds(new ExtendedBounds(0l, (long) numBuckets_empty_rnd - 1)) + .extendedBounds(new ExtendedBounds(0L, (long) numBuckets_empty_rnd - 1)) .subAggregation(sum("sum").field(SINGLE_VALUED_FIELD_NAME)) .subAggregation(derivative("deriv", "sum").gapPolicy(gapPolicy))).execute().actionGet(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java index 63a55cfc526..64345607acf 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java @@ -214,7 +214,7 @@ public class ExtendedStatsBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); count++; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java index 82ed6b9d893..434c45da2a3 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MaxBucketIT.java @@ -205,7 +205,7 @@ public class MaxBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); if (sum.value() > maxValue) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java index 3d4ecf124e7..55d4cb08b0b 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/MinBucketIT.java @@ -202,7 +202,7 @@ public class MinBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); if (sum.value() < minValue) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java index 4f03ccee437..d1989e229b4 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/PercentilesBucketIT.java @@ -202,7 +202,7 @@ public class PercentilesBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); values[i] = sum.value(); @@ -238,7 +238,7 @@ public class PercentilesBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); values[i] = sum.value(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java index b60d4cc5482..a16a430343e 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/StatsBucketIT.java @@ -206,7 +206,7 @@ public class StatsBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); count++; diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java index fcbbf9b75cd..e372f667b43 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/SumBucketIT.java @@ -184,7 +184,7 @@ public class SumBucketIT extends ESIntegTestCase { Terms.Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((String) bucket.getKey(), equalTo("tag" + (i % interval))); - assertThat(bucket.getDocCount(), greaterThan(0l)); + assertThat(bucket.getDocCount(), greaterThan(0L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); bucketSum += sum.value(); diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java index e23df88a385..318e07d5a0b 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/pipeline/moving/avg/MovAvgIT.java @@ -678,7 +678,7 @@ public class MovAvgIT extends ESIntegTestCase { Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((long) bucket.getKey(), equalTo((long) i - 10)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avgAgg = bucket.getAggregations().get("avg"); assertThat(avgAgg, notNullValue()); assertThat(avgAgg.value(), equalTo(10d)); @@ -691,7 +691,7 @@ public class MovAvgIT extends ESIntegTestCase { Bucket bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((long) bucket.getKey(), equalTo((long) i - 10)); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); Avg avgAgg = bucket.getAggregations().get("avg"); assertThat(avgAgg, nullValue()); SimpleValue movAvgAgg = bucket.getAggregations().get("movavg_values"); @@ -901,7 +901,7 @@ public class MovAvgIT extends ESIntegTestCase { Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat((long) bucket.getKey(), equalTo((long) 0)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avgAgg = bucket.getAggregations().get("avg"); assertThat(avgAgg, notNullValue()); @@ -920,7 +920,7 @@ public class MovAvgIT extends ESIntegTestCase { bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat((long) bucket.getKey(), equalTo(1L)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); avgAgg = bucket.getAggregations().get("avg"); assertThat(avgAgg, notNullValue()); @@ -941,7 +941,7 @@ public class MovAvgIT extends ESIntegTestCase { bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((long) bucket.getKey(), equalTo((long) i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); avgAgg = bucket.getAggregations().get("avg"); assertThat(avgAgg, notNullValue()); @@ -965,7 +965,7 @@ public class MovAvgIT extends ESIntegTestCase { bucket = buckets.get(i); assertThat(bucket, notNullValue()); assertThat((long) bucket.getKey(), equalTo((long) i)); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); avgAgg = bucket.getAggregations().get("avg"); assertThat(avgAgg, nullValue()); diff --git a/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java b/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java index 38fb4cae98d..fec1ca7c930 100644 --- a/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/basic/TransportTwoNodesSearchIT.java @@ -140,7 +140,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setSearchType(DFS_QUERY_THEN_FETCH).setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).setScroll(TimeValue.timeValueSeconds(30)).get(); while (true) { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); SearchHit[] hits = searchResponse.getHits().hits(); if (hits.length == 0) { break; // finished @@ -164,7 +164,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setSearchType(DFS_QUERY_THEN_FETCH).setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).addSort("age", SortOrder.ASC).setScroll(TimeValue.timeValueSeconds(30)).get(); while (true) { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); SearchHit[] hits = searchResponse.getHits().hits(); if (hits.length == 0) { break; // finished @@ -188,7 +188,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setSearchType(QUERY_THEN_FETCH).setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).addSort("nid", SortOrder.DESC).setScroll(TimeValue.timeValueSeconds(30)).get(); while (true) { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); SearchHit[] hits = searchResponse.getHits().hits(); if (hits.length == 0) { break; // finished @@ -216,7 +216,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().search(searchRequest("test").source(source.from(0).size(60)).searchType(QUERY_THEN_FETCH)).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(60)); for (int i = 0; i < 60; i++) { SearchHit hit = searchResponse.getHits().hits()[i]; @@ -224,7 +224,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { } searchResponse = client().search(searchRequest("test").source(source.from(60).size(60)).searchType(QUERY_THEN_FETCH)).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(40)); for (int i = 0; i < 40; i++) { SearchHit hit = searchResponse.getHits().hits()[i]; @@ -240,7 +240,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(termQuery("multi", "test")).setSize(60).setExplain(true).addSort("age", SortOrder.ASC).setScroll(TimeValue.timeValueSeconds(30)).get(); while (true) { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); SearchHit[] hits = searchResponse.getHits().hits(); if (hits.length == 0) { break; // finished @@ -271,7 +271,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(QUERY_AND_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(60)); // 20 per shard for (int i = 0; i < 60; i++) { SearchHit hit = searchResponse.getHits().hits()[i]; @@ -284,7 +284,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { do { searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).setScroll("10m").get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, lessThanOrEqualTo(40)); for (int i = 0; i < searchResponse.getHits().hits().length; i++) { SearchHit hit = searchResponse.getHits().hits()[i]; @@ -312,7 +312,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { //SearchResponse searchResponse = client().search(searchRequest("test").source(source).searchType(DFS_QUERY_AND_FETCH).scroll(new Scroll(timeValueMinutes(10)))).actionGet(); SearchResponse searchResponse = client().prepareSearch("test").setSearchType(DFS_QUERY_AND_FETCH).setScroll("10m").setSource(source).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(60)); // 20 per shard for (int i = 0; i < 60; i++) { SearchHit hit = searchResponse.getHits().hits()[i]; @@ -325,7 +325,7 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { do { searchResponse = client().prepareSearchScroll(searchResponse.getScrollId()).setScroll("10m").get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, lessThanOrEqualTo(40)); for (int i = 0; i < searchResponse.getHits().hits().length; i++) { SearchHit hit = searchResponse.getHits().hits()[i]; @@ -349,13 +349,13 @@ public class TransportTwoNodesSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().search(searchRequest("test").source(sourceBuilder)).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(100L)); Global global = searchResponse.getAggregations().get("global"); Filter all = global.getAggregations().get("all"); Filter test1 = searchResponse.getAggregations().get("test1"); - assertThat(test1.getDocCount(), equalTo(1l)); - assertThat(all.getDocCount(), equalTo(100l)); + assertThat(test1.getDocCount(), equalTo(1L)); + assertThat(all.getDocCount(), equalTo(100L)); } public void testFailedSearchWithWrongQuery() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java index 9bd8fcbdfed..d8f76c001bb 100644 --- a/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/child/ChildQuerySearchIT.java @@ -136,33 +136,33 @@ public class ChildQuerySearchIT extends ESIntegTestCase { boolQuery().must(termQuery("c_field", "c_value1")) .filter(hasChildQuery("grandchild", termQuery("gc_field", "gc_value1")))))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", termQuery("p_field", "p_value1")))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1")); searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("child", termQuery("c_field", "c_value1")))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("gc1")); searchResponse = client().prepareSearch("test").setQuery(hasParentQuery("parent", termQuery("p_field", "p_value1"))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1")); searchResponse = client().prepareSearch("test").setQuery(hasParentQuery("child", termQuery("c_field", "c_value1"))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("gc1")); } @@ -180,7 +180,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("test", matchQuery("foo", 1))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); } @@ -204,14 +204,14 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(idsQuery("child").addIds("c1")).fields("_parent").execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1")); assertThat(searchResponse.getHits().getAt(0).field("_parent").value().toString(), equalTo("p1")); // TEST matching on parent searchResponse = client().prepareSearch("test").setQuery(termQuery("_parent#parent", "p1")).fields("_parent").get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("c1"), equalTo("c2"))); assertThat(searchResponse.getHits().getAt(0).field("_parent").value().toString(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("c1"), equalTo("c2"))); @@ -219,7 +219,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test").setQuery(queryStringQuery("_parent#parent:p1")).fields("_parent").get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("c1"), equalTo("c2"))); assertThat(searchResponse.getHits().getAt(0).field("_parent").value().toString(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("c1"), equalTo("c2"))); @@ -228,17 +228,17 @@ public class ChildQuerySearchIT extends ESIntegTestCase { // HAS CHILD searchResponse = client().prepareSearch("test").setQuery(randomHasChild("child", "c_field", "yellow")) .get(); - assertHitCount(searchResponse, 1l); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertHitCount(searchResponse, 1L); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); searchResponse = client().prepareSearch("test").setQuery(randomHasChild("child", "c_field", "blue")).execute() .actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2")); searchResponse = client().prepareSearch("test").setQuery(randomHasChild("child", "c_field", "red")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1"))); assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); @@ -246,13 +246,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test") .setQuery(randomHasParent("parent", "p_field", "p_value2")).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c3")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c4")); searchResponse = client().prepareSearch("test") .setQuery(randomHasParent("parent", "p_field", "p_value1")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c1")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c2")); } @@ -372,18 +372,18 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "yellow"))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "blue"))).execute() .actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2")); searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "red"))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1"))); assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); @@ -392,19 +392,19 @@ public class ChildQuerySearchIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "yellow")))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue")))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "red")))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1"))); assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); } @@ -432,7 +432,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { AggregationBuilders.filter("filter", boolQuery().should(termQuery("c_field", "red")).should(termQuery("c_field", "yellow"))).subAggregation( AggregationBuilders.terms("facet1").field("c_field")))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), anyOf(equalTo("p2"), equalTo("p1"))); assertThat(searchResponse.getHits().getAt(1).id(), anyOf(equalTo("p2"), equalTo("p1"))); @@ -464,7 +464,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "yellow")))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1\"")); @@ -476,7 +476,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "yellow")))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1_updated\"")); } @@ -523,12 +523,12 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", matchAllQuery()))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", matchAllQuery()))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); } public void testCountApiUsage() throws Exception { @@ -544,19 +544,19 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse countResponse = client().prepareSearch("test").setSize(0).setQuery(hasChildQuery("child", termQuery("c_field", "1")).scoreMode(ScoreMode.Max)) .get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); countResponse = client().prepareSearch("test").setSize(0).setQuery(hasParentQuery("parent", termQuery("p_field", "1")).score(true)) .get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); countResponse = client().prepareSearch("test").setSize(0).setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "1")))) .get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); countResponse = client().prepareSearch("test").setSize(0).setQuery(constantScoreQuery(hasParentQuery("parent", termQuery("p_field", "1")))) .get(); - assertHitCount(countResponse, 1l); + assertHitCount(countResponse, 1L); } public void testExplainUsage() throws Exception { @@ -574,14 +574,14 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .setExplain(true) .setQuery(hasChildQuery("child", termQuery("c_field", "1")).scoreMode(ScoreMode.Max)) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).explanation().getDescription(), equalTo("Score based on join value p1")); searchResponse = client().prepareSearch("test") .setExplain(true) .setQuery(hasParentQuery("parent", termQuery("p_field", "1")).score(true)) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).explanation().getDescription(), equalTo("Score based on join value p1")); ExplainResponse explainResponse = client().prepareExplain("test", "parent", parentId) @@ -664,7 +664,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { fieldValueFactorFunction("c_field1")) .boostMode(CombineFunction.REPLACE)).scoreMode(ScoreMode.Total)).get(); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("1")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -681,7 +681,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { fieldValueFactorFunction("c_field1")) .boostMode(CombineFunction.REPLACE)).scoreMode(ScoreMode.Max)).get(); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(4f)); assertThat(response.getHits().hits()[1].id(), equalTo("2")); @@ -698,7 +698,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { fieldValueFactorFunction("c_field1")) .boostMode(CombineFunction.REPLACE)).scoreMode(ScoreMode.Avg)).get(); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(4f)); assertThat(response.getHits().hits()[1].id(), equalTo("2")); @@ -716,7 +716,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .boostMode(CombineFunction.REPLACE)).score(true)) .addSort(SortBuilders.fieldSort("c_field3")).addSort(SortBuilders.scoreSort()).get(); - assertThat(response.getHits().totalHits(), equalTo(7l)); + assertThat(response.getHits().totalHits(), equalTo(7L)); assertThat(response.getHits().hits()[0].id(), equalTo("13")); assertThat(response.getHits().hits()[0].score(), equalTo(5f)); assertThat(response.getHits().hits()[1].id(), equalTo("14")); @@ -743,28 +743,28 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse response = client().prepareSearch("test") .setQuery(QueryBuilders.hasChildQuery("child", matchQuery("text", "value"))).get(); assertNoFailures(response); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); client().prepareIndex("test", "child1").setSource(jsonBuilder().startObject().field("text", "value").endObject()).setRefresh(true) .get(); response = client().prepareSearch("test").setQuery(QueryBuilders.hasChildQuery("child", matchQuery("text", "value"))).get(); assertNoFailures(response); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = client().prepareSearch("test").setQuery(QueryBuilders.hasChildQuery("child", matchQuery("text", "value")).scoreMode(ScoreMode.Max)) .get(); assertNoFailures(response); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = client().prepareSearch("test").setQuery(QueryBuilders.hasParentQuery("child", matchQuery("text", "value"))).get(); assertNoFailures(response); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = client().prepareSearch("test").setQuery(QueryBuilders.hasParentQuery("child", matchQuery("text", "value")).score(true)) .get(); assertNoFailures(response); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); } public void testHasChildAndHasParentFilter_withFilter() throws Exception { @@ -783,13 +783,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(matchAllQuery()).filter(hasChildQuery("child", termQuery("c_field", 1)))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits()[0].id(), equalTo("1")); searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(matchAllQuery()).filter(hasParentQuery("parent", termQuery("p_field", 1)))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits()[0].id(), equalTo("2")); } @@ -888,7 +888,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(hasChildQuery("child", termQuery("c_field", "yellow")).scoreMode(ScoreMode.Total)).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1\"")); @@ -898,7 +898,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { boolQuery().must(matchQuery("c_field", "x")).must( hasParentQuery("parent", termQuery("p_field", "p_value2")).score(true))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("c3")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("c4")); @@ -914,7 +914,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "yellow")).scoreMode(ScoreMode.Total)) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p1")); assertThat(searchResponse.getHits().getAt(0).sourceAsString(), containsString("\"p_value1\"")); @@ -924,7 +924,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { boolQuery().must(matchQuery("c_field", "x")).must( hasParentQuery("parent", termQuery("p_field", "p_value2")).score(true))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).id(), Matchers.anyOf(equalTo("c3"), equalTo("c4"))); assertThat(searchResponse.getHits().getAt(1).id(), Matchers.anyOf(equalTo("c3"), equalTo("c4"))); } @@ -949,7 +949,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .setMinScore(3) // Score needs to be 3 or above! .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("p2")); assertThat(searchResponse.getHits().getAt(0).score(), equalTo(3.0f)); } @@ -1038,7 +1038,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue")))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); client().prepareIndex("test", "child", "c2").setParent("p2").setSource("c_field", "blue").get(); client().admin().indices().prepareRefresh("test").get(); @@ -1047,7 +1047,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "blue")))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); } private QueryBuilder randomHasChild(String type, String field, String value) { @@ -1107,7 +1107,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { ) ) ).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("grandissue").setQuery( boolQuery().must( @@ -1124,7 +1124,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { ) ) ).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testIndexChildDocWithNoParentMapping() throws IOException { @@ -1206,13 +1206,13 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .setQuery(boolQuery().must(QueryBuilders.hasChildQuery("child", termQuery("c_field", "blue")).scoreMode(scoreMode)).filter(boolQuery().mustNot(termQuery("p_field", "3")))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test") .setQuery(boolQuery().must(QueryBuilders.hasChildQuery("child", termQuery("c_field", "red")).scoreMode(scoreMode)).filter(boolQuery().mustNot(termQuery("p_field", "3")))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); } public void testNamedFilters() throws Exception { @@ -1228,25 +1228,25 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(hasChildQuery("child", termQuery("c_field", "1")).scoreMode(ScoreMode.Max).queryName("test")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("test")); searchResponse = client().prepareSearch("test").setQuery(hasParentQuery("parent", termQuery("p_field", "1")).score(true).queryName("test")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("test")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasChildQuery("child", termQuery("c_field", "1")).queryName("test"))) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("test")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(hasParentQuery("parent", termQuery("p_field", "1")).queryName("test"))) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("test")); } @@ -1363,7 +1363,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .must(QueryBuilders.hasChildQuery("child", matchQuery("c_field", "red"))) .must(matchAllQuery()))) .get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); } @@ -1376,7 +1376,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .must(matchAllQuery()))) .get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); } public void testParentChildQueriesViaScrollApi() throws Exception { @@ -1408,10 +1408,10 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .actionGet(); assertNoFailures(scrollResponse); - assertThat(scrollResponse.getHits().totalHits(), equalTo(10l)); + assertThat(scrollResponse.getHits().totalHits(), equalTo(10L)); int scannedDocs = 0; do { - assertThat(scrollResponse.getHits().totalHits(), equalTo(10l)); + assertThat(scrollResponse.getHits().totalHits(), equalTo(10L)); scannedDocs += scrollResponse.getHits().getHits().length; scrollResponse = client() .prepareSearchScroll(scrollResponse.getScrollId()) @@ -1456,7 +1456,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { .setQuery(multiMatchQuery("1", "_parent#type1")) .get(); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).id(), equalTo("1")); } @@ -1475,22 +1475,22 @@ public class ChildQuerySearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(hasParentQuery("parent", boolQuery().mustNot(termQuery("field1", "a"))))) .get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test") .setQuery(hasParentQuery("parent", constantScoreQuery(boolQuery().mustNot(termQuery("field1", "a"))))) .get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(hasParentQuery("parent", termQuery("field1", "a")))) .get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("test") .setQuery(hasParentQuery("parent", constantScoreQuery(termQuery("field1", "a")))) .get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } private List createMinMaxDocBuilders() { @@ -1562,7 +1562,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { // Score mode = NONE response = minMaxQuery(ScoreMode.None, 0, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("2")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1572,7 +1572,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.None, 1, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("2")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1582,7 +1582,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.None, 2, 0); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); assertThat(response.getHits().hits()[1].id(), equalTo("4")); @@ -1590,17 +1590,17 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.None, 3, 0); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); response = minMaxQuery(ScoreMode.None, 4, 0); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = minMaxQuery(ScoreMode.None, 0, 4); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("2")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1610,7 +1610,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.None, 0, 3); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("2")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1620,7 +1620,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.None, 0, 2); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("2")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1628,7 +1628,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.None, 2, 2); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(1f)); @@ -1642,7 +1642,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { // Score mode = SUM response = minMaxQuery(ScoreMode.Total, 0, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1652,7 +1652,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Total, 1, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1662,7 +1662,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Total, 2, 0); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1670,17 +1670,17 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Total, 3, 0); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); response = minMaxQuery(ScoreMode.Total, 4, 0); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = minMaxQuery(ScoreMode.Total, 0, 4); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1690,7 +1690,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Total, 0, 3); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(6f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1700,7 +1700,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Total, 0, 2); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); assertThat(response.getHits().hits()[1].id(), equalTo("2")); @@ -1708,7 +1708,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Total, 2, 2); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); @@ -1722,7 +1722,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { // Score mode = MAX response = minMaxQuery(ScoreMode.Max, 0, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1732,7 +1732,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Max, 1, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1742,7 +1742,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Max, 2, 0); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1750,17 +1750,17 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Max, 3, 0); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); response = minMaxQuery(ScoreMode.Max, 4, 0); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = minMaxQuery(ScoreMode.Max, 0, 4); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1770,7 +1770,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Max, 0, 3); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(3f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1780,7 +1780,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Max, 0, 2); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); assertThat(response.getHits().hits()[1].id(), equalTo("2")); @@ -1788,7 +1788,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Max, 2, 2); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); @@ -1802,7 +1802,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { // Score mode = AVG response = minMaxQuery(ScoreMode.Avg, 0, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1812,7 +1812,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Avg, 1, 0); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1822,7 +1822,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Avg, 2, 0); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1830,17 +1830,17 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Avg, 3, 0); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); response = minMaxQuery(ScoreMode.Avg, 4, 0); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); response = minMaxQuery(ScoreMode.Avg, 0, 4); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1850,7 +1850,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Avg, 0, 3); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().hits()[0].id(), equalTo("4")); assertThat(response.getHits().hits()[0].score(), equalTo(2f)); assertThat(response.getHits().hits()[1].id(), equalTo("3")); @@ -1860,7 +1860,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Avg, 0, 2); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(1.5f)); assertThat(response.getHits().hits()[1].id(), equalTo("2")); @@ -1868,7 +1868,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase { response = minMaxQuery(ScoreMode.Avg, 2, 2); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().hits()[0].id(), equalTo("3")); assertThat(response.getHits().hits()[0].score(), equalTo(1.5f)); diff --git a/core/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingIT.java b/core/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingIT.java index 1a4493a9832..0c7c069ec34 100644 --- a/core/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingIT.java +++ b/core/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingIT.java @@ -73,7 +73,7 @@ public class ParentFieldLoadingIT extends ESIntegTestCase { refresh(); ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L)); logger.info("testing default loading..."); assertAcked(client().admin().indices().prepareDelete("test").get()); @@ -88,7 +88,7 @@ public class ParentFieldLoadingIT extends ESIntegTestCase { refresh(); response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L)); logger.info("testing eager loading..."); assertAcked(client().admin().indices().prepareDelete("test").get()); @@ -103,7 +103,7 @@ public class ParentFieldLoadingIT extends ESIntegTestCase { refresh(); response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L)); logger.info("testing eager global ordinals loading..."); assertAcked(client().admin().indices().prepareDelete("test").get()); @@ -121,7 +121,7 @@ public class ParentFieldLoadingIT extends ESIntegTestCase { refresh(); response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); } public void testChangingEagerParentFieldLoadingAtRuntime() throws Exception { @@ -136,7 +136,7 @@ public class ParentFieldLoadingIT extends ESIntegTestCase { refresh(); ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), equalTo(0L)); PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("child") .setSource(childMapping(MappedFieldType.Loading.EAGER_GLOBAL_ORDINALS)) @@ -169,7 +169,7 @@ public class ParentFieldLoadingIT extends ESIntegTestCase { client().prepareIndex("test", "dummy", "dummy").setSource("{}").get(); refresh(); response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0l)); + assertThat(response.getIndicesStats().getFieldData().getMemorySizeInBytes(), greaterThan(0L)); } private XContentBuilder childMapping(MappedFieldType.Loading loading) throws IOException { diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java index 39ce61f6c73..3267b6b0c87 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/ExplainableScriptIT.java @@ -80,7 +80,7 @@ public class ExplainableScriptIT extends ESIntegTestCase { ElasticsearchAssertions.assertNoFailures(response); SearchHits hits = response.getHits(); - assertThat(hits.getTotalHits(), equalTo(20l)); + assertThat(hits.getTotalHits(), equalTo(20L)); int idCounter = 19; for (SearchHit hit : hits.getHits()) { assertThat(hit.getId(), equalTo(Integer.toString(idCounter))); diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java index 07f51772a7d..959adac3daf 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/QueryRescorerIT.java @@ -119,7 +119,7 @@ public class QueryRescorerIT extends ESIntegTestCase { RescoreBuilder.queryRescorer(QueryBuilders.matchPhraseQuery("field1", "quick brown").slop(2).boost(4.0f)) .setRescoreQueryWeight(2), 5).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getHits()[0].getId(), equalTo("1")); assertThat(searchResponse.getHits().getHits()[1].getId(), equalTo("3")); assertThat(searchResponse.getHits().getHits()[2].getId(), equalTo("2")); diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java index 14d620b9b99..651e1a8d1a5 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java @@ -109,7 +109,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() // from NY .setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); assertThat(searchResponse.getHits().hits().length, equalTo(2)); for (SearchHit hit : searchResponse.getHits()) { assertThat(hit.id(), anyOf(equalTo("1"), equalTo("3"), equalTo("5"))); @@ -118,7 +118,7 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { searchResponse = client().prepareSearch() // from NY .setQuery(geoBoundingBoxQuery("location").setCorners(40.73, -74.1, 40.717, -73.99).type("indexed")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); assertThat(searchResponse.getHits().hits().length, equalTo(2)); for (SearchHit hit : searchResponse.getHits()) { assertThat(hit.id(), anyOf(equalTo("1"), equalTo("3"), equalTo("5"))); @@ -182,52 +182,52 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(41, -11, 40, 9)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(41, -11, 40, 9).type("indexed")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(41, -9, 40, 11)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("3")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(41, -9, 40, 11).type("indexed")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("3")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(11, 171, 1, -169)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("5")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(11, 171, 1, -169).type("indexed")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("5")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(9, 169, -1, -171)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("9")); searchResponse = client().prepareSearch() .setQuery(geoBoundingBoxQuery("location").setCorners(9, 169, -1, -171).type("indexed")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("9")); } @@ -265,26 +265,26 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { boolQuery().must(termQuery("userid", 880)).filter( geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875)) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( boolQuery().must(termQuery("userid", 880)).filter( geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875).type("indexed")) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( boolQuery().must(termQuery("userid", 534)).filter( geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875)) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( boolQuery().must(termQuery("userid", 534)).filter( geoBoundingBoxQuery("location").setCorners(74.579421999999994, 143.5, -66.668903999999998, 113.96875).type("indexed")) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); } public void testCompleteLonRange() throws Exception { @@ -319,43 +319,43 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, -180, -50, 180).type("indexed") ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, -180, -90, 180).type("indexed") ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(50, 0, -50, 360).type("indexed") ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360) ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); searchResponse = client().prepareSearch() .setQuery( geoBoundingBoxQuery("location").setValidationMethod(GeoValidationMethod.COERCE).setCorners(90, 0, -90, 360).type("indexed") ).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); } } diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java index c6f05ee23a2..7afbeaa9abf 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java @@ -104,7 +104,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); assertSearchResponse(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); @@ -113,7 +113,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); assertSearchResponse(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); } @@ -150,7 +150,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); assertSearchResponse(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("blakely")); } @@ -183,7 +183,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); assertSearchResponse(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); @@ -192,7 +192,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); assertSearchResponse(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); } diff --git a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java index fc7a779b407..eaad1536e24 100644 --- a/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchIT.java @@ -1659,7 +1659,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .get(); // Highlighting of numeric fields is not supported, but it should not raise errors // (this behavior is consistent with version 0.20) - assertHitCount(response, 1l); + assertHitCount(response, 1L); } // Issue #3200 @@ -1680,7 +1680,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .setQuery(QueryBuilders.matchQuery("text", "test").type(MatchQuery.Type.BOOLEAN)) .highlighter(new HighlightBuilder().field("text")).execute().actionGet(); // PatternAnalyzer will throw an exception if it is resetted twice - assertHitCount(response, 1l); + assertHitCount(response, 1L); } public void testHighlightUsesHighlightQuery() throws IOException { @@ -2118,7 +2118,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .field(new HighlightBuilder.Field("field1").numOfFragments(0).preTags("").postTags(""))); searchResponse = client().search(searchRequest("test").source(source)).actionGet(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); for (SearchHit searchHit : searchResponse.getHits()) { if ("1".equals(searchHit.id())) { @@ -2167,7 +2167,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .field(new Field("field1").requireFieldMatch(true).preTags("").postTags(""))); logger.info("Running multi-match type: [" + matchQueryType + "] highlight with type: [" + highlighterType + "]"); SearchResponse searchResponse = client().search(searchRequest("test").source(source)).actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertHighlight(searchResponse, 0, "field1", 0, anyOf(equalTo("The quick brown fox jumps over"), equalTo("The quick brown fox jumps over"))); } @@ -2240,7 +2240,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { .setQuery(matchQuery("title", "This is a Test")) .highlighter(new HighlightBuilder().field("title")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); SearchHit hit = searchResponse.getHits().getAt(0); //stopwords are not highlighted since not indexed assertHighlight(hit, "title", 0, 1, equalTo("this is a test .")); @@ -2249,7 +2249,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { searchResponse = client().prepareSearch() .setQuery(matchQuery("title.key", "this is a test")) .highlighter(new HighlightBuilder().field("title.key")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); //stopwords are now highlighted since we used only whitespace analyzer here assertHighlight(searchResponse, 0, "title.key", 0, 1, equalTo("this is a test .")); @@ -2349,7 +2349,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { SearchSourceBuilder source = searchSource().query(commonTermsQuery("field2", "quick brown").cutoffFrequency(100)) .highlighter(highlight().field("field2").preTags("").postTags("")); SearchResponse searchResponse = client().search(searchRequest("test").source(source)).actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The quick brown fox jumps over the lazy dog!")); } @@ -2423,7 +2423,7 @@ public class HighlighterSearchIT extends ESIntegTestCase { source = searchSource().query(wildcardQuery("field2", "qu*k")) .highlighter(highlight().field("field2")); searchResponse = client().prepareSearch("test").setSource(source).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertHighlight(searchResponse, 0, "field2", 0, 1, equalTo("The quick brown fox jumps over the lazy dog!")); } diff --git a/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java b/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java index f9245a3d981..606e9a18f2d 100644 --- a/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/indicesboost/SimpleIndicesBoostSearchIT.java @@ -63,7 +63,7 @@ public class SimpleIndicesBoostSearchIT extends ESIntegTestCase { .source(searchSource().explain(true).indexBoost("test1", indexBoost).query(termQuery("test", "value"))) ).actionGet(); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); logger.info("Hit[0] {} Explanation {}", response.getHits().getAt(0).index(), response.getHits().getAt(0).explanation()); logger.info("Hit[1] {} Explanation {}", response.getHits().getAt(1).index(), response.getHits().getAt(1).explanation()); assertThat(response.getHits().getAt(0).index(), equalTo("test1")); @@ -75,7 +75,7 @@ public class SimpleIndicesBoostSearchIT extends ESIntegTestCase { .source(searchSource().explain(true).indexBoost("test2", indexBoost).query(termQuery("test", "value"))) ).actionGet(); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); logger.info("Hit[0] {} Explanation {}", response.getHits().getAt(0).index(), response.getHits().getAt(0).explanation()); logger.info("Hit[1] {} Explanation {}", response.getHits().getAt(1).index(), response.getHits().getAt(1).explanation()); assertThat(response.getHits().getAt(0).index(), equalTo("test2")); @@ -89,7 +89,7 @@ public class SimpleIndicesBoostSearchIT extends ESIntegTestCase { .source(searchSource().explain(true).indexBoost("test1", indexBoost).query(termQuery("test", "value"))) ).actionGet(); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); logger.info("Hit[0] {} Explanation {}", response.getHits().getAt(0).index(), response.getHits().getAt(0).explanation()); logger.info("Hit[1] {} Explanation {}", response.getHits().getAt(1).index(), response.getHits().getAt(1).explanation()); assertThat(response.getHits().getAt(0).index(), equalTo("test1")); @@ -101,7 +101,7 @@ public class SimpleIndicesBoostSearchIT extends ESIntegTestCase { .source(searchSource().explain(true).indexBoost("test2", indexBoost).query(termQuery("test", "value"))) ).actionGet(); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); logger.info("Hit[0] {} Explanation {}", response.getHits().getAt(0).index(), response.getHits().getAt(0).explanation()); logger.info("Hit[1] {} Explanation {}", response.getHits().getAt(1).index(), response.getHits().getAt(1).explanation()); assertThat(response.getHits().getAt(0).index(), equalTo("test2")); diff --git a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java index 1374d36ef3b..05ff048b420 100644 --- a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java @@ -128,7 +128,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertSearchHit(response, 1, hasId("1")); assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(2l)); + assertThat(innerHits.totalHits(), equalTo(2L)); assertThat(innerHits.getHits().length, equalTo(2)); assertThat(innerHits.getAt(0).getId(), equalTo("1")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); @@ -160,7 +160,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getShard(), notNullValue()); assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(3l)); + assertThat(innerHits.totalHits(), equalTo(3L)); assertThat(innerHits.getHits().length, equalTo(3)); assertThat(innerHits.getAt(0).getId(), equalTo("2")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); @@ -198,7 +198,7 @@ public class InnerHitsIT extends ESIntegTestCase { SearchResponse response = client().search(searchRequest).actionGet(); assertNoFailures(response); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comments"); - assertThat(innerHits.getTotalHits(), equalTo(2l)); + assertThat(innerHits.getTotalHits(), equalTo(2L)); assertThat(innerHits.getHits().length, equalTo(1)); assertThat(innerHits.getAt(0).getHighlightFields().get("comments.message").getFragments()[0].string(), equalTo("fox eat quick")); assertThat(innerHits.getAt(0).explanation().toString(), containsString("weight(comments.message:fox in")); @@ -320,7 +320,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(2l)); + assertThat(innerHits.totalHits(), equalTo(2L)); assertThat(innerHits.getAt(0).getId(), equalTo("1")); assertThat(innerHits.getAt(0).type(), equalTo("comment")); @@ -347,7 +347,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(3l)); + assertThat(innerHits.totalHits(), equalTo(3L)); assertThat(innerHits.getAt(0).getId(), equalTo("4")); assertThat(innerHits.getAt(0).type(), equalTo("comment")); @@ -530,14 +530,14 @@ public class InnerHitsIT extends ESIntegTestCase { SearchHit searchHit = response.getHits().getAt(0); assertThat(searchHit.getId(), equalTo("1")); assertThat(searchHit.getType(), equalTo("answer")); - assertThat(searchHit.getInnerHits().get("question").getTotalHits(), equalTo(1l)); + assertThat(searchHit.getInnerHits().get("question").getTotalHits(), equalTo(1L)); assertThat(searchHit.getInnerHits().get("question").getAt(0).getType(), equalTo("question")); assertThat(searchHit.getInnerHits().get("question").getAt(0).id(), equalTo("1")); searchHit = response.getHits().getAt(1); assertThat(searchHit.getId(), equalTo("2")); assertThat(searchHit.getType(), equalTo("answer")); - assertThat(searchHit.getInnerHits().get("question").getTotalHits(), equalTo(1l)); + assertThat(searchHit.getInnerHits().get("question").getTotalHits(), equalTo(1L)); assertThat(searchHit.getInnerHits().get("question").getAt(0).getType(), equalTo("question")); assertThat(searchHit.getInnerHits().get("question").getAt(0).id(), equalTo("2")); } @@ -575,12 +575,12 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getAt(0).getId(), equalTo("1")); assertThat(innerHits.getAt(0).type(), equalTo("comment")); innerHits = innerHits.getAt(0).getInnerHits().get("remark"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getAt(0).getId(), equalTo("1")); assertThat(innerHits.getAt(0).type(), equalTo("remark")); @@ -601,12 +601,12 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getAt(0).getId(), equalTo("2")); assertThat(innerHits.getAt(0).type(), equalTo("comment")); innerHits = innerHits.getAt(0).getInnerHits().get("remark"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getAt(0).getId(), equalTo("2")); assertThat(innerHits.getAt(0).type(), equalTo("remark")); } @@ -668,13 +668,13 @@ public class InnerHitsIT extends ESIntegTestCase { assertSearchHit(response, 1, hasId("1")); assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getHits().length, equalTo(1)); assertThat(innerHits.getAt(0).getId(), equalTo("1")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(innerHits.getAt(0).getNestedIdentity().getOffset(), equalTo(0)); innerHits = innerHits.getAt(0).getInnerHits().get("remark"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getHits().length, equalTo(1)); assertThat(innerHits.getAt(0).getId(), equalTo("1")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); @@ -691,7 +691,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertSearchHit(response, 1, hasId("2")); assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); innerHits = response.getHits().getAt(0).getInnerHits().get("comments.remarks"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getHits().length, equalTo(1)); assertThat(innerHits.getAt(0).getId(), equalTo("2")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); @@ -714,13 +714,13 @@ public class InnerHitsIT extends ESIntegTestCase { assertSearchHit(response, 1, hasId("2")); assertThat(response.getHits().getAt(0).getInnerHits().size(), equalTo(1)); innerHits = response.getHits().getAt(0).getInnerHits().get("comment"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getHits().length, equalTo(1)); assertThat(innerHits.getAt(0).getId(), equalTo("2")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(innerHits.getAt(0).getNestedIdentity().getOffset(), equalTo(0)); innerHits = innerHits.getAt(0).getInnerHits().get("remark"); - assertThat(innerHits.totalHits(), equalTo(1l)); + assertThat(innerHits.totalHits(), equalTo(1L)); assertThat(innerHits.getHits().length, equalTo(1)); assertThat(innerHits.getAt(0).getId(), equalTo("2")); assertThat(innerHits.getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); @@ -746,7 +746,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -783,7 +783,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -822,7 +822,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -861,7 +861,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -899,7 +899,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getField().string(), equalTo("comments")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -940,7 +940,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getField().string(), equalTo("comments.messages")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -952,7 +952,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getField().string(), equalTo("comments.messages")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getOffset(), equalTo(1)); @@ -971,7 +971,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertNoFailures(response); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).id(), equalTo("1")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getField().string(), equalTo("comments.messages")); assertThat(response.getHits().getAt(0).getInnerHits().get("comments.messages").getAt(0).getNestedIdentity().getOffset(), equalTo(0)); @@ -1024,34 +1024,34 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(response.getHits().getAt(0).getId(), equalTo("duke")); SearchHits innerHits = response.getHits().getAt(0).getInnerHits().get("earls"); - assertThat(innerHits.getTotalHits(), equalTo(4l)); + assertThat(innerHits.getTotalHits(), equalTo(4L)); assertThat(innerHits.getAt(0).getId(), equalTo("earl1")); assertThat(innerHits.getAt(1).getId(), equalTo("earl2")); assertThat(innerHits.getAt(2).getId(), equalTo("earl3")); assertThat(innerHits.getAt(3).getId(), equalTo("earl4")); SearchHits innerInnerHits = innerHits.getAt(0).getInnerHits().get("barons"); - assertThat(innerInnerHits.totalHits(), equalTo(1l)); + assertThat(innerInnerHits.totalHits(), equalTo(1L)); assertThat(innerInnerHits.getAt(0).getId(), equalTo("baron1")); innerInnerHits = innerHits.getAt(1).getInnerHits().get("barons"); - assertThat(innerInnerHits.totalHits(), equalTo(1l)); + assertThat(innerInnerHits.totalHits(), equalTo(1L)); assertThat(innerInnerHits.getAt(0).getId(), equalTo("baron2")); innerInnerHits = innerHits.getAt(2).getInnerHits().get("barons"); - assertThat(innerInnerHits.totalHits(), equalTo(1l)); + assertThat(innerInnerHits.totalHits(), equalTo(1L)); assertThat(innerInnerHits.getAt(0).getId(), equalTo("baron3")); innerInnerHits = innerHits.getAt(3).getInnerHits().get("barons"); - assertThat(innerInnerHits.totalHits(), equalTo(1l)); + assertThat(innerInnerHits.totalHits(), equalTo(1L)); assertThat(innerInnerHits.getAt(0).getId(), equalTo("baron4")); innerHits = response.getHits().getAt(0).getInnerHits().get("princes"); - assertThat(innerHits.getTotalHits(), equalTo(1l)); + assertThat(innerHits.getTotalHits(), equalTo(1L)); assertThat(innerHits.getAt(0).getId(), equalTo("prince")); innerInnerHits = innerHits.getAt(0).getInnerHits().get("kings"); - assertThat(innerInnerHits.totalHits(), equalTo(1l)); + assertThat(innerInnerHits.totalHits(), equalTo(1L)); assertThat(innerInnerHits.getAt(0).getId(), equalTo("king")); } @@ -1132,7 +1132,7 @@ public class InnerHitsIT extends ESIntegTestCase { assertAllSuccessful(searchResponse); assertThat(searchResponse.getHits().totalHits(), equalTo((long) numDocs)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("0")); - assertThat(searchResponse.getHits().getAt(0).getInnerHits().get("nested1").getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getAt(0).getInnerHits().get("nested1").getTotalHits(), equalTo(2L)); assertThat(searchResponse.getHits().getAt(0).getInnerHits().get("nested1").getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).getInnerHits().get("nested1").getAt(0).getMatchedQueries()[0], equalTo("test1")); assertThat(searchResponse.getHits().getAt(0).getInnerHits().get("nested1").getAt(1).getMatchedQueries().length, equalTo(1)); @@ -1140,13 +1140,13 @@ public class InnerHitsIT extends ESIntegTestCase { assertThat(searchResponse.getHits().getAt(1).id(), equalTo("1")); - assertThat(searchResponse.getHits().getAt(1).getInnerHits().get("nested1").getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(1).getInnerHits().get("nested1").getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(1).getInnerHits().get("nested1").getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(1).getInnerHits().get("nested1").getAt(0).getMatchedQueries()[0], equalTo("test2")); for (int i = 2; i < numDocs; i++) { assertThat(searchResponse.getHits().getAt(i).id(), equalTo(String.valueOf(i))); - assertThat(searchResponse.getHits().getAt(i).getInnerHits().get("nested1").getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(i).getInnerHits().get("nested1").getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(i).getInnerHits().get("nested1").getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(i).getInnerHits().get("nested1").getAt(0).getMatchedQueries()[0], equalTo("test3")); } @@ -1168,12 +1168,12 @@ public class InnerHitsIT extends ESIntegTestCase { .get(); assertHitCount(response, 2); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("child").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("child").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("child").getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(response.getHits().getAt(0).getInnerHits().get("child").getAt(0).getMatchedQueries()[0], equalTo("_name1")); assertThat(response.getHits().getAt(1).id(), equalTo("2")); - assertThat(response.getHits().getAt(1).getInnerHits().get("child").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(1).getInnerHits().get("child").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(1).getInnerHits().get("child").getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(response.getHits().getAt(1).getInnerHits().get("child").getAt(0).getMatchedQueries()[0], equalTo("_name1")); @@ -1183,7 +1183,7 @@ public class InnerHitsIT extends ESIntegTestCase { .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).id(), equalTo("1")); - assertThat(response.getHits().getAt(0).getInnerHits().get("child").getTotalHits(), equalTo(1l)); + assertThat(response.getHits().getAt(0).getInnerHits().get("child").getTotalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getInnerHits().get("child").getAt(0).getMatchedQueries().length, equalTo(1)); assertThat(response.getHits().getAt(0).getInnerHits().get("child").getAt(0).getMatchedQueries()[0], equalTo("_name2")); } diff --git a/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java b/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java index 4daa45fe391..f5427ca6778 100644 --- a/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java +++ b/core/src/test/java/org/elasticsearch/search/matchedqueries/MatchedQueriesIT.java @@ -54,7 +54,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(boolQuery().must(matchAllQuery()).filter(boolQuery().should(rangeQuery("number").lte(2).queryName("test1")).should(rangeQuery("number").gt(2).queryName("test2")))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1") || hit.id().equals("2")) { assertThat(hit.matchedQueries().length, equalTo(1)); @@ -69,7 +69,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { searchResponse = client().prepareSearch() .setQuery(boolQuery().should(rangeQuery("number").lte(2).queryName("test1")).should(rangeQuery("number").gt(2).queryName("test2"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1") || hit.id().equals("2")) { assertThat(hit.matchedQueries().length, equalTo(1)); @@ -97,7 +97,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { .setPostFilter(boolQuery().should( termQuery("name", "test").queryName("name")).should( termQuery("title", "title1").queryName("title"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { assertThat(hit.matchedQueries().length, equalTo(2)); @@ -117,7 +117,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { .should(termQuery("name", "test").queryName("name")) .should(termQuery("title", "title1").queryName("title"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { assertThat(hit.matchedQueries().length, equalTo(2)); @@ -144,7 +144,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(boolQuery().must(matchAllQuery()).filter(termsQuery("title", "title1", "title2", "title3").queryName("title"))) .setPostFilter(termQuery("name", "test").queryName("name")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1") || hit.id().equals("2") || hit.id().equals("3")) { assertThat(hit.matchedQueries().length, equalTo(2)); @@ -158,7 +158,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { searchResponse = client().prepareSearch() .setQuery(termsQuery("title", "title1", "title2", "title3").queryName("title")) .setPostFilter(matchQuery("name", "test").queryName("name")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1") || hit.id().equals("2") || hit.id().equals("3")) { assertThat(hit.matchedQueries().length, equalTo(2)); @@ -185,7 +185,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { indicesQuery(termQuery("title", "title1").queryName("title1"), "test1") .noMatchQuery(termQuery("title", "title2").queryName("title2")).queryName("indices_filter")).should( termQuery("title", "title3").queryName("title3")).queryName("or"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { @@ -217,7 +217,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(QueryBuilders.regexpQuery("title", "title1").queryName("regex")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { @@ -238,7 +238,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(QueryBuilders.prefixQuery("title", "title").queryName("prefix")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { @@ -260,7 +260,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(QueryBuilders.fuzzyQuery("title", "titel1").queryName("fuzzy")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { @@ -281,7 +281,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(QueryBuilders.wildcardQuery("title", "titl*").queryName("wildcard")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { @@ -302,7 +302,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(QueryBuilders.spanFirstQuery(QueryBuilders.spanTermQuery("title", "title1"), 10).queryName("span")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { @@ -338,7 +338,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { .setPreference("_primary") .get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); for (SearchHit hit : searchResponse.getHits()) { if (hit.id().equals("1")) { assertThat(hit.matchedQueries().length, equalTo(1)); @@ -368,7 +368,7 @@ public class MatchedQueriesIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(query) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("abc")); } } diff --git a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java index ae163eaf4a6..40608134fc6 100644 --- a/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java +++ b/core/src/test/java/org/elasticsearch/search/morelikethis/MoreLikeThisIT.java @@ -79,7 +79,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Running moreLikeThis"); SearchResponse response = client().prepareSearch().setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); } public void testSimpleMoreLikeOnLongField() throws Exception { @@ -89,7 +89,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); logger.info("Indexing..."); - client().index(indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("some_long", 1367484649580l).endObject())).actionGet(); + client().index(indexRequest("test").type("type1").id("1").source(jsonBuilder().startObject().field("some_long", 1367484649580L).endObject())).actionGet(); client().index(indexRequest("test").type("type2").id("2").source(jsonBuilder().startObject().field("some_long", 0).endObject())).actionGet(); client().index(indexRequest("test").type("type1").id("3").source(jsonBuilder().startObject().field("some_long", -666).endObject())).actionGet(); @@ -98,7 +98,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Running moreLikeThis"); SearchResponse response = client().prepareSearch().setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(response, 0l); + assertHitCount(response, 0L); } public void testMoreLikeThisWithAliases() throws Exception { @@ -124,24 +124,24 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Running moreLikeThis on index"); SearchResponse response = client().prepareSearch().setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(response, 2l); + assertHitCount(response, 2L); logger.info("Running moreLikeThis on beta shard"); response = client().prepareSearch("beta").setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); assertThat(response.getHits().getAt(0).id(), equalTo("3")); logger.info("Running moreLikeThis on release shard"); response = client().prepareSearch("release").setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); assertThat(response.getHits().getAt(0).id(), equalTo("2")); logger.info("Running moreLikeThis on alias with node client"); response = internalCluster().clientNodeClient().prepareSearch("beta").setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type1", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); assertThat(response.getHits().getAt(0).id(), equalTo("3")); } @@ -234,7 +234,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { // Implicit list of fields -> ignore numeric fields SearchResponse searchResponse = client().prepareSearch().setQuery( new MoreLikeThisQueryBuilder(null, new Item[] {new Item("test", "type", "1")}).minTermFreq(1).minDocFreq(1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); // Explicit list of fields including numeric fields -> fail assertThrows(client().prepareSearch().setQuery( @@ -242,11 +242,11 @@ public class MoreLikeThisIT extends ESIntegTestCase { // mlt query with no field -> OK searchResponse = client().prepareSearch().setQuery(moreLikeThisQuery(new String[] {"index"}).minTermFreq(1).minDocFreq(1)).execute().actionGet(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); // mlt query with string fields searchResponse = client().prepareSearch().setQuery(moreLikeThisQuery(new String[]{"string_value"}, new String[] {"index"}, null).minTermFreq(1).minDocFreq(1)).execute().actionGet(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); // mlt query with at least a numeric field -> fail by default assertThrows(client().prepareSearch().setQuery(moreLikeThisQuery(new String[] {"string_value", "int_value"}, new String[] {"index"}, null)), SearchPhaseExecutionException.class); @@ -257,7 +257,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { // mlt query with at least a numeric field but fail_on_unsupported_field set to false searchResponse = client().prepareSearch().setQuery(moreLikeThisQuery(new String[] {"string_value", "int_value"}, new String[] {"index"}, null).minTermFreq(1).minDocFreq(1).failOnUnsupportedField(false)).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); // mlt field query on a numeric field -> failure by default assertThrows(client().prepareSearch().setQuery(moreLikeThisQuery(new String[] {"int_value"}, new String[] {"42"}, null).minTermFreq(1).minDocFreq(1)), SearchPhaseExecutionException.class); @@ -268,7 +268,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { // mlt field query on a numeric field but fail_on_unsupported_field set to false searchResponse = client().prepareSearch().setQuery(moreLikeThisQuery(new String[] {"int_value"}, new String[] {"42"}, null).minTermFreq(1).minDocFreq(1).failOnUnsupportedField(false)).execute().actionGet(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testSimpleMoreLikeInclude() throws Exception { @@ -327,7 +327,7 @@ public class MoreLikeThisIT extends ESIntegTestCase { logger.info("Running MoreLikeThis"); MoreLikeThisQueryBuilder queryBuilder = QueryBuilders.moreLikeThisQuery(new String[] {"text"}, null, ids("1")).include(true).minTermFreq(1).minDocFreq(1); SearchResponse mltResponse = client().prepareSearch().setTypes("type1").setQuery(queryBuilder).execute().actionGet(); - assertHitCount(mltResponse, 3l); + assertHitCount(mltResponse, 3L); } public void testSimpleMoreLikeThisIdsMultipleTypes() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java b/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java index c7454a5c8b6..d3ee811be23 100644 --- a/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/msearch/SimpleMultiSearchIT.java @@ -48,9 +48,9 @@ public class SimpleMultiSearchIT extends ESIntegTestCase { assertNoFailures(item.getResponse()); } assertThat(response.getResponses().length, equalTo(3)); - assertHitCount(response.getResponses()[0].getResponse(), 1l); - assertHitCount(response.getResponses()[1].getResponse(), 1l); - assertHitCount(response.getResponses()[2].getResponse(), 2l); + assertHitCount(response.getResponses()[0].getResponse(), 1L); + assertHitCount(response.getResponses()[1].getResponse(), 1L); + assertHitCount(response.getResponses()[2].getResponse(), 2L); assertFirstHit(response.getResponses()[0].getResponse(), hasId("1")); assertFirstHit(response.getResponses()[1].getResponse(), hasId("2")); } diff --git a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java index 23eafdb0b01..f9bae6a1c90 100644 --- a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java @@ -59,9 +59,9 @@ public class SimpleNestedIT extends ESIntegTestCase { // check on no data, see it works SearchResponse searchResponse = client().prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); searchResponse = client().prepareSearch("test").setQuery(termQuery("n_field1", "n_value1_1")).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject() .field("field1", "value1") @@ -89,24 +89,24 @@ public class SimpleNestedIT extends ESIntegTestCase { // check that _all is working on nested docs searchResponse = client().prepareSearch("test").setQuery(termQuery("_all", "n_value1_1")).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(termQuery("n_field1", "n_value1_1")).execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); // search for something that matches the nested doc, and see that we don't find the nested doc searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(termQuery("n_field1", "n_value1_1")).get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); // now, do a nested query searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).setSearchType(SearchType.DFS_QUERY_THEN_FETCH).get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); // add another doc, one that would match if it was not nested... @@ -131,19 +131,19 @@ public class SimpleNestedIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1")))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); // filter searchResponse = client().prepareSearch("test").setQuery(boolQuery().must(matchAllQuery()).mustNot(nestedQuery("nested1", boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); // check with type prefix searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.n_field1", "n_value1_1")).must(termQuery("nested1.n_field2", "n_value2_1")))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); // check delete, so all is gone... DeleteResponse deleteResponse = client().prepareDelete("test", "type1", "2").execute().actionGet(); @@ -155,11 +155,11 @@ public class SimpleNestedIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setTypes("type1", "type2").setQuery(nestedQuery("nested1", termQuery("nested1.n_field1", "n_value1_1"))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); } public void testMultiNested() throws Exception { @@ -193,42 +193,42 @@ public class SimpleNestedIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", termQuery("nested1.field1", "1"))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "2"))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "2"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "3"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "4"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.field1", "1")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "5"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.field1", "4")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "5"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch("test").setQuery(nestedQuery("nested1", boolQuery().must(termQuery("nested1.field1", "4")).must(nestedQuery("nested1.nested2", termQuery("nested1.nested2.field2", "2"))))).execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(0L)); } // When IncludeNestedDocsQuery is wrapped in a FilteredQuery then a in-finite loop occurs b/c of a bug in IncludeNestedDocsQuery#advance() @@ -314,7 +314,7 @@ public class SimpleNestedIT extends ESIntegTestCase { .setExplain(true) .execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); Explanation explanation = searchResponse.getHits().hits()[0].explanation(); assertThat(explanation.getValue(), equalTo(2f)); assertThat(explanation.toString(), startsWith("2.0 = sum of:\n 2.0 = Score based on child doc range from 0 to 1\n")); @@ -531,96 +531,96 @@ public class SimpleNestedIT extends ESIntegTestCase { // sum: 11 client().prepareIndex("test", "type1", Integer.toString(1)).setSource(jsonBuilder().startObject() - .field("grand_parent_values", 1l) + .field("grand_parent_values", 1L) .startObject("parent") .field("filter", false) - .field("parent_values", 1l) + .field("parent_values", 1L) .startObject("child") .field("filter", true) - .field("child_values", 1l) + .field("child_values", 1L) .startObject("child_obj") - .field("value", 1l) + .field("value", 1L) .endObject() .endObject() .startObject("child") .field("filter", false) - .field("child_values", 6l) + .field("child_values", 6L) .endObject() .endObject() .startObject("parent") .field("filter", true) - .field("parent_values", 2l) + .field("parent_values", 2L) .startObject("child") .field("filter", false) - .field("child_values", -1l) + .field("child_values", -1L) .endObject() .startObject("child") .field("filter", false) - .field("child_values", 5l) + .field("child_values", 5L) .endObject() .endObject() .endObject()).execute().actionGet(); // sum: 7 client().prepareIndex("test", "type1", Integer.toString(2)).setSource(jsonBuilder().startObject() - .field("grand_parent_values", 2l) + .field("grand_parent_values", 2L) .startObject("parent") .field("filter", false) - .field("parent_values", 2l) + .field("parent_values", 2L) .startObject("child") .field("filter", true) - .field("child_values", 2l) + .field("child_values", 2L) .startObject("child_obj") - .field("value", 2l) + .field("value", 2L) .endObject() .endObject() .startObject("child") .field("filter", false) - .field("child_values", 4l) + .field("child_values", 4L) .endObject() .endObject() .startObject("parent") - .field("parent_values", 3l) + .field("parent_values", 3L) .field("filter", true) .startObject("child") - .field("child_values", -2l) + .field("child_values", -2L) .field("filter", false) .endObject() .startObject("child") .field("filter", false) - .field("child_values", 3l) + .field("child_values", 3L) .endObject() .endObject() .endObject()).execute().actionGet(); // sum: 2 client().prepareIndex("test", "type1", Integer.toString(3)).setSource(jsonBuilder().startObject() - .field("grand_parent_values", 3l) + .field("grand_parent_values", 3L) .startObject("parent") - .field("parent_values", 3l) + .field("parent_values", 3L) .field("filter", false) .startObject("child") .field("filter", true) - .field("child_values", 3l) + .field("child_values", 3L) .startObject("child_obj") - .field("value", 3l) + .field("value", 3L) .endObject() .endObject() .startObject("child") .field("filter", false) - .field("child_values", 1l) + .field("child_values", 1L) .endObject() .endObject() .startObject("parent") - .field("parent_values", 4l) + .field("parent_values", 4L) .field("filter", true) .startObject("child") .field("filter", false) - .field("child_values", -3l) + .field("child_values", -3L) .endObject() .startObject("child") .field("filter", false) - .field("child_values", 1l) + .field("child_values", 1L) .endObject() .endObject() .endObject()).execute().actionGet(); @@ -1019,7 +1019,7 @@ public class SimpleNestedIT extends ESIntegTestCase { // No nested mapping yet, there shouldn't be anything in the fixed bit set cache ClusterStatsResponse clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); - assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0l)); + assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); // Now add nested mapping assertAcked( @@ -1040,21 +1040,21 @@ public class SimpleNestedIT extends ESIntegTestCase { if (loadFixedBitSeLazily) { clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); - assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0l)); + assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); // only when querying with nested the fixed bitsets are loaded SearchResponse searchResponse = client().prepareSearch("test") .setQuery(nestedQuery("array1", termQuery("array1.field1", "value1"))) .get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(5l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(5L)); } clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); - assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), greaterThan(0l)); + assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), greaterThan(0L)); assertAcked(client().admin().indices().prepareDelete("test")); clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); - assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0l)); + assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); } /** diff --git a/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java b/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java index fa9626964e8..7b34aec9bd0 100644 --- a/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java +++ b/core/src/test/java/org/elasticsearch/search/preference/SearchPreferenceIT.java @@ -95,29 +95,29 @@ public class SearchPreferenceIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_local").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_local").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_primary").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_primary").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_replica").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_replica").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_replica_first").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_replica_first").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("1234").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setPreference("1234").execute().actionGet(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); } public void testReplicaPreference() throws Exception { @@ -135,13 +135,13 @@ public class SearchPreferenceIT extends ESIntegTestCase { } SearchResponse resp = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_replica_first").execute().actionGet(); - assertThat(resp.getHits().totalHits(), equalTo(1l)); + assertThat(resp.getHits().totalHits(), equalTo(1L)); client().admin().indices().prepareUpdateSettings("test").setSettings("number_of_replicas=1").get(); ensureGreen("test"); resp = client().prepareSearch().setQuery(matchAllQuery()).setPreference("_replica").execute().actionGet(); - assertThat(resp.getHits().totalHits(), equalTo(1l)); + assertThat(resp.getHits().totalHits(), equalTo(1L)); } public void testThatSpecifyingNonExistingNodesReturnsUsefulError() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java index 1cbdf60a4a4..6ad4d990dee 100644 --- a/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java @@ -197,13 +197,13 @@ public class MultiMatchQueryIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category") .operator(Operator.AND).type(type))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category") .operator(Operator.AND).type(type))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); } @@ -212,18 +212,18 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .setQuery(randomizeType(multiMatchQuery("Man the Ultimate", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase") .operator(Operator.OR).type(MatchQuery.Type.PHRASE))).get(); assertFirstHit(searchResponse, hasId("ultimate2")); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("Captain", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase") .operator(Operator.OR).type(MatchQuery.Type.PHRASE))).get(); - assertThat(searchResponse.getHits().getTotalHits(), greaterThan(1l)); + assertThat(searchResponse.getHits().getTotalHits(), greaterThan(1L)); searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("the Ul", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase") .operator(Operator.OR).type(MatchQuery.Type.PHRASE_PREFIX))).get(); assertSearchHits(searchResponse, "ultimate2", "ultimate1"); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } public void testSingleField() throws NoSuchFieldException, IllegalAccessException { @@ -318,13 +318,13 @@ public class MultiMatchQueryIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category") .operator(Operator.AND).cutoffFrequency(cutoffFrequency).type(type))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category") .operator(Operator.AND).cutoffFrequency(cutoffFrequency).type(type))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); searchResponse = client().prepareSearch("test") @@ -332,7 +332,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .operator(Operator.AND).cutoffFrequency(cutoffFrequency) .analyzer("category") .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theother")); } @@ -455,7 +455,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category") .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS) .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); searchResponse = client().prepareSearch("test") @@ -463,7 +463,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS) .analyzer("category") .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); searchResponse = client().prepareSearch("test") @@ -471,7 +471,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS) .analyzer("category") .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); searchResponse = client().prepareSearch("test") @@ -479,7 +479,7 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS) .analyzer("category") .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); @@ -549,21 +549,21 @@ public class MultiMatchQueryIT extends ESIntegTestCase { .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS) .analyzer("category") .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("theone")); // counter example searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category") .type(randomBoolean() ? MultiMatchQueryBuilder.Type.CROSS_FIELDS : MultiMatchQueryBuilder.DEFAULT_TYPE) .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); // counter example searchResponse = client().prepareSearch("test") .setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category") .type(randomBoolean() ? MultiMatchQueryBuilder.Type.CROSS_FIELDS : MultiMatchQueryBuilder.DEFAULT_TYPE) .operator(Operator.AND))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); // test if boosts work searchResponse = client().prepareSearch("test") diff --git a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java index d723c88535a..faa6b62d2ad 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -129,7 +129,7 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("field1", "quick brown"), client().prepareIndex("test", "type1", "3").setSource("field1", "quick")); - assertHitCount(client().prepareSearch().setQuery(matchQuery("_all", "quick")).get(), 3l); + assertHitCount(client().prepareSearch().setQuery(matchQuery("_all", "quick")).get(), 3L); SearchResponse searchResponse = client().prepareSearch().setQuery(matchQuery("_all", "quick")).setExplain(true).get(); SearchHit[] hits = searchResponse.getHits().hits(); assertThat(hits.length, equalTo(3)); @@ -141,7 +141,7 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("field1", "quick brown"), client().prepareIndex("test", "type1", "3").setSource("field1", "quick")); - assertHitCount(client().prepareSearch().setQuery(matchQuery("_all", "quick")).get(), 3l); + assertHitCount(client().prepareSearch().setQuery(matchQuery("_all", "quick")).get(), 3L); searchResponse = client().prepareSearch().setQuery(matchQuery("_all", "quick")).get(); hits = searchResponse.getHits().hits(); assertThat(hits.length, equalTo(3)); @@ -156,8 +156,8 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("field1", "quick brown"), client().prepareIndex("test", "type1", "3").setSource("field1", "quick")); - assertHitCount(client().prepareSearch().setQuery(queryStringQuery("quick")).get(), 3l); - assertHitCount(client().prepareSearch().setQuery(queryStringQuery("")).get(), 0l); // return no docs + assertHitCount(client().prepareSearch().setQuery(queryStringQuery("quick")).get(), 3L); + assertHitCount(client().prepareSearch().setQuery(queryStringQuery("")).get(), 0L); // return no docs } // see https://github.com/elasticsearch/elasticsearch/issues/3177 @@ -178,7 +178,7 @@ public class SearchQueryIT extends ESIntegTestCase { matchAllQuery()).must( boolQuery().mustNot(boolQuery().must(termQuery("field1", "value1")).must( termQuery("field1", "value2"))))).get(), - 3l); + 3L); assertHitCount( client().prepareSearch() .setQuery( @@ -187,10 +187,10 @@ public class SearchQueryIT extends ESIntegTestCase { .should(termQuery("field1", "value3"))).filter( boolQuery().mustNot(boolQuery().must(termQuery("field1", "value1")).must( termQuery("field1", "value2"))))).get(), - 3l); + 3L); assertHitCount( client().prepareSearch().setQuery(matchAllQuery()).setPostFilter(boolQuery().mustNot(termQuery("field1", "value3"))).get(), - 2l); + 2L); } public void testIndexOptions() throws Exception { @@ -201,7 +201,7 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox")); SearchResponse searchResponse = client().prepareSearch().setQuery(matchQuery("field2", "quick brown").type(Type.PHRASE).slop(0)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFailures(client().prepareSearch().setQuery(matchQuery("field1", "quick brown").type(Type.PHRASE).slop(0)), RestStatus.INTERNAL_SERVER_ERROR, @@ -215,7 +215,7 @@ public class SearchQueryIT extends ESIntegTestCase { indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("field1", "quick brown fox", "field2", "quick brown fox"), client().prepareIndex("test", "type1", "2").setSource("field1", "quick lazy huge brown fox", "field2", "quick lazy huge brown fox")); SearchResponse searchResponse = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("field1", "quick"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); for (SearchHit searchHit : searchResponse.getHits().hits()) { assertSearchHit(searchHit, hasScore(1.0f)); } @@ -223,17 +223,17 @@ public class SearchQueryIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test").setQuery( boolQuery().must(matchAllQuery()).must( constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + getRandom().nextFloat()))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasScore(searchResponse.getHits().getAt(1).score())); client().prepareSearch("test").setQuery(constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + getRandom().nextFloat())).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasScore(searchResponse.getHits().getAt(1).score())); searchResponse = client().prepareSearch("test").setQuery( constantScoreQuery(boolQuery().must(matchAllQuery()).must( constantScoreQuery(matchQuery("field1", "quick")).boost(1.0f + (random.nextBoolean()? 0.0f : random.nextFloat()))))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasScore(searchResponse.getHits().getAt(1).score())); for (SearchHit searchHit : searchResponse.getHits().hits()) { assertSearchHit(searchHit, hasScore(1.0f)); @@ -280,11 +280,11 @@ public class SearchQueryIT extends ESIntegTestCase { int iters = scaledRandomIntBetween(100, 200); for (int i = 0; i < iters; i++) { SearchResponse searchResponse = client().prepareSearch("test").setQuery(queryStringQuery("*:*^10.0").boost(10.0f)).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("test").setQuery( boolQuery().must(matchAllQuery()).must(constantScoreQuery(matchAllQuery()))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat((double)searchResponse.getHits().getAt(0).score(), closeTo(Math.sqrt(2), 0.1)); assertThat((double)searchResponse.getHits().getAt(1).score(),closeTo(Math.sqrt(2), 0.1)); } @@ -298,7 +298,7 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("message", "hello world", "comment", "test comment")); SearchResponse searchResponse = client().prepareSearch().setQuery(commonTermsQuery("_all", "test")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("2")); assertSecondHit(searchResponse, hasId("1")); assertThat(searchResponse.getHits().getHits()[0].getScore(), greaterThan(searchResponse.getHits().getHits()[1].getScore())); @@ -314,44 +314,44 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the quick brown").cutoffFrequency(3).lowFreqOperator(Operator.OR)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThirdHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the quick brown").cutoffFrequency(3).lowFreqOperator(Operator.AND)).get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); // Default searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the quick brown").cutoffFrequency(3)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThirdHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the huge fox").lowFreqMinimumShouldMatch("2")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("3")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("4")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); // Default searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the lazy fox brown").cutoffFrequency(1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the quick brown").cutoffFrequency(3).analyzer("stop")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); // stop drops "the" since its a stopword assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("3")); @@ -359,18 +359,18 @@ public class SearchQueryIT extends ESIntegTestCase { // try the same with match query searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the quick brown").cutoffFrequency(3).operator(Operator.AND)).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the quick brown").cutoffFrequency(3).operator(Operator.OR)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThirdHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the quick brown").cutoffFrequency(3).operator(Operator.AND).analyzer("stop")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); // stop drops "the" since its a stopword assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("3")); @@ -378,7 +378,7 @@ public class SearchQueryIT extends ESIntegTestCase { // try the same with multi match query searchResponse = client().prepareSearch().setQuery(multiMatchQuery("the quick brown", "field1", "field2").cutoffFrequency(3).operator(Operator.AND)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("3")); // better score due to different query stats assertSecondHit(searchResponse, hasId("1")); assertThirdHit(searchResponse, hasId("2")); @@ -401,44 +401,44 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "2").setSource("field1", "the quick lazy huge brown fox jumps over the tree") ); SearchResponse searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast brown").cutoffFrequency(3).lowFreqOperator(Operator.OR)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThirdHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast brown").cutoffFrequency(3).lowFreqOperator(Operator.AND)).get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(2L)); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); // Default searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast brown").cutoffFrequency(3)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThirdHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast huge fox").lowFreqMinimumShouldMatch("3")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("5")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast lazy fox brown").cutoffFrequency(1).highFreqMinimumShouldMatch("6")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); // Default searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the fast lazy fox brown").cutoffFrequency(1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(commonTermsQuery("field1", "the quick brown").cutoffFrequency(3).analyzer("stop")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); // stop drops "the" since its a stopword assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("3")); @@ -446,31 +446,31 @@ public class SearchQueryIT extends ESIntegTestCase { // try the same with match query searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the fast brown").cutoffFrequency(3).operator(Operator.AND)).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the fast brown").cutoffFrequency(3).operator(Operator.OR)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThirdHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the fast brown").cutoffFrequency(3).operator(Operator.AND).analyzer("stop")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); // stop drops "the" since its a stopword assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("3")); assertThirdHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(matchQuery("field1", "the fast brown").cutoffFrequency(3).minimumShouldMatch("3")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); // try the same with multi match query searchResponse = client().prepareSearch().setQuery(multiMatchQuery("the fast brown", "field1", "field2").cutoffFrequency(3).operator(Operator.AND)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertFirstHit(searchResponse, hasId("3")); // better score due to different query stats assertSecondHit(searchResponse, hasId("1")); assertThirdHit(searchResponse, hasId("2")); @@ -483,19 +483,19 @@ public class SearchQueryIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("value*").analyzeWildcard(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("*ue*").analyzeWildcard(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("*ue_1").analyzeWildcard(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("val*e_1").analyzeWildcard(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("v?l*e?1").analyzeWildcard(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testLowercaseExpandedTerms() { @@ -505,17 +505,17 @@ public class SearchQueryIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("VALUE_3~1").lowercaseExpandedTerms(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("VALUE_3~1").lowercaseExpandedTerms(false)).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("ValUE_*").lowercaseExpandedTerms(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("vAl*E_1")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("[VALUE_1 TO VALUE_3]")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("[VALUE_1 TO VALUE_3]").lowercaseExpandedTerms(false)).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } // Issue #3540 @@ -532,10 +532,10 @@ public class SearchQueryIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("past:[now-2M/d TO now/d]")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("future:[now/d TO now+2M/d]").lowercaseExpandedTerms(false)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); try { client().prepareSearch().setQuery(queryStringQuery("future:[now/D TO now+2M/d]").lowercaseExpandedTerms(false)).get(); @@ -562,7 +562,7 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("past:[now-1m/m TO now+1m/m]") .timeZone(timeZone.getID())).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } // Issue #10477 @@ -581,25 +581,25 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(queryStringQuery("past:[2015-04-06T00:00:00+0200 TO 2015-04-06T23:00:00+0200]")) .get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); // Same timezone set with time_zone searchResponse = client().prepareSearch() .setQuery(queryStringQuery("past:[2015-04-06T00:00:00 TO 2015-04-06T23:00:00]").timeZone("+0200")) .get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); // We set a timezone which will give no result searchResponse = client().prepareSearch() .setQuery(queryStringQuery("past:[2015-04-06T00:00:00-0200 TO 2015-04-06T23:00:00-0200]")) .get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); // Same timezone set with time_zone but another timezone is set directly within dates which has the precedence searchResponse = client().prepareSearch() .setQuery(queryStringQuery("past:[2015-04-06T00:00:00-0200 TO 2015-04-06T23:00:00-0200]").timeZone("+0200")) .get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testTypeFilter() throws Exception { @@ -610,13 +610,13 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type2", "2").setSource("field1", "value1"), client().prepareIndex("test", "type2", "3").setSource("field1", "value1")); - assertHitCount(client().prepareSearch().setQuery(typeQuery("type1")).get(), 2l); - assertHitCount(client().prepareSearch().setQuery(typeQuery("type2")).get(), 3l); + assertHitCount(client().prepareSearch().setQuery(typeQuery("type1")).get(), 2L); + assertHitCount(client().prepareSearch().setQuery(typeQuery("type2")).get(), 3L); - assertHitCount(client().prepareSearch().setTypes("type1").setQuery(matchAllQuery()).get(), 2l); - assertHitCount(client().prepareSearch().setTypes("type2").setQuery(matchAllQuery()).get(), 3l); + assertHitCount(client().prepareSearch().setTypes("type1").setQuery(matchAllQuery()).get(), 2L); + assertHitCount(client().prepareSearch().setTypes("type2").setQuery(matchAllQuery()).get(), 3L); - assertHitCount(client().prepareSearch().setTypes("type1", "type2").setQuery(matchAllQuery()).get(), 5l); + assertHitCount(client().prepareSearch().setTypes("type1", "type2").setQuery(matchAllQuery()).get(), 5L); } public void testIdsQueryTestsIdIndexed() throws Exception { @@ -627,29 +627,29 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "3").setSource("field1", "value3")); SearchResponse searchResponse = client().prepareSearch().setQuery(constantScoreQuery(idsQuery("type1").addIds("1", "3"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); // no type searchResponse = client().prepareSearch().setQuery(constantScoreQuery(idsQuery().addIds("1", "3"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); searchResponse = client().prepareSearch().setQuery(idsQuery("type1").addIds("1", "3")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); // no type searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1", "3")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); searchResponse = client().prepareSearch().setQuery(idsQuery("type1").addIds("7", "10")).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); // repeat..., with terms searchResponse = client().prepareSearch().setTypes("type1").setQuery(constantScoreQuery(termsQuery("_id", "1", "3"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); } @@ -668,19 +668,19 @@ public class SearchQueryIT extends ESIntegTestCase { for (String indexName : indexNames) { SearchResponse request = client().prepareSearch().setQuery(constantScoreQuery(termQuery("_index", indexName))).get(); SearchResponse searchResponse = assertSearchResponse(request); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, indexName + "1"); } for (String indexName : indexNames) { SearchResponse request = client().prepareSearch().setQuery(constantScoreQuery(termsQuery("_index", indexName))).get(); SearchResponse searchResponse = assertSearchResponse(request); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, indexName + "1"); } for (String indexName : indexNames) { SearchResponse request = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("_index", indexName))).get(); SearchResponse searchResponse = assertSearchResponse(request); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, indexName + "1"); } { @@ -701,33 +701,33 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(existsQuery("field1")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); searchResponse = client().prepareSearch().setQuery(constantScoreQuery(existsQuery("field1"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); searchResponse = client().prepareSearch().setQuery(queryStringQuery("_exists_:field1")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); searchResponse = client().prepareSearch().setQuery(existsQuery("field2")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); searchResponse = client().prepareSearch().setQuery(existsQuery("field3")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("4")); // wildcard check searchResponse = client().prepareSearch().setQuery(existsQuery("x*")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); // object check searchResponse = client().prepareSearch().setQuery(existsQuery("obj1")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); } @@ -737,13 +737,13 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").setRefresh(true).get(); WrapperQueryBuilder wrapper = new WrapperQueryBuilder("{ \"term\" : { \"field1\" : \"value1_1\" } }"); - assertHitCount(client().prepareSearch().setQuery(wrapper).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(wrapper).get(), 1L); BoolQueryBuilder bool = boolQuery().must(wrapper).must(new TermQueryBuilder("field2", "value2_1")); - assertHitCount(client().prepareSearch().setQuery(bool).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(bool).get(), 1L); WrapperQueryBuilder wrapperFilter = wrapperQuery("{ \"term\" : { \"field1\" : \"value1_1\" } }"); - assertHitCount(client().prepareSearch().setPostFilter(wrapperFilter).get(), 1l); + assertHitCount(client().prepareSearch().setPostFilter(wrapperFilter).get(), 1L); } public void testFiltersWithCustomCacheKey() throws Exception { @@ -752,31 +752,31 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get(); refresh(); SearchResponse searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("field1", "value1"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("field1", "value1"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("field1", "value1"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("field1", "value1"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testMatchQueryNumeric() throws Exception { assertAcked(prepareCreate("test").addMapping("type1", "long", "type=long", "double", "type=double")); - indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("long", 1l, "double", 1.0d), - client().prepareIndex("test", "type1", "2").setSource("long", 2l, "double", 2.0d), - client().prepareIndex("test", "type1", "3").setSource("long", 3l, "double", 3.0d)); + indexRandom(true, client().prepareIndex("test", "type1", "1").setSource("long", 1L, "double", 1.0d), + client().prepareIndex("test", "type1", "2").setSource("long", 2L, "double", 2.0d), + client().prepareIndex("test", "type1", "3").setSource("long", 3L, "double", 3.0d)); SearchResponse searchResponse = client().prepareSearch().setQuery(matchQuery("long", "1")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch().setQuery(matchQuery("double", "2")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); try { client().prepareSearch().setQuery(matchQuery("double", "2 3 4")).get(); @@ -798,7 +798,7 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(builder) .addAggregation(AggregationBuilders.terms("field1").field("field1")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); // this uses dismax so scores are equal and the order can be arbitrary assertSearchHits(searchResponse, "1", "2"); @@ -807,7 +807,7 @@ public class SearchQueryIT extends ESIntegTestCase { .setQuery(builder) .get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); client().admin().indices().prepareRefresh("test").get(); @@ -816,21 +816,21 @@ public class SearchQueryIT extends ESIntegTestCase { searchResponse = client().prepareSearch() .setQuery(builder) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); refresh(); builder = multiMatchQuery("value1", "field1").field("field3", 1.5f) .operator(Operator.AND); // Operator only applies on terms inside a field! Fields are always OR-ed together. searchResponse = client().prepareSearch().setQuery(builder).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "3", "1"); client().admin().indices().prepareRefresh("test").get(); builder = multiMatchQuery("value1").field("field1").field("field3", 1.5f) .operator(Operator.AND); // Operator only applies on terms inside a field! Fields are always OR-ed together. searchResponse = client().prepareSearch().setQuery(builder).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "3", "1"); // Test lenient @@ -845,7 +845,7 @@ public class SearchQueryIT extends ESIntegTestCase { builder.lenient(true); searchResponse = client().prepareSearch().setQuery(builder).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); } @@ -860,17 +860,17 @@ public class SearchQueryIT extends ESIntegTestCase { .must(matchQuery("field1", "a").zeroTermsQuery(MatchQuery.ZeroTermsQuery.NONE)) .must(matchQuery("field1", "value1").zeroTermsQuery(MatchQuery.ZeroTermsQuery.NONE)); SearchResponse searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); boolQuery = boolQuery() .must(matchQuery("field1", "a").zeroTermsQuery(MatchQuery.ZeroTermsQuery.ALL)) .must(matchQuery("field1", "value1").zeroTermsQuery(MatchQuery.ZeroTermsQuery.ALL)); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); boolQuery = boolQuery().must(matchQuery("field1", "a").zeroTermsQuery(MatchQuery.ZeroTermsQuery.ALL)); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } public void testMultiMatchQueryZeroTermsQuery() { @@ -885,17 +885,17 @@ public class SearchQueryIT extends ESIntegTestCase { .must(multiMatchQuery("a", "field1", "field2").zeroTermsQuery(MatchQuery.ZeroTermsQuery.NONE)) .must(multiMatchQuery("value1", "field1", "field2").zeroTermsQuery(MatchQuery.ZeroTermsQuery.NONE)); // Fields are ORed together SearchResponse searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); boolQuery = boolQuery() .must(multiMatchQuery("a", "field1", "field2").zeroTermsQuery(MatchQuery.ZeroTermsQuery.ALL)) .must(multiMatchQuery("value4", "field1", "field2").zeroTermsQuery(MatchQuery.ZeroTermsQuery.ALL)); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); boolQuery = boolQuery().must(multiMatchQuery("a", "field1").zeroTermsQuery(MatchQuery.ZeroTermsQuery.ALL)); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } public void testMultiMatchQueryMinShouldMatch() { @@ -911,41 +911,41 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(multiMatchQuery) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); multiMatchQuery.minimumShouldMatch("30%"); searchResponse = client().prepareSearch().setQuery(multiMatchQuery).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); multiMatchQuery.useDisMax(false); multiMatchQuery.minimumShouldMatch("70%"); searchResponse = client().prepareSearch().setQuery(multiMatchQuery).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); multiMatchQuery.minimumShouldMatch("30%"); searchResponse = client().prepareSearch().setQuery(multiMatchQuery).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); multiMatchQuery = multiMatchQuery("value1 value2 bar", "field1"); multiMatchQuery.minimumShouldMatch("100%"); searchResponse = client().prepareSearch().setQuery(multiMatchQuery).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); multiMatchQuery.minimumShouldMatch("70%"); searchResponse = client().prepareSearch().setQuery(multiMatchQuery).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); // Min should match > # optional clauses returns no docs. multiMatchQuery = multiMatchQuery("value1 value2 value3", "field1", "field2"); multiMatchQuery.minimumShouldMatch("4"); searchResponse = client().prepareSearch().setQuery(multiMatchQuery).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testBoolQueryMinShouldMatchBiggerThanNumberOfShouldClauses() throws IOException { @@ -961,7 +961,7 @@ public class SearchQueryIT extends ESIntegTestCase { .should(termQuery("field1", "value2")) .minimumNumberShouldMatch(3)); SearchResponse searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); boolQuery = boolQuery() @@ -973,7 +973,7 @@ public class SearchQueryIT extends ESIntegTestCase { // Only one should clause is defined, returns no docs. .minimumNumberShouldMatch(2); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); boolQuery = boolQuery() .should(termQuery("field1", "value1")) @@ -983,7 +983,7 @@ public class SearchQueryIT extends ESIntegTestCase { .minimumNumberShouldMatch(3)) .minimumNumberShouldMatch(1); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); boolQuery = boolQuery() @@ -993,7 +993,7 @@ public class SearchQueryIT extends ESIntegTestCase { .should(termQuery("field1", "value2")) .minimumNumberShouldMatch(3)); searchResponse = client().prepareSearch().setQuery(boolQuery).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testFuzzyQueryString() { @@ -1004,15 +1004,15 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("str:kimcy~1")).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:11~1")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch().setQuery(queryStringQuery("date:2012-02-02~1d")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); } @@ -1026,14 +1026,14 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch() .setQuery(queryStringQuery("\"phrase match\"").field("important", boost).field("less_important")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThat((double)searchResponse.getHits().getAt(0).score(), closeTo(boost * searchResponse.getHits().getAt(1).score(), .1)); searchResponse = client().prepareSearch() .setQuery(queryStringQuery("\"phrase match\"").field("important", boost).field("less_important").useDisMax(false)).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("1")); assertSecondHit(searchResponse, hasId("2")); assertThat((double)searchResponse.getHits().getAt(0).score(), closeTo(boost * searchResponse.getHits().getAt(1).score(), .1)); @@ -1046,27 +1046,27 @@ public class SearchQueryIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:>19")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:>20")).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:>=20")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:>11")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:<20")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("num:<=20")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("+num:>11 +num:<20")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testEmptytermsQuery() throws Exception { @@ -1079,77 +1079,77 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("term", new String[0]))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test").setQuery(idsQuery()).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testTermsQuery() throws Exception { assertAcked(prepareCreate("test").addMapping("type", "str", "type=string", "lng", "type=long", "dbl", "type=double")); indexRandom(true, - client().prepareIndex("test", "type", "1").setSource("str", "1", "lng", 1l, "dbl", 1.0d), - client().prepareIndex("test", "type", "2").setSource("str", "2", "lng", 2l, "dbl", 2.0d), - client().prepareIndex("test", "type", "3").setSource("str", "3", "lng", 3l, "dbl", 3.0d), - client().prepareIndex("test", "type", "4").setSource("str", "4", "lng", 4l, "dbl", 4.0d)); + client().prepareIndex("test", "type", "1").setSource("str", "1", "lng", 1L, "dbl", 1.0d), + client().prepareIndex("test", "type", "2").setSource("str", "2", "lng", 2L, "dbl", 2.0d), + client().prepareIndex("test", "type", "3").setSource("str", "3", "lng", 3L, "dbl", 3.0d), + client().prepareIndex("test", "type", "4").setSource("str", "4", "lng", 4L, "dbl", 4.0d)); SearchResponse searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("str", "1", "4"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "4"); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("lng", new long[] {2, 3}))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "2", "3"); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("dbl", new double[]{2, 3}))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "2", "3"); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("lng", new int[] {1, 3}))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("dbl", new float[] {2, 4}))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "2", "4"); // test partial matching searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("str", "2", "5"))).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("dbl", new double[] {2, 5}))).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("lng", new long[] {2, 5}))).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); // test valid type, but no matching terms searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("str", "5", "6"))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("dbl", new double[] {5, 6}))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test") .setQuery(constantScoreQuery(termsQuery("lng", new long[] {5, 6}))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testTermsLookupFilter() throws Exception { @@ -1189,54 +1189,54 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term" , new TermsLookup("lookup", "type", "1", "terms"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); // same as above, just on the _id... searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("_id", new TermsLookup("lookup", "type", "1", "terms")) ).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); // another search with same parameters... searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup", "type", "1", "terms"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup", "type", "2", "terms"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup", "type", "3", "terms"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "2", "4"); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup", "type", "4", "terms"))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup2", "type", "1", "arr.term"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "3"); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup2", "type", "2", "arr.term"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("2")); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("term", new TermsLookup("lookup2", "type", "3", "arr.term"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "2", "4"); searchResponse = client().prepareSearch("test") .setQuery(termsLookupQuery("not_exists", new TermsLookup("lookup2", "type", "3", "arr.term"))).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testBasicQueryById() throws Exception { @@ -1247,27 +1247,27 @@ public class SearchQueryIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(idsQuery("type1", "type2").addIds("1", "2")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat(searchResponse.getHits().hits().length, equalTo(2)); searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().hits().length, equalTo(1)); searchResponse = client().prepareSearch().setQuery(idsQuery().addIds("1", "2")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat(searchResponse.getHits().hits().length, equalTo(2)); searchResponse = client().prepareSearch().setQuery(idsQuery("type1").addIds("1", "2")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().hits().length, equalTo(1)); searchResponse = client().prepareSearch().setQuery(idsQuery(Strings.EMPTY_ARRAY).addIds("1")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().hits().length, equalTo(1)); searchResponse = client().prepareSearch().setQuery(idsQuery("type1", "type2", "type3").addIds("1", "2", "3", "4")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertThat(searchResponse.getHits().hits().length, equalTo(2)); } @@ -1291,82 +1291,82 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse; logger.info("--> term query on 1"); searchResponse = client().prepareSearch("test").setQuery(termQuery("num_byte", 1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termQuery("num_short", 1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termQuery("num_integer", 1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termQuery("num_long", 1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termQuery("num_float", 1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termQuery("num_double", 1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); logger.info("--> terms query on 1"); searchResponse = client().prepareSearch("test").setQuery(termsQuery("num_byte", new int[]{1})).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termsQuery("num_short", new int[]{1})).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termsQuery("num_integer", new int[]{1})).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termsQuery("num_long", new int[]{1})).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termsQuery("num_float", new double[]{1})).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(termsQuery("num_double", new double[]{1})).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); logger.info("--> term filter on 1"); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_byte", 1))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_short", 1))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_integer", 1))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_long", 1))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_float", 1))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termQuery("num_double", 1))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); logger.info("--> terms filter on 1"); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_byte", new int[]{1}))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_short", new int[]{1}))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_integer", new int[]{1}))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_long", new int[]{1}))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_float", new int[]{1}))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); searchResponse = client().prepareSearch("test").setQuery(constantScoreQuery(termsQuery("num_double", new int[]{1}))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); } @@ -1388,7 +1388,7 @@ public class SearchQueryIT extends ESIntegTestCase { .should(rangeQuery("num_long").from(1).to(2)) .should(rangeQuery("num_long").from(3).to(4)) ).get(); - assertHitCount(searchResponse, 4l); + assertHitCount(searchResponse, 4L); // This made 2826 fail! (only with bit based filters) searchResponse = client().prepareSearch("test").setPostFilter( @@ -1396,7 +1396,7 @@ public class SearchQueryIT extends ESIntegTestCase { .should(rangeQuery("num_long").from(1).to(2)) .should(rangeQuery("num_long").from(3).to(4)) ).get(); - assertHitCount(searchResponse, 4l); + assertHitCount(searchResponse, 4L); // This made #2979 fail! searchResponse = client().prepareSearch("test").setPostFilter( @@ -1405,7 +1405,7 @@ public class SearchQueryIT extends ESIntegTestCase { .should(rangeQuery("num_long").from(1).to(2)) .should(rangeQuery("num_long").from(3).to(4)) ).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } // see #2926 @@ -1422,13 +1422,13 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()) .setSearchType(SearchType.DFS_QUERY_THEN_FETCH).get(); - assertHitCount(searchResponse, 4l); + assertHitCount(searchResponse, 4L); searchResponse = client().prepareSearch("test").setQuery( boolQuery() .mustNot(matchQuery("description", "anything").type(Type.BOOLEAN)) ).setSearchType(SearchType.DFS_QUERY_THEN_FETCH).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } // see #2994 @@ -1443,12 +1443,12 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(spanOrQuery(spanTermQuery("description", "bar"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test").setQuery( spanNearQuery(spanTermQuery("description", "foo"), 3) .clause(spanTermQuery("description", "other"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); } @SuppressWarnings("deprecation") // fuzzy queries will be removed in 4.0 @@ -1493,17 +1493,17 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(spanNotQuery(spanNearQuery(QueryBuilders.spanTermQuery("description", "quick"), 1) .clause(QueryBuilders.spanTermQuery("description", "fox")), spanTermQuery("description", "brown"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(spanNotQuery(spanNearQuery(QueryBuilders.spanTermQuery("description", "quick"), 1) .clause(QueryBuilders.spanTermQuery("description", "fox")), spanTermQuery("description", "sleeping")).dist(5)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(spanNotQuery(spanNearQuery(QueryBuilders.spanTermQuery("description", "quick"), 1) .clause(QueryBuilders.spanTermQuery("description", "fox")), spanTermQuery("description", "jumped")).pre(1).post(1)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testSimpleDFSQuery() throws IOException { @@ -1691,7 +1691,7 @@ public class SearchQueryIT extends ESIntegTestCase { .setQuery( queryStringQuery("foo.baz").useDisMax(false).defaultOperator(Operator.AND) .field("field1").field("field2")).get(); - assertHitCount(response, 1l); + assertHitCount(response, 1L); } // see #3797 @@ -1703,15 +1703,15 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(multiMatchQuery("value2", "field2").field("field1", 2).lenient(true).useDisMax(false)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(multiMatchQuery("value2", "field2").field("field1", 2).lenient(true).useDisMax(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(multiMatchQuery("value2").field("field2", 2).lenient(true)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testAllFieldEmptyMapping() throws Exception { @@ -1742,24 +1742,24 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("index1", "index2", "index3") .setQuery(indicesQuery(matchQuery("text", "value1"), "index1") .noMatchQuery(matchQuery("text", "value2"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); //default no match query is match_all searchResponse = client().prepareSearch("index1", "index2", "index3") .setQuery(indicesQuery(matchQuery("text", "value1"), "index1")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertSearchHits(searchResponse, "1", "2", "3"); searchResponse = client().prepareSearch("index1", "index2", "index3") .setQuery(indicesQuery(matchQuery("text", "value1"), "index1") .noMatchQuery(QueryBuilders.matchAllQuery())).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertSearchHits(searchResponse, "1", "2", "3"); searchResponse = client().prepareSearch("index1", "index2", "index3") .setQuery(indicesQuery(matchQuery("text", "value1"), "index1") .noMatchQuery("none")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("1")); } @@ -1791,7 +1791,7 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("related", "simple") .setQuery(indicesQuery(hasChildQuery("child", matchQuery("text", "value2")), "related") .noMatchQuery(matchQuery("text", "value1"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "1", "2"); } @@ -1812,7 +1812,7 @@ public class SearchQueryIT extends ESIntegTestCase { indicesQuery(termQuery("field", "missing"), "test1", "test2", "test3") .noMatchQuery(termQuery("field", "match"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits().getHits()) { if ("index1".equals(hit.index())) { @@ -1831,7 +1831,7 @@ public class SearchQueryIT extends ESIntegTestCase { indicesQuery(termQuery("field", "missing"), "test1") .noMatchQuery(termQuery("field", "match"))).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); for (SearchHit hit : searchResponse.getHits().getHits()) { if ("index1".equals(hit.index())) { @@ -1850,7 +1850,7 @@ public class SearchQueryIT extends ESIntegTestCase { indicesQuery(termQuery("field", "missing"), "index1", "test1") .noMatchQuery(termQuery("field", "match"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); for (SearchHit hit : searchResponse.getHits().getHits()) { if ("index2".equals(hit.index())) { @@ -1933,51 +1933,51 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T00:00:00").to("2014-01-01T00:59:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("1")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2013-12-31T23:00:00").to("2013-12-31T23:59:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("2")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T01:00:00").to("2014-01-01T01:59:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("3")); // We explicitly define a time zone in the from/to dates so whatever the time zone is, it won't be used searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T00:00:00Z").to("2014-01-01T00:59:00Z").timeZone("+10:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("1")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2013-12-31T23:00:00Z").to("2013-12-31T23:59:00Z").timeZone("+10:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("2")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T01:00:00Z").to("2014-01-01T01:59:00Z").timeZone("+10:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("3")); // We define a time zone to be applied to the filter and from/to have no time zone searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T03:00:00").to("2014-01-01T03:59:00").timeZone("+03:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("1")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T02:00:00").to("2014-01-01T02:59:00").timeZone("+03:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("2")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01T04:00:00").to("2014-01-01T04:59:00").timeZone("+03:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("3")); // When we use long values, it means we have ms since epoch UTC based so we don't apply any transformation @@ -1993,13 +1993,13 @@ public class SearchQueryIT extends ESIntegTestCase { searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("2014-01-01").to("2014-01-01T00:59:00").timeZone("-01:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("3")); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date").from("now/d-1d").timeZone("+01:00")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertThat(searchResponse.getHits().getAt(0).getId(), is("4")); // A Range Filter on a numeric field with a TimeZone should raise an exception @@ -2018,7 +2018,7 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "1").setSource("{}").get(); refresh(); - assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1l); + assertHitCount(client().prepareSearch().setQuery(matchAllQuery()).get(), 1L); } // see #5120 @@ -2042,32 +2042,32 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(matchQuery("meta", "1234")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(matchQuery("meta", "1234.56")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(termQuery("meta", "A1234")) .get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(termQuery("meta", "a1234")) .get(); - assertHitCount(searchResponse, 0l); // it's upper case + assertHitCount(searchResponse, 0L); // it's upper case searchResponse = client().prepareSearch("test") .setQuery(matchQuery("meta", "A1234").analyzer("my_ngram_analyzer")) .get(); // force ngram analyzer - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test") .setQuery(matchQuery("meta", "a1234").analyzer("my_ngram_analyzer")) .get(); // this one returns a hit since it's default operator is OR - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testMatchPhrasePrefixQuery() throws ExecutionException, InterruptedException { @@ -2077,13 +2077,13 @@ public class SearchQueryIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(matchQuery("field", "Johnnie la").slop(between(2,5)).type(Type.PHRASE_PREFIX)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setQuery(matchQuery("field", "trying").type(Type.PHRASE_PREFIX)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "2"); searchResponse = client().prepareSearch().setQuery(matchQuery("field", "try").type(Type.PHRASE_PREFIX)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "2"); } @@ -2096,7 +2096,7 @@ public class SearchQueryIT extends ESIntegTestCase { .setSearchType(SearchType.DFS_QUERY_THEN_FETCH) .setQuery(QueryBuilders.queryStringQuery("xyz").boost(100)) .get(); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).id(), equalTo("1")); float first = response.getHits().getAt(0).getScore(); @@ -2106,7 +2106,7 @@ public class SearchQueryIT extends ESIntegTestCase { .setQuery(QueryBuilders.queryStringQuery("xyz").boost(100)) .get(); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).id(), equalTo("1")); float actual = response.getHits().getAt(0).getScore(); assertThat(i + " expected: " + first + " actual: " + actual, Float.compare(first, actual), equalTo(0)); diff --git a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java index 358122f54ec..923153a7dd0 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SimpleQueryStringIT.java @@ -62,7 +62,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "6").setSource("otherbody", "spaghetti")); SearchResponse searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertSearchHits(searchResponse, "1", "2", "3"); // Tests boost value setting. In this case doc 1 should always be ranked above the other @@ -71,32 +71,32 @@ public class SimpleQueryStringIT extends ESIntegTestCase { boolQuery() .should(simpleQueryStringQuery("\"foo bar\"").boost(10.0f)) .should(termQuery("body", "eggplant"))).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("foo bar").defaultOperator(Operator.AND)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("\"quux baz\" +(eggplant | spaghetti)")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "4", "5"); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("eggplants").analyzer("snowball")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("4")); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("spaghetti").field("body", 1000.0f).field("otherbody", 2.0f).queryName("myquery")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertFirstHit(searchResponse, hasId("5")); assertSearchHits(searchResponse, "5", "6"); assertThat(searchResponse.getHits().getAt(0).getMatchedQueries()[0], equalTo("myquery")); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("spaghetti").field("*body")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "5", "6"); } @@ -112,17 +112,17 @@ public class SimpleQueryStringIT extends ESIntegTestCase { logger.info("--> query 1"); SearchResponse searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar").minimumShouldMatch("2")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "3", "4"); logger.info("--> query 2"); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar").field("body").field("body2").minimumShouldMatch("2")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "3", "4"); logger.info("--> query 3"); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar baz").field("body").field("body2").minimumShouldMatch("70%")).get(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); assertSearchHits(searchResponse, "3", "4"); indexRandom(true, false, @@ -133,17 +133,17 @@ public class SimpleQueryStringIT extends ESIntegTestCase { logger.info("--> query 4"); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar").field("body").field("body2").minimumShouldMatch("2")).get(); - assertHitCount(searchResponse, 4l); + assertHitCount(searchResponse, 4L); assertSearchHits(searchResponse, "3", "4", "7", "8"); logger.info("--> query 5"); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar").minimumShouldMatch("2")).get(); - assertHitCount(searchResponse, 5l); + assertHitCount(searchResponse, 5L); assertSearchHits(searchResponse, "3", "4", "6", "7", "8"); logger.info("--> query 6"); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo bar baz").field("body2").field("other").minimumShouldMatch("70%")).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertSearchHits(searchResponse, "6", "7", "8"); } @@ -153,21 +153,21 @@ public class SimpleQueryStringIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("Professio*")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("Professio*").lowercaseExpandedTerms(false)).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("Professionan~1")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("Professionan~1").lowercaseExpandedTerms(false)).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); } public void testQueryStringLocale() { @@ -176,17 +176,17 @@ public class SimpleQueryStringIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("BILL*")).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch().setQuery(queryStringQuery("body:BILL*")).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("BILL*").locale(new Locale("tr", "TR"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setQuery( queryStringQuery("body:BILL*").locale(new Locale("tr", "TR"))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); } @@ -210,22 +210,22 @@ public class SimpleQueryStringIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("foo bar baz").field("body")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setTypes("type1").setQuery( simpleQueryStringQuery("foo bar baz").field("body")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("foo bar baz").field("body.sub")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setTypes("type1").setQuery( simpleQueryStringQuery("foo bar baz").field("body.sub")).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); } @@ -241,42 +241,42 @@ public class SimpleQueryStringIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("foo bar").flags(SimpleQueryStringFlag.ALL)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertSearchHits(searchResponse, "1", "2", "3"); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("foo | bar") .defaultOperator(Operator.AND) .flags(SimpleQueryStringFlag.OR)).get(); - assertHitCount(searchResponse, 3l); + assertHitCount(searchResponse, 3L); assertSearchHits(searchResponse, "1", "2", "3"); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("foo | bar") .defaultOperator(Operator.AND) .flags(SimpleQueryStringFlag.NONE)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("3")); searchResponse = client().prepareSearch().setQuery( simpleQueryStringQuery("baz | egg*") .defaultOperator(Operator.AND) .flags(SimpleQueryStringFlag.NONE)).get(); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client() .prepareSearch() .setSource( new SearchSourceBuilder().query(QueryBuilders.simpleQueryStringQuery("foo|bar").defaultOperator(Operator.AND) .flags(SimpleQueryStringFlag.NONE))).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client() .prepareSearch() .setQuery( simpleQueryStringQuery("baz | egg*").defaultOperator(Operator.AND).flags(SimpleQueryStringFlag.WHITESPACE, SimpleQueryStringFlag.PREFIX)).get(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertFirstHit(searchResponse, hasId("4")); } @@ -288,12 +288,12 @@ public class SimpleQueryStringIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo").field("field")).get(); assertFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("foo").field("field").lenient(true)).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); } @@ -332,7 +332,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch().setQuery(simpleQueryStringQuery("Köln*").analyzeWildcard(true).field("location")).get(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); assertSearchHits(searchResponse, "1"); } } diff --git a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java index bb81f28d15f..6341be8037e 100644 --- a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java +++ b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java @@ -92,7 +92,7 @@ public class SearchScrollIT extends ESIntegTestCase { try { long counter = 0; - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -102,7 +102,7 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -112,7 +112,7 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(30)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -150,7 +150,7 @@ public class SearchScrollIT extends ESIntegTestCase { try { long counter = 0; - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -161,7 +161,7 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -173,7 +173,7 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -184,7 +184,7 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(0)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); @@ -206,11 +206,11 @@ public class SearchScrollIT extends ESIntegTestCase { client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(500l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(500l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(500l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(0l)); + assertThat(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(500L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(500L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(500L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(0L)); SearchResponse searchResponse = client().prepareSearch() .setQuery(queryStringQuery("user:kimchy")) @@ -229,11 +229,11 @@ public class SearchScrollIT extends ESIntegTestCase { } while (searchResponse.getHits().hits().length > 0); client().admin().indices().prepareRefresh().execute().actionGet(); - assertThat(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(500l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(0l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(500l)); - assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(500l)); + assertThat(client().prepareSearch().setSize(0).setQuery(matchAllQuery()).execute().actionGet().getHits().totalHits(), equalTo(500L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "test")).execute().actionGet().getHits().totalHits(), equalTo(0L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(500L)); + assertThat(client().prepareSearch().setSize(0).setQuery(termQuery("message", "update")).execute().actionGet().getHits().totalHits(), equalTo(500L)); } finally { clearScroll(searchResponse.getScrollId()); } @@ -270,13 +270,13 @@ public class SearchScrollIT extends ESIntegTestCase { long counter1 = 0; long counter2 = 0; - assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse1.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse1.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter1++)); } - assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse2.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse2.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter2++)); @@ -290,13 +290,13 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse1.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse1.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter1++)); } - assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse2.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse2.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter2++)); @@ -381,13 +381,13 @@ public class SearchScrollIT extends ESIntegTestCase { long counter1 = 0; long counter2 = 0; - assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse1.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse1.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter1++)); } - assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse2.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse2.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter2++)); @@ -401,13 +401,13 @@ public class SearchScrollIT extends ESIntegTestCase { .setScroll(TimeValue.timeValueMinutes(2)) .execute().actionGet(); - assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse1.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse1.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse1.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter1++)); } - assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse2.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse2.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse2.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter2++)); @@ -439,7 +439,7 @@ public class SearchScrollIT extends ESIntegTestCase { SearchResponse response = builder.execute().actionGet(); try { - ElasticsearchAssertions.assertHitCount(response, 1l); + ElasticsearchAssertions.assertHitCount(response, 1L); } finally { String scrollId = response.getScrollId(); if (scrollId != null) { @@ -586,7 +586,7 @@ public class SearchScrollIT extends ESIntegTestCase { .addSort("field", SortOrder.ASC) .execute().actionGet(); long counter = 0; - assertThat(searchResponse.getHits().getTotalHits(), equalTo(100l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(100L)); assertThat(searchResponse.getHits().hits().length, equalTo(35)); for (SearchHit hit : searchResponse.getHits()) { assertThat(((Number) hit.sortValues()[0]).longValue(), equalTo(counter++)); diff --git a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java index 20cf8596c4a..2a42ec3530b 100644 --- a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java +++ b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollWithFailingNodesIT.java @@ -84,7 +84,7 @@ public class SearchScrollWithFailingNodesIT extends ESIntegTestCase { .get(); assertAllSuccessful(searchResponse); } while (searchResponse.getHits().hits().length > 0); - assertThat(numHits, equalTo(100l)); + assertThat(numHits, equalTo(100L)); clearScroll("_all"); internalCluster().stopRandomNonMasterNode(); @@ -104,7 +104,7 @@ public class SearchScrollWithFailingNodesIT extends ESIntegTestCase { .get(); assertThat(searchResponse.getSuccessfulShards(), equalTo(numberOfSuccessfulShards)); } while (searchResponse.getHits().hits().length > 0); - assertThat(numHits, greaterThan(0l)); + assertThat(numHits, greaterThan(0L)); clearScroll(searchResponse.getScrollId()); } diff --git a/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java b/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java index d14ea50838f..6c10a1c8aef 100644 --- a/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java @@ -85,7 +85,7 @@ public class SimpleSearchIT extends ESIntegTestCase { } // id is not indexed, but lets see that we automatically convert to SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).setPreference(randomPreference).get(); - assertHitCount(searchResponse, 6l); + assertHitCount(searchResponse, 6L); } } @@ -106,7 +106,7 @@ public class SimpleSearchIT extends ESIntegTestCase { .setQuery(boolQuery().must(rangeQuery("from").lt("192.168.0.7")).must(rangeQuery("to").gt("192.168.0.7"))) .execute().actionGet(); - assertHitCount(search, 1l); + assertHitCount(search, 1L); } public void testIpCidr() throws Exception { @@ -138,27 +138,27 @@ public class SimpleSearchIT extends ESIntegTestCase { search = client().prepareSearch() .setQuery(boolQuery().must(QueryBuilders.termQuery("ip", "192.168.0.1/32"))) .execute().actionGet(); - assertHitCount(search, 1l); + assertHitCount(search, 1L); search = client().prepareSearch() .setQuery(boolQuery().must(QueryBuilders.termQuery("ip", "192.168.0.0/24"))) .execute().actionGet(); - assertHitCount(search, 3l); + assertHitCount(search, 3L); search = client().prepareSearch() .setQuery(boolQuery().must(QueryBuilders.termQuery("ip", "192.0.0.0/8"))) .execute().actionGet(); - assertHitCount(search, 4l); + assertHitCount(search, 4L); search = client().prepareSearch() .setQuery(boolQuery().must(QueryBuilders.termQuery("ip", "0.0.0.0/0"))) .execute().actionGet(); - assertHitCount(search, 4l); + assertHitCount(search, 4L); search = client().prepareSearch() .setQuery(boolQuery().must(QueryBuilders.termQuery("ip", "192.168.1.5/32"))) .execute().actionGet(); - assertHitCount(search, 0l); + assertHitCount(search, 0L); assertFailures(client().prepareSearch().setQuery(boolQuery().must(QueryBuilders.termQuery("ip", "0/0/0/0/0"))), RestStatus.BAD_REQUEST, @@ -171,17 +171,17 @@ public class SimpleSearchIT extends ESIntegTestCase { client().prepareIndex("test", "type", "XXX1").setSource("field", "value").setRefresh(true).execute().actionGet(); // id is not indexed, but lets see that we automatically convert to SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(QueryBuilders.queryStringQuery("_id:XXX1")).execute().actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); // id is not index, but we can automatically support prefix as well searchResponse = client().prepareSearch().setQuery(QueryBuilders.prefixQuery("_id", "XXX")).execute().actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch().setQuery(QueryBuilders.queryStringQuery("_id:XXX*").lowercaseExpandedTerms(false)).execute().actionGet(); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); } public void testSimpleDateRange() throws Exception { @@ -192,22 +192,22 @@ public class SimpleSearchIT extends ESIntegTestCase { refresh(); SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d/d")).execute().actionGet(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.rangeQuery("field").gte("2010-01-05T02:00").lte("2010-01-06T02:00")).execute().actionGet(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.rangeQuery("field").gte("2010-01-05T02:00").lt("2010-01-06T02:00")).execute().actionGet(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 1l); + assertHitCount(searchResponse, 1L); searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.rangeQuery("field").gt("2010-01-05T02:00").lt("2010-01-06T02:00")).execute().actionGet(); assertNoFailures(searchResponse); - assertHitCount(searchResponse, 0l); + assertHitCount(searchResponse, 0L); searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.queryStringQuery("field:[2010-01-03||+2d TO 2010-01-04||+2d/d]")).execute().actionGet(); - assertHitCount(searchResponse, 2l); + assertHitCount(searchResponse, 2L); } public void testLocaleDependentDate() throws Exception { @@ -236,13 +236,13 @@ public class SimpleSearchIT extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Do, 07 Dez 2000 00:00:00 -0800")) .execute().actionGet(); - assertHitCount(searchResponse, 10l); + assertHitCount(searchResponse, 10L); searchResponse = client().prepareSearch("test") .setQuery(QueryBuilders.rangeQuery("date_field").gte("Di, 05 Dez 2000 02:55:00 -0800").lte("Fr, 08 Dez 2000 00:00:00 -0800")) .execute().actionGet(); - assertHitCount(searchResponse, 20l); + assertHitCount(searchResponse, 20L); } } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java index 1543433be32..c910e46cbd2 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java @@ -293,12 +293,12 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { Map> firstPayload = options.get(0).getPayload(); assertThat(firstPayload.keySet(), containsInAnyOrder("title", "count")); assertThat((String) firstPayload.get("title").get(0), equalTo("title2")); - assertThat((long) firstPayload.get("count").get(0), equalTo(2l)); + assertThat((long) firstPayload.get("count").get(0), equalTo(2L)); Map> secondPayload = options.get(1).getPayload(); assertThat(secondPayload.keySet(), containsInAnyOrder("title", "count")); assertThat((String) secondPayload.get("title").get(0), equalTo("title1")); - assertThat((long) secondPayload.get("count").get(0), equalTo(1l)); + assertThat((long) secondPayload.get("count").get(0), equalTo(1L)); } public void testSuggestWithPayload() throws Exception { @@ -378,7 +378,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { PercolateResponse response = client().preparePercolate().setIndices(INDEX).setDocumentType(TYPE) .setGetRequest(Requests.getRequest(INDEX).type(TYPE).id("1")) .execute().actionGet(); - assertThat(response.getCount(), equalTo(1l)); + assertThat(response.getCount(), equalTo(1L)); } public void testThatWeightsAreWorking() throws Exception { @@ -438,7 +438,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { CompletionSuggestion.Entry.Option prefixOption = (CompletionSuggestion.Entry.Option) option; assertThat(prefixOption.getText().string(), equalTo("testing")); - assertThat((long) prefixOption.getScore(), equalTo(10l)); + assertThat((long) prefixOption.getScore(), equalTo(10L)); } @@ -1045,7 +1045,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { refresh(); assertSuggestions("b"); - assertThat(2l, equalTo(client().prepareSearch(INDEX).setSize(0).get().getHits().totalHits())); + assertThat(2L, equalTo(client().prepareSearch(INDEX).setSize(0).get().getHits().totalHits())); for (IndexShardSegments seg : client().admin().indices().prepareSegments().get().getIndices().get(INDEX)) { ShardSegments[] shards = seg.getShards(); for (ShardSegments shardSegments : shards) { diff --git a/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java b/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java new file mode 100644 index 00000000000..02826b9a7eb --- /dev/null +++ b/core/src/test/java/org/elasticsearch/search/suggest/phrase/DirectCandidateGeneratorTests.java @@ -0,0 +1,323 @@ +/* + * 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.search.suggest.phrase; + +import org.apache.lucene.analysis.core.WhitespaceAnalyzer; +import org.elasticsearch.common.ParseFieldMatcher; +import org.elasticsearch.common.ParsingException; +import org.elasticsearch.common.io.stream.BytesStreamOutput; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.XContentHelper; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.analysis.AnalysisService; +import org.elasticsearch.index.analysis.NamedAnalyzer; +import org.elasticsearch.index.mapper.ContentPath; +import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.Mapper; +import org.elasticsearch.index.mapper.MapperBuilders; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.core.StringFieldMapper; +import org.elasticsearch.index.mapper.core.StringFieldMapper.StringFieldType; +import org.elasticsearch.index.query.QueryParseContext; +import org.elasticsearch.index.query.QueryShardContext; +import org.elasticsearch.indices.IndicesModule; +import org.elasticsearch.indices.query.IndicesQueriesRegistry; +import org.elasticsearch.search.suggest.phrase.PhraseSuggestionContext.DirectCandidateGenerator; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.IndexSettingsModule; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.function.Consumer; + +import static org.hamcrest.Matchers.equalTo; + +public class DirectCandidateGeneratorTests extends ESTestCase{ + + private static final int NUMBER_OF_RUNS = 20; + + + + /** + * Test serialization and deserialization of the generator + */ + public void testSerialization() throws IOException { + for (int runs = 0; runs < NUMBER_OF_RUNS; runs++) { + DirectCandidateGeneratorBuilder original = randomCandidateGenerator(); + DirectCandidateGeneratorBuilder deserialized = serializedCopy(original); + assertEquals(deserialized, original); + assertEquals(deserialized.hashCode(), original.hashCode()); + assertNotSame(deserialized, original); + } + } + + /** + * Test equality and hashCode properties + */ + public void testEqualsAndHashcode() throws IOException { + for (int runs = 0; runs < NUMBER_OF_RUNS; runs++) { + DirectCandidateGeneratorBuilder first = randomCandidateGenerator(); + assertFalse("generator is equal to null", first.equals(null)); + assertFalse("generator is equal to incompatible type", first.equals("")); + assertTrue("generator is not equal to self", first.equals(first)); + assertThat("same generator's hashcode returns different values if called multiple times", first.hashCode(), + equalTo(first.hashCode())); + + DirectCandidateGeneratorBuilder second = serializedCopy(first); + assertTrue("generator is not equal to self", second.equals(second)); + assertTrue("generator is not equal to its copy", first.equals(second)); + assertTrue("equals is not symmetric", second.equals(first)); + assertThat("generator copy's hashcode is different from original hashcode", second.hashCode(), equalTo(first.hashCode())); + + DirectCandidateGeneratorBuilder third = serializedCopy(second); + assertTrue("generator is not equal to self", third.equals(third)); + assertTrue("generator is not equal to its copy", second.equals(third)); + assertThat("generator copy's hashcode is different from original hashcode", second.hashCode(), equalTo(third.hashCode())); + assertTrue("equals is not transitive", first.equals(third)); + assertThat("generator copy's hashcode is different from original hashcode", first.hashCode(), equalTo(third.hashCode())); + assertTrue("equals is not symmetric", third.equals(second)); + assertTrue("equals is not symmetric", third.equals(first)); + + // test for non-equality, check that all fields are covered by changing one by one + first = new DirectCandidateGeneratorBuilder("aaa"); + assertEquals(first, serializedCopy(first)); + second = new DirectCandidateGeneratorBuilder("bbb"); + assertNotEquals(first, second); + assertNotEquals(first.accuracy(0.1f), serializedCopy(first).accuracy(0.2f)); + assertNotEquals(first.maxEdits(1), serializedCopy(first).maxEdits(2)); + assertNotEquals(first.maxInspections(1), serializedCopy(first).maxInspections(2)); + assertNotEquals(first.maxTermFreq(0.1f), serializedCopy(first).maxTermFreq(0.2f)); + assertNotEquals(first.minDocFreq(0.1f), serializedCopy(first).minDocFreq(0.2f)); + assertNotEquals(first.minWordLength(1), serializedCopy(first).minWordLength(2)); + assertNotEquals(first.postFilter("postFilter"), serializedCopy(first).postFilter("postFilter_other")); + assertNotEquals(first.preFilter("preFilter"), serializedCopy(first).preFilter("preFilter_other")); + assertNotEquals(first.prefixLength(1), serializedCopy(first).prefixLength(2)); + assertNotEquals(first.size(1), serializedCopy(first).size(2)); + assertNotEquals(first.sort("score"), serializedCopy(first).sort("frequency")); + assertNotEquals(first.stringDistance("levenstein"), serializedCopy(first).sort("ngram")); + assertNotEquals(first.suggestMode("missing"), serializedCopy(first).suggestMode("always")); + } + } + + /** + * creates random candidate generator, renders it to xContent and back to new instance that should be equal to original + */ + public void testFromXContent() throws IOException { + QueryParseContext context = new QueryParseContext(new IndicesQueriesRegistry(Settings.EMPTY, Collections.emptyMap())); + context.parseFieldMatcher(new ParseFieldMatcher(Settings.EMPTY)); + for (int runs = 0; runs < NUMBER_OF_RUNS; runs++) { + DirectCandidateGeneratorBuilder generator = randomCandidateGenerator(); + XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values())); + if (randomBoolean()) { + builder.prettyPrint(); + } + generator.toXContent(builder, ToXContent.EMPTY_PARAMS); + + XContentParser parser = XContentHelper.createParser(builder.bytes()); + context.reset(parser); + parser.nextToken(); + DirectCandidateGeneratorBuilder secondGenerator = DirectCandidateGeneratorBuilder.PROTOTYPE + .fromXContent(context); + assertNotSame(generator, secondGenerator); + assertEquals(generator, secondGenerator); + assertEquals(generator.hashCode(), secondGenerator.hashCode()); + } + } + + /** + * test that build() outputs a {@link DirectCandidateGenerator} that is similar to the one + * we would get when parsing the xContent the test generator is rendering out + */ + public void testBuild() throws IOException { + + long start = System.currentTimeMillis(); + IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAsciiOfLengthBetween(1, 10), Settings.EMPTY); + + AnalysisService mockAnalysisService = new AnalysisService(idxSettings, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()) { + @Override + public NamedAnalyzer analyzer(String name) { + return new NamedAnalyzer(name, new WhitespaceAnalyzer()); + } + }; + + MapperService mockMapperService = new MapperService(idxSettings, mockAnalysisService , null, new IndicesModule().getMapperRegistry(), null) { + @Override + public MappedFieldType fullName(String fullName) { + return new StringFieldType(); + } + }; + + QueryShardContext mockShardContext = new QueryShardContext(idxSettings, null, null, null, mockMapperService, null, null, null) { + @Override + public MappedFieldType fieldMapper(String name) { + StringFieldMapper.Builder builder = MapperBuilders.stringField(name); + return builder.build(new Mapper.BuilderContext(idxSettings.getSettings(), new ContentPath(1))).fieldType(); + } + }; + mockShardContext.setMapUnmappedFieldAsString(true); + + for (int runs = 0; runs < NUMBER_OF_RUNS; runs++) { + DirectCandidateGeneratorBuilder generator = randomCandidateGenerator(); + // first, build via DirectCandidateGenerator#build() + DirectCandidateGenerator contextGenerator = generator.build(mockShardContext); + + // second, render random test generator to xContent and parse using + // PhraseSuggestParser + XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values())); + if (randomBoolean()) { + builder.prettyPrint(); + } + generator.toXContent(builder, ToXContent.EMPTY_PARAMS); + XContentParser parser = XContentHelper.createParser(builder.bytes()); + + DirectCandidateGenerator secondGenerator = PhraseSuggestParser.parseCandidateGenerator(parser, + mockShardContext.getMapperService(), mockShardContext.parseFieldMatcher()); + + // compare their properties + assertNotSame(contextGenerator, secondGenerator); + assertEquals(contextGenerator.field(), secondGenerator.field()); + assertEquals(contextGenerator.accuracy(), secondGenerator.accuracy(), Float.MIN_VALUE); + assertEquals(contextGenerator.maxTermFreq(), secondGenerator.maxTermFreq(), Float.MIN_VALUE); + assertEquals(contextGenerator.maxEdits(), secondGenerator.maxEdits()); + assertEquals(contextGenerator.maxInspections(), secondGenerator.maxInspections()); + assertEquals(contextGenerator.minDocFreq(), secondGenerator.minDocFreq(), Float.MIN_VALUE); + assertEquals(contextGenerator.minWordLength(), secondGenerator.minWordLength()); + assertEquals(contextGenerator.postFilter(), secondGenerator.postFilter()); + assertEquals(contextGenerator.prefixLength(), secondGenerator.prefixLength()); + assertEquals(contextGenerator.preFilter(), secondGenerator.preFilter()); + assertEquals(contextGenerator.sort(), secondGenerator.sort()); + assertEquals(contextGenerator.size(), secondGenerator.size()); + // some instances of StringDistance don't support equals, just checking the class here + assertEquals(contextGenerator.stringDistance().getClass(), secondGenerator.stringDistance().getClass()); + assertEquals(contextGenerator.suggestMode(), secondGenerator.suggestMode()); + } + } + + /** + * test that bad xContent throws exception + */ + public void testIllegalXContent() throws IOException { + QueryParseContext context = new QueryParseContext(new IndicesQueriesRegistry(Settings.EMPTY, Collections.emptyMap())); + context.parseFieldMatcher(new ParseFieldMatcher(Settings.EMPTY)); + + // test missing fieldname + String directGenerator = "{ }"; + XContentParser parser = XContentFactory.xContent(directGenerator).createParser(directGenerator); + + context.reset(parser); + try { + DirectCandidateGeneratorBuilder.PROTOTYPE.fromXContent(context); + fail("expected an exception"); + } catch (IllegalArgumentException e) { + assertEquals("[direct_generator] expects exactly one field parameter, but found []", e.getMessage()); + } + + // test two fieldnames + directGenerator = "{ \"field\" : \"f1\", \"field\" : \"f2\" }"; + parser = XContentFactory.xContent(directGenerator).createParser(directGenerator); + + context.reset(parser); + try { + DirectCandidateGeneratorBuilder.PROTOTYPE.fromXContent(context); + fail("expected an exception"); + } catch (IllegalArgumentException e) { + assertEquals("[direct_generator] expects exactly one field parameter, but found [f2, f1]", e.getMessage()); + } + + // test unknown field + directGenerator = "{ \"unknown_param\" : \"f1\" }"; + parser = XContentFactory.xContent(directGenerator).createParser(directGenerator); + + context.reset(parser); + try { + DirectCandidateGeneratorBuilder.PROTOTYPE.fromXContent(context); + fail("expected an exception"); + } catch (IllegalArgumentException e) { + assertEquals("[direct_generator] unknown field [unknown_param], parser not found", e.getMessage()); + } + + // test bad value for field (e.g. size expects an int) + directGenerator = "{ \"size\" : \"xxl\" }"; + parser = XContentFactory.xContent(directGenerator).createParser(directGenerator); + + context.reset(parser); + try { + DirectCandidateGeneratorBuilder.PROTOTYPE.fromXContent(context); + fail("expected an exception"); + } catch (ParsingException e) { + assertEquals("[direct_generator] failed to parse field [size]", e.getMessage()); + } + + // test unexpected token + directGenerator = "{ \"size\" : [ \"xxl\" ] }"; + parser = XContentFactory.xContent(directGenerator).createParser(directGenerator); + + context.reset(parser); + try { + DirectCandidateGeneratorBuilder.PROTOTYPE.fromXContent(context); + fail("expected an exception"); + } catch (IllegalArgumentException e) { + assertEquals("[direct_generator] size doesn't support values of type: START_ARRAY", e.getMessage()); + } + } + + /** + * create random {@link DirectCandidateGeneratorBuilder} + */ + public static DirectCandidateGeneratorBuilder randomCandidateGenerator() { + DirectCandidateGeneratorBuilder generator = new DirectCandidateGeneratorBuilder(randomAsciiOfLength(10)); + maybeSet(generator::accuracy, randomFloat()); + maybeSet(generator::maxEdits, randomIntBetween(1, 2)); + maybeSet(generator::maxInspections, randomIntBetween(1, 20)); + maybeSet(generator::maxTermFreq, randomFloat()); + maybeSet(generator::minDocFreq, randomFloat()); + maybeSet(generator::minWordLength, randomIntBetween(1, 20)); + maybeSet(generator::prefixLength, randomIntBetween(1, 20)); + maybeSet(generator::preFilter, randomAsciiOfLengthBetween(1, 20)); + maybeSet(generator::postFilter, randomAsciiOfLengthBetween(1, 20)); + maybeSet(generator::size, randomIntBetween(1, 20)); + maybeSet(generator::sort, randomFrom(Arrays.asList(new String[]{ "score", "frequency" }))); + maybeSet(generator::stringDistance, randomFrom(Arrays.asList(new String[]{ "internal", "damerau_levenshtein", "levenstein", "jarowinkler", "ngram"}))); + maybeSet(generator::suggestMode, randomFrom(Arrays.asList(new String[]{ "missing", "popular", "always"}))); + return generator; + } + + private static void maybeSet(Consumer consumer, T value) { + if (randomBoolean()) { + consumer.accept(value); + } + } + + private static DirectCandidateGeneratorBuilder serializedCopy(DirectCandidateGeneratorBuilder original) throws IOException { + try (BytesStreamOutput output = new BytesStreamOutput()) { + original.writeTo(output); + try (StreamInput in = StreamInput.wrap(output.bytes())) { + return DirectCandidateGeneratorBuilder.PROTOTYPE.readFrom(in); + } + } + } +} diff --git a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java index 1df6960b6df..f6fa1fc621f 100644 --- a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java +++ b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java @@ -63,11 +63,11 @@ public class SimilarityIT extends ESIntegTestCase { .setRefresh(true).execute().actionGet(); SearchResponse bm25SearchResponse = client().prepareSearch().setQuery(matchQuery("field1", "quick brown fox")).execute().actionGet(); - assertThat(bm25SearchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(bm25SearchResponse.getHits().totalHits(), equalTo(1L)); float bm25Score = bm25SearchResponse.getHits().hits()[0].score(); SearchResponse defaultSearchResponse = client().prepareSearch().setQuery(matchQuery("field2", "quick brown fox")).execute().actionGet(); - assertThat(defaultSearchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(defaultSearchResponse.getHits().totalHits(), equalTo(1L)); float defaultScore = defaultSearchResponse.getHits().hits()[0].score(); assertThat(bm25Score, not(equalTo(defaultScore))); diff --git a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java index e655f452688..c30954f7312 100644 --- a/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/threadpool/ThreadPoolSerializationTests.java @@ -63,7 +63,7 @@ public class ThreadPoolSerializationTests extends ESTestCase { ThreadPool.Info newInfo = new ThreadPool.Info(); newInfo.readFrom(input); - assertThat(newInfo.getQueueSize().singles(), is(10000l)); + assertThat(newInfo.getQueueSize().singles(), is(10000L)); } public void testThatNegativeQueueSizesCanBeSerialized() throws Exception { diff --git a/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java b/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java index 06e20fd31f1..01fae3036dd 100644 --- a/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/threadpool/UpdateThreadPoolSettingsTests.java @@ -379,7 +379,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase { assertEquals(info.getThreadPoolType(), ThreadPool.ThreadPoolType.FIXED); assertThat(info.getMin(), equalTo(1)); assertThat(info.getMax(), equalTo(1)); - assertThat(info.getQueueSize().singles(), equalTo(1l)); + assertThat(info.getQueueSize().singles(), equalTo(1L)); } else { for (Field field : Names.class.getFields()) { if (info.getName().equalsIgnoreCase(field.getName())) { @@ -411,7 +411,7 @@ public class UpdateThreadPoolSettingsTests extends ESTestCase { foundPool2 = true; assertThat(info.getMax(), equalTo(10)); assertThat(info.getMin(), equalTo(10)); - assertThat(info.getQueueSize().singles(), equalTo(1l)); + assertThat(info.getQueueSize().singles(), equalTo(1L)); assertEquals(info.getThreadPoolType(), ThreadPool.ThreadPoolType.FIXED); } else { for (Field field : Names.class.getFields()) { diff --git a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java index 30ed8fe25ca..1bb51fab09d 100644 --- a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java +++ b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java @@ -74,7 +74,7 @@ public class SimpleTimestampIT extends ESIntegTestCase { getResponse = client().prepareGet("test", "type1", "1").setFields("_timestamp").setRealtime(false).execute().actionGet(); timestamp = ((Number) getResponse.getField("_timestamp").getValue()).longValue(); - assertThat(timestamp, equalTo(10l)); + assertThat(timestamp, equalTo(10L)); // verify its the same timestamp when going the replica getResponse = client().prepareGet("test", "type1", "1").setFields("_timestamp").setRealtime(false).execute().actionGet(); assertThat(((Number) getResponse.getField("_timestamp").getValue()).longValue(), equalTo(timestamp)); @@ -84,7 +84,7 @@ public class SimpleTimestampIT extends ESIntegTestCase { getResponse = client().prepareGet("test", "type1", "1").setFields("_timestamp").setRealtime(false).execute().actionGet(); timestamp = ((Number) getResponse.getField("_timestamp").getValue()).longValue(); - assertThat(timestamp, equalTo(20l)); + assertThat(timestamp, equalTo(20L)); // verify its the same timestamp when going the replica getResponse = client().prepareGet("test", "type1", "1").setFields("_timestamp").setRealtime(false).execute().actionGet(); assertThat(((Number) getResponse.getField("_timestamp").getValue()).longValue(), equalTo(timestamp)); diff --git a/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java b/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java index 747b218b797..4688daec7d9 100644 --- a/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java +++ b/core/src/test/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java @@ -429,7 +429,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase { @Override public void handleException(TransportException exp) { - assertThat("bad message !!!", equalTo(exp.getCause().getMessage())); + assertThat("runtime_exception: bad message !!!", equalTo(exp.getCause().getMessage())); } }); @@ -437,7 +437,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase { res.txGet(); fail("exception should be thrown"); } catch (Exception e) { - assertThat(e.getCause().getMessage(), equalTo("bad message !!!")); + assertThat(e.getCause().getMessage(), equalTo("runtime_exception: bad message !!!")); } serviceA.removeHandler("sayHelloException"); diff --git a/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java b/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java index 20663aee29d..e2ff218a942 100644 --- a/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java +++ b/core/src/test/java/org/elasticsearch/transport/ContextAndHeaderTransportIT.java @@ -229,7 +229,7 @@ public class ContextAndHeaderTransportIT extends ESIntegTestCase { GetRequest getRequest = client.prepareGet(lookupIndex, "type", "1").request(); PercolateResponse response = client.preparePercolate().setDocumentType("type").setGetRequest(getRequest).get(); - assertThat(response.getCount(), is(1l)); + assertThat(response.getCount(), is(1L)); assertGetRequestsContainHeaders(); } diff --git a/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java b/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java index 39b96386fdb..def9a119ac4 100644 --- a/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java +++ b/core/src/test/java/org/elasticsearch/transport/NettySizeHeaderFrameDecoderTests.java @@ -52,7 +52,7 @@ public class NettySizeHeaderFrameDecoderTests extends ESTestCase { private final Settings settings = settingsBuilder() .put("name", "foo") - .put("transport.host", "127.0.0.1") + .put(TransportSettings.BIND_HOST.getKey(), "127.0.0.1") .put(TransportSettings.PORT.getKey(), "0") .build(); diff --git a/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java b/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java index ab3290980e5..d720706b77d 100644 --- a/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java +++ b/core/src/test/java/org/elasticsearch/transport/netty/NettyScheduledPingTests.java @@ -69,12 +69,12 @@ public class NettyScheduledPingTests extends ESTestCase { assertBusy(new Runnable() { @Override public void run() { - assertThat(nettyA.scheduledPing.successfulPings.count(), greaterThan(100l)); - assertThat(nettyB.scheduledPing.successfulPings.count(), greaterThan(100l)); + assertThat(nettyA.scheduledPing.successfulPings.count(), greaterThan(100L)); + assertThat(nettyB.scheduledPing.successfulPings.count(), greaterThan(100L)); } }); - assertThat(nettyA.scheduledPing.failedPings.count(), equalTo(0l)); - assertThat(nettyB.scheduledPing.failedPings.count(), equalTo(0l)); + assertThat(nettyA.scheduledPing.failedPings.count(), equalTo(0L)); + assertThat(nettyB.scheduledPing.failedPings.count(), equalTo(0L)); serviceA.registerRequestHandler("sayHello", TransportRequest.Empty::new, ThreadPool.Names.GENERIC, new TransportRequestHandler() { @Override @@ -118,12 +118,12 @@ public class NettyScheduledPingTests extends ESTestCase { assertBusy(new Runnable() { @Override public void run() { - assertThat(nettyA.scheduledPing.successfulPings.count(), greaterThan(200l)); - assertThat(nettyB.scheduledPing.successfulPings.count(), greaterThan(200l)); + assertThat(nettyA.scheduledPing.successfulPings.count(), greaterThan(200L)); + assertThat(nettyB.scheduledPing.successfulPings.count(), greaterThan(200L)); } }); - assertThat(nettyA.scheduledPing.failedPings.count(), equalTo(0l)); - assertThat(nettyB.scheduledPing.failedPings.count(), equalTo(0l)); + assertThat(nettyA.scheduledPing.failedPings.count(), equalTo(0L)); + assertThat(nettyB.scheduledPing.failedPings.count(), equalTo(0L)); Releasables.close(serviceA, serviceB); terminate(threadPool); diff --git a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java index 506321684ba..ae4555b891c 100644 --- a/core/src/test/java/org/elasticsearch/tribe/TribeIT.java +++ b/core/src/test/java/org/elasticsearch/tribe/TribeIT.java @@ -225,7 +225,6 @@ public class TribeIT extends ESIntegTestCase { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/16299") public void testOnConflictDrop() throws Exception { logger.info("create 2 indices, test1 on t1, and test2 on t2"); assertAcked(cluster().client().admin().indices().prepareCreate("conflict")); @@ -244,8 +243,8 @@ public class TribeIT extends ESIntegTestCase { logger.info("wait till test1 and test2 exists in the tribe node state"); awaitIndicesInClusterState("test1", "test2"); - assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test1").getSettings().get(TribeService.TRIBE_NAME), equalTo("t1")); - assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test2").getSettings().get(TribeService.TRIBE_NAME), equalTo("t2")); + assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test1").getSettings().get("tribe.name"), equalTo("t1")); + assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test2").getSettings().get("tribe.name"), equalTo("t2")); assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().hasIndex("conflict"), equalTo(false)); } @@ -271,9 +270,9 @@ public class TribeIT extends ESIntegTestCase { logger.info("wait till test1 and test2 exists in the tribe node state"); awaitIndicesInClusterState("test1", "test2", "conflict"); - assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test1").getSettings().get(TribeService.TRIBE_NAME), equalTo("t1")); - assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test2").getSettings().get(TribeService.TRIBE_NAME), equalTo("t2")); - assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("conflict").getSettings().get(TribeService.TRIBE_NAME), equalTo(tribe)); + assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test1").getSettings().get("tribe.name"), equalTo("t1")); + assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("test2").getSettings().get("tribe.name"), equalTo("t2")); + assertThat(tribeClient.admin().cluster().prepareState().get().getState().getMetaData().index("conflict").getSettings().get("tribe.name"), equalTo(tribe)); } public void testTribeOnOneCluster() throws Exception { @@ -298,8 +297,8 @@ public class TribeIT extends ESIntegTestCase { tribeClient.admin().indices().prepareRefresh().get(); logger.info("verify they are there"); - assertHitCount(tribeClient.prepareSearch().setSize(0).get(), 2l); - assertHitCount(tribeClient.prepareSearch().get(), 2l); + assertHitCount(tribeClient.prepareSearch().setSize(0).get(), 2L); + assertHitCount(tribeClient.prepareSearch().get(), 2L); assertBusy(new Runnable() { @Override public void run() { @@ -317,8 +316,8 @@ public class TribeIT extends ESIntegTestCase { logger.info("verify they are there"); - assertHitCount(tribeClient.prepareSearch().setSize(0).get(), 4l); - assertHitCount(tribeClient.prepareSearch().get(), 4l); + assertHitCount(tribeClient.prepareSearch().setSize(0).get(), 4L); + assertHitCount(tribeClient.prepareSearch().get(), 4L); assertBusy(new Runnable() { @Override public void run() { @@ -438,7 +437,7 @@ public class TribeIT extends ESIntegTestCase { if (!node.dataNode()) { continue; } - if (tribeName.equals(node.getAttributes().get(TribeService.TRIBE_NAME))) { + if (tribeName.equals(node.getAttributes().get("tribe.name"))) { count++; } } diff --git a/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java b/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java index d2d9a8507e4..cb8165b4aac 100644 --- a/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java +++ b/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java @@ -111,7 +111,7 @@ public class SimpleTTLIT extends ESIntegTestCase { ttl0 = ((Number) getResponse.getField("_ttl").getValue()).longValue(); assertThat(ttl0, lessThanOrEqualTo(providedTTLValue - (currentTime - now))); } else { - assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0l)); + assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0L)); } // verify the ttl is still decreasing when going to the replica currentTime = System.currentTimeMillis(); @@ -120,7 +120,7 @@ public class SimpleTTLIT extends ESIntegTestCase { ttl0 = ((Number) getResponse.getField("_ttl").getValue()).longValue(); assertThat(ttl0, lessThanOrEqualTo(providedTTLValue - (currentTime - now))); } else { - assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0l)); + assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0L)); } // non realtime get (stored) currentTime = System.currentTimeMillis(); @@ -129,7 +129,7 @@ public class SimpleTTLIT extends ESIntegTestCase { ttl0 = ((Number) getResponse.getField("_ttl").getValue()).longValue(); assertThat(ttl0, lessThanOrEqualTo(providedTTLValue - (currentTime - now))); } else { - assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0l)); + assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0L)); } // non realtime get going the replica currentTime = System.currentTimeMillis(); @@ -138,7 +138,7 @@ public class SimpleTTLIT extends ESIntegTestCase { ttl0 = ((Number) getResponse.getField("_ttl").getValue()).longValue(); assertThat(ttl0, lessThanOrEqualTo(providedTTLValue - (currentTime - now))); } else { - assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0l)); + assertThat(providedTTLValue - (currentTime - now), lessThanOrEqualTo(0L)); } // no TTL provided so no TTL fetched diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java index 1d176b199ba..b6d785a4977 100644 --- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -598,13 +598,13 @@ public class UpdateIT extends ESIntegTestCase { client().prepareUpdate(indexOrAlias(), "type", "1") .setScript(new Script("", ScriptService.ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2"))).setVersion(1).get(); - assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(2l)); + assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(2L)); // and again with a higher version.. client().prepareUpdate(indexOrAlias(), "type", "1") .setScript(new Script("", ScriptService.ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v3"))).setVersion(2).get(); - assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(3l)); + assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(3L)); // after delete client().prepareDelete("test", "type", "1").get(); @@ -628,7 +628,7 @@ public class UpdateIT extends ESIntegTestCase { .setVersion(10).setVersionType(VersionType.FORCE).get(); GetResponse get = get("test", "type", "2"); - assertThat(get.getVersion(), equalTo(10l)); + assertThat(get.getVersion(), equalTo(10L)); assertThat((String) get.getSource().get("text"), equalTo("v10")); // upserts - the combination with versions is a bit weird. Test are here to ensure we do not change our behavior unintentionally @@ -638,7 +638,7 @@ public class UpdateIT extends ESIntegTestCase { .setScript(new Script("", ScriptService.ScriptType.INLINE, "put_values", Collections.singletonMap("text", "v2"))) .setVersion(10).setUpsert("{ \"text\": \"v0\" }").get(); get = get("test", "type", "3"); - assertThat(get.getVersion(), equalTo(1l)); + assertThat(get.getVersion(), equalTo(1L)); assertThat((String) get.getSource().get("text"), equalTo("v0")); // retry on conflict is rejected: diff --git a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java index d937d5bade3..8bc69d4c17a 100644 --- a/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java +++ b/core/src/test/java/org/elasticsearch/validate/SimpleValidateQueryIT.java @@ -92,7 +92,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { refresh(); - for (Client client : internalCluster()) { + for (Client client : internalCluster().getClients()) { ValidateQueryResponse response = client.admin().indices().prepareValidateQuery("test") .setQuery(QueryBuilders.wrapperQuery("foo".getBytes(StandardCharsets.UTF_8))) .setExplain(true) @@ -104,7 +104,7 @@ public class SimpleValidateQueryIT extends ESIntegTestCase { } - for (Client client : internalCluster()) { + for (Client client : internalCluster().getClients()) { ValidateQueryResponse response = client.admin().indices().prepareValidateQuery("test") .setQuery(QueryBuilders.queryStringQuery("foo")) .setExplain(true) diff --git a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java index edbbebbbc45..3432411b225 100644 --- a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java +++ b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java @@ -75,23 +75,23 @@ public class SimpleVersioningIT extends ESIntegTestCase { createIndex("test"); ensureGreen("test"); // we are testing force here which doesn't work if we are recovering at the same time - zzzzz... IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(12).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(12l)); + assertThat(indexResponse.getVersion(), equalTo(12L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(12).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(12l)); + assertThat(indexResponse.getVersion(), equalTo(12L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(14).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(14l)); + assertThat(indexResponse.getVersion(), equalTo(14L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.FORCE).get(); - assertThat(indexResponse.getVersion(), equalTo(13l)); + assertThat(indexResponse.getVersion(), equalTo(13L)); client().admin().indices().prepareRefresh().execute().actionGet(); if (randomBoolean()) { refresh(); } for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(13l)); + assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(13L)); } // deleting with a lower version works. @@ -105,13 +105,13 @@ public class SimpleVersioningIT extends ESIntegTestCase { createIndex("test"); IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(12).setVersionType(VersionType.EXTERNAL_GTE).get(); - assertThat(indexResponse.getVersion(), equalTo(12l)); + assertThat(indexResponse.getVersion(), equalTo(12L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(12).setVersionType(VersionType.EXTERNAL_GTE).get(); - assertThat(indexResponse.getVersion(), equalTo(12l)); + assertThat(indexResponse.getVersion(), equalTo(12L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(14).setVersionType(VersionType.EXTERNAL_GTE).get(); - assertThat(indexResponse.getVersion(), equalTo(14l)); + assertThat(indexResponse.getVersion(), equalTo(14L)); assertThrows(client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.EXTERNAL_GTE), VersionConflictEngineException.class); @@ -121,7 +121,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { refresh(); } for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(14l)); + assertThat(client().prepareGet("test", "type", "1").get().getVersion(), equalTo(14L)); } // deleting with a lower version fails. @@ -144,7 +144,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { // But delete with a higher version is OK. deleteResponse = client().prepareDelete("test", "type", "1").setVersion(18).setVersionType(VersionType.EXTERNAL_GTE).execute().actionGet(); assertThat(deleteResponse.isFound(), equalTo(false)); - assertThat(deleteResponse.getVersion(), equalTo(18l)); + assertThat(deleteResponse.getVersion(), equalTo(18L)); } public void testExternalVersioning() throws Exception { @@ -152,10 +152,10 @@ public class SimpleVersioningIT extends ESIntegTestCase { ensureGreen(); IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(12).setVersionType(VersionType.EXTERNAL).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(12l)); + assertThat(indexResponse.getVersion(), equalTo(12L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(14).setVersionType(VersionType.EXTERNAL).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(14l)); + assertThat(indexResponse.getVersion(), equalTo(14L)); assertThrows(client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(13).setVersionType(VersionType.EXTERNAL).execute(), VersionConflictEngineException.class); @@ -164,7 +164,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { refresh(); } for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(14l)); + assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(14L)); } // deleting with a lower version fails. @@ -175,7 +175,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { // Delete with a higher version deletes all versions up to the given one. DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(17).setVersionType(VersionType.EXTERNAL).execute().actionGet(); assertThat(deleteResponse.isFound(), equalTo(true)); - assertThat(deleteResponse.getVersion(), equalTo(17l)); + assertThat(deleteResponse.getVersion(), equalTo(17L)); // Deleting with a lower version keeps on failing after a delete. assertThrows( @@ -186,17 +186,17 @@ public class SimpleVersioningIT extends ESIntegTestCase { // But delete with a higher version is OK. deleteResponse = client().prepareDelete("test", "type", "1").setVersion(18).setVersionType(VersionType.EXTERNAL).execute().actionGet(); assertThat(deleteResponse.isFound(), equalTo(false)); - assertThat(deleteResponse.getVersion(), equalTo(18l)); + assertThat(deleteResponse.getVersion(), equalTo(18L)); // TODO: This behavior breaks rest api returning http status 201, good news is that it this is only the case until deletes GC kicks in. indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(19).setVersionType(VersionType.EXTERNAL).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(19l)); + assertThat(indexResponse.getVersion(), equalTo(19L)); deleteResponse = client().prepareDelete("test", "type", "1").setVersion(20).setVersionType(VersionType.EXTERNAL).execute().actionGet(); assertThat(deleteResponse.isFound(), equalTo(true)); - assertThat(deleteResponse.getVersion(), equalTo(20l)); + assertThat(deleteResponse.getVersion(), equalTo(20L)); // Make sure that the next delete will be GC. Note we do it on the index settings so it will be cleaned up HashMap newSettings = new HashMap<>(); @@ -207,7 +207,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { // And now we have previous version return -1 indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(20).setVersionType(VersionType.EXTERNAL).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(20l)); + assertThat(indexResponse.getVersion(), equalTo(20L)); } public void testRequireUnitsOnUpdateSettings() throws Exception { @@ -233,7 +233,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1") .setCreate(true).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(1l)); + assertThat(indexResponse.getVersion(), equalTo(1L)); } public void testInternalVersioning() throws Exception { @@ -241,10 +241,10 @@ public class SimpleVersioningIT extends ESIntegTestCase { ensureGreen(); IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(1l)); + assertThat(indexResponse.getVersion(), equalTo(1L)); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(1).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(2l)); + assertThat(indexResponse.getVersion(), equalTo(2L)); assertThrows( client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").setVersion(1).execute(), @@ -264,13 +264,13 @@ public class SimpleVersioningIT extends ESIntegTestCase { client().admin().indices().prepareRefresh().execute().actionGet(); for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(2l)); + assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(2L)); } // search with versioning for (int i = 0; i < 10; i++) { SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setVersion(true).execute().actionGet(); - assertThat(searchResponse.getHits().getAt(0).version(), equalTo(2l)); + assertThat(searchResponse.getHits().getAt(0).version(), equalTo(2L)); } // search without versioning @@ -281,7 +281,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { DeleteResponse deleteResponse = client().prepareDelete("test", "type", "1").setVersion(2).execute().actionGet(); assertThat(deleteResponse.isFound(), equalTo(true)); - assertThat(deleteResponse.getVersion(), equalTo(3l)); + assertThat(deleteResponse.getVersion(), equalTo(3L)); assertThrows(client().prepareDelete("test", "type", "1").setVersion(2).execute(), VersionConflictEngineException.class); @@ -290,7 +290,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { // and thus the transaction is increased. deleteResponse = client().prepareDelete("test", "type", "1").setVersion(3).execute().actionGet(); assertThat(deleteResponse.isFound(), equalTo(false)); - assertThat(deleteResponse.getVersion(), equalTo(4l)); + assertThat(deleteResponse.getVersion(), equalTo(4L)); } public void testSimpleVersioningWithFlush() throws Exception { @@ -298,12 +298,12 @@ public class SimpleVersioningIT extends ESIntegTestCase { ensureGreen(); IndexResponse indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_1").execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(1l)); + assertThat(indexResponse.getVersion(), equalTo(1L)); client().admin().indices().prepareFlush().execute().actionGet(); indexResponse = client().prepareIndex("test", "type", "1").setSource("field1", "value1_2").setVersion(1).execute().actionGet(); - assertThat(indexResponse.getVersion(), equalTo(2l)); + assertThat(indexResponse.getVersion(), equalTo(2L)); client().admin().indices().prepareFlush().execute().actionGet(); @@ -321,12 +321,12 @@ public class SimpleVersioningIT extends ESIntegTestCase { client().admin().indices().prepareRefresh().execute().actionGet(); for (int i = 0; i < 10; i++) { - assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(2l)); + assertThat(client().prepareGet("test", "type", "1").execute().actionGet().getVersion(), equalTo(2L)); } for (int i = 0; i < 10; i++) { SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setVersion(true).execute().actionGet(); - assertThat(searchResponse.getHits().getAt(0).version(), equalTo(2l)); + assertThat(searchResponse.getHits().getAt(0).version(), equalTo(2L)); } } @@ -338,7 +338,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { assertThat(bulkResponse.hasFailures(), equalTo(false)); assertThat(bulkResponse.getItems().length, equalTo(1)); IndexResponse indexResponse = bulkResponse.getItems()[0].getResponse(); - assertThat(indexResponse.getVersion(), equalTo(1l)); + assertThat(indexResponse.getVersion(), equalTo(1L)); } diff --git a/docs/reference/index.asciidoc b/docs/reference/index.asciidoc index 4acd1f16eab..d150471a8b0 100644 --- a/docs/reference/index.asciidoc +++ b/docs/reference/index.asciidoc @@ -3,7 +3,7 @@ :version: 3.0.0-beta1 :major-version: 3.x -:branch: 3.0 +:branch: master :jdk: 1.8.0_25 :defguide: https://www.elastic.co/guide/en/elasticsearch/guide/current :plugins: https://www.elastic.co/guide/en/elasticsearch/plugins/master diff --git a/docs/reference/migration/migrate_2_2.asciidoc b/docs/reference/migration/migrate_2_2.asciidoc index c13358ecc15..efb063f7c0f 100644 --- a/docs/reference/migration/migrate_2_2.asciidoc +++ b/docs/reference/migration/migrate_2_2.asciidoc @@ -4,13 +4,47 @@ This section discusses the changes that you need to be aware of when migrating your application to Elasticsearch 2.2. -* <> +[float] +=== Scripting and security -[[breaking_22_index_apis]] -=== Index APIs +The Java Security Manager is being used to lock down the privileges available +to the scripting languages and to restrict the classes they are allowed to +load to a predefined whitelist. These changes may cause scripts which worked +in earlier versions to fail. See <> for more +details. -==== Field stats API +[float] +=== Field stats API + +The field stats' response format has been changed for number based and date +fields. The `min_value` and `max_value` elements now return values as number +and the new `min_value_as_string` and `max_value_as_string` return the values +as string. + +[float] +=== Default logging using systemd + +In previous versions of Elasticsearch using systemd, the default logging +configuration routed standard output to `/dev/null` and standard error to +the journal. However, there are often critical error messages at +startup that are logged to standard output rather than standard error +and these error messages would be lost to the ether. The default has +changed to now route standard output to the journal and standard error +to inherit this setting (these are the defaults for systemd). These +settings can be modified by editing the `elasticsearch.service` file. + +[float] +=== Cloud AWS Plugin + +Proxy settings have been deprecated and renamed: + +* from `cloud.aws.proxy_host` to `cloud.aws.proxy.host` +* from `cloud.aws.ec2.proxy_host` to `cloud.aws.ec2.proxy.host` +* from `cloud.aws.s3.proxy_host` to `cloud.aws.s3.proxy.host` +* from `cloud.aws.proxy_port` to `cloud.aws.proxy.port` +* from `cloud.aws.ec2.proxy_port` to `cloud.aws.ec2.proxy.port` +* from `cloud.aws.s3.proxy_port` to `cloud.aws.s3.proxy.port` + +If you are using proxy settings, update your settings as deprecated ones will +be removed in next major version. -The field stats' response format has been changed for number based and date fields. The `min_value` and -`max_value` elements now return values as number and the new `min_value_as_string` and `max_value_as_string` -return the values as string. diff --git a/docs/reference/migration/migrate_3_0.asciidoc b/docs/reference/migration/migrate_3_0.asciidoc index 78f8ff40307..c76dec77399 100644 --- a/docs/reference/migration/migrate_3_0.asciidoc +++ b/docs/reference/migration/migrate_3_0.asciidoc @@ -578,6 +578,10 @@ to index a document only if it doesn't already exist. `RecoreBuilder.Rescorer` was merged with `RescoreBuilder`, which now is an abstract superclass. QueryRescoreBuilder currently is its only implementation. +==== PhraseSuggestionBuilder + +The inner DirectCandidateGenerator class has been moved out to its own class called DirectCandidateGeneratorBuilder. + [[breaking_30_cache_concurrency]] === Cache concurrency level settings removed diff --git a/docs/reference/modules.asciidoc b/docs/reference/modules.asciidoc index 09ffb06fb68..5ef8a41d3f5 100644 --- a/docs/reference/modules.asciidoc +++ b/docs/reference/modules.asciidoc @@ -67,10 +67,10 @@ The modules in this section are: Configure the transport networking layer, used internally by Elasticsearch to communicate between nodes. - + <>:: - A tribe node joins one or more clusters and acts as a federated + A tribe node joins one or more clusters and acts as a federated client across them. -- @@ -93,8 +93,6 @@ include::modules/plugins.asciidoc[] include::modules/scripting.asciidoc[] -include::modules/advanced-scripting.asciidoc[] - include::modules/snapshots.asciidoc[] include::modules/threadpool.asciidoc[] diff --git a/docs/reference/modules/node.asciidoc b/docs/reference/modules/node.asciidoc index 5e40522264a..0117d193043 100644 --- a/docs/reference/modules/node.asciidoc +++ b/docs/reference/modules/node.asciidoc @@ -1,32 +1,271 @@ [[modules-node]] == Node -*elasticsearch* allows to configure a node to either be allowed to store -data locally or not. Storing data locally basically means that shards of -different indices are allowed to be allocated on that node. By default, -each node is considered to be a data node, and it can be turned off by -setting `node.data` to `false`. +Any time that you start an instance of Elasticsearch, you are starting a +_node_. A collection of connected nodes is called a +<>. If you are running a single node of Elasticsearch, +then you have a cluster of one node. -This is a powerful setting allowing to simply create smart load -balancers that take part in some of different API processing. Lets take -an example: +Every node in the cluster can handle <> and +<> traffic by default. The transport layer +is used exclusively for communication between nodes and between nodes and the +{javaclient}/transport-client.html[Java `TransportClient`]; the HTTP layer is +used only by external REST clients. -We can start a whole cluster of data nodes which do not even start an -HTTP transport by setting `http.enabled` to `false`. Such nodes will -communicate with one another using the -<> module. In front -of the cluster we can start one or more "non data" nodes which will -start with HTTP enabled. All HTTP communication will be performed -through these "non data" nodes. +All nodes know about all the other nodes in the cluster and can forward client +requests to the appropriate node. Besides that, each node serves one or more +purpose: -The benefit of using that is first the ability to create smart load -balancers. These "non data" nodes are still part of the cluster, and -they redirect operations exactly to the node that holds the relevant -data. The other benefit is the fact that for scatter / gather based -operations (such as search), these nodes will take part of the -processing since they will start the scatter process, and perform the -actual gather processing. +<>:: + +A node that has `node.master` set to `true` (default), which makes it eligible +to be <>, which controls +the cluster. + +<>:: + +A node that has `node.data` set to `true` (default). Data nodes hold data and +perform data related operations such as CRUD, search, and aggregations. + +<>:: + +A client node has both `node.master` and `node.data` set to `false`. It can +neither hold data nor become the master node. It behaves as a ``smart +router'' and is used to forward cluster-level requests to the master node and +data-related requests (such as search) to the appropriate data nodes. + +<>:: + +A tribe node, configured via the `tribe.*` settings, is a special type of +client node that can connect to multiple clusters and perform search and other +operations across all connected clusters. + +By default a node is both a master-eligible node and a data node. This is very +convenient for small clusters but, as the cluster grows, it becomes important +to consider separating dedicated master-eligible nodes from dedicated data +nodes. + +[NOTE] +[[coordinating-node]] +.Coordinating node +=============================================== + +Requests like search requests or bulk-indexing requests may involve data held +on different data nodes. A search request, for example, is executed in two +phases which are coordinated by the node which receives the client request -- +the _coordinating node_. + +In the _scatter_ phase, the coordinating node forwards the request to the data +nodes which hold the data. Each data node executes the request locally and +returns its results to the coordinating node. In the _gather_ phase, the +coordinating node reduces each data node's results into a single global +resultset. + +This means that a _client_ node needs to have enough memory and CPU in order to +deal with the gather phase. + +=============================================== + +[float] +[[master-node]] +=== Master Eligible Node + +The master node is responsible for lightweight cluster-wide actions such as +creating or deleting an index, tracking which nodes are part of the cluster, +and deciding which shards to allocate to which nodes. It is important for +cluster health to have a stable master node. + +Any master-eligible node (all nodes by default) may be elected to become the +master node by the <>. + +Indexing and searching your data is CPU-, memory-, and I/O-intensive work +which can put pressure on a node's resources. To ensure that your master +node is stable and not under pressure, it is a good idea in a bigger +cluster to split the roles between dedicated master-eligible nodes and +dedicated data nodes. + +While master nodes can also behave as <> +and route search and indexing requests from clients to data nodes, it is +better _not_ to use dedicated master nodes for this purpose. It is important +for the stability of the cluster that master-eligible nodes do as little work +as possible. + +To create a standalone master-eligible node, set: + +[source,yaml] +------------------- +node.master: true <1> +node.data: false <2> +------------------- +<1> The `node.master` role is enabled by default. +<2> Disable the `node.data` role (enabled by default). + +[float] +[[split-brain]] +==== Avoiding split brain with `minimum_master_nodes` + +To prevent data loss, it is vital to configure the +`discovery.zen.minimum_master_nodes` setting (which defaults to `1`) so that +each master-eligible node knows the _minimum number of master-eligible nodes_ +that must be visible in order to form a cluster. + +To explain, imagine that you have a cluster consisting of two master-eligible +nodes. A network failure breaks communication between these two nodes. Each +node sees one master-eligible node... itself. With `minimum_master_nodes` set +to the default of `1`, this is sufficient to form a cluster. Each node elects +itself as the new master (thinking that the other master-eligible node has +died) and the result is two clusters, or a _split brain_. These two nodes +will never rejoin until one node is restarted. Any data that has been written +to the restarted node will be lost. + +Now imagine that you have a cluster with three master-eligible nodes, and +`minimum_master_nodes` set to `2`. If a network split separates one node from +the other two nodes, the side with one node cannot see enough master-eligible +nodes and will realise that it cannot elect itself as master. The side with +two nodes will elect a new master (if needed) and continue functioning +correctly. As soon as the network split is resolved, the single node will +rejoin the cluster and start serving requests again. + +This setting should be set to a _quorum_ of master-eligible nodes: + + (master_eligible_nodes / 2) + 1 + +In other words, if there are three master-eligible nodes, then minimum master +nodes should be set to `(3 / 2) + 1` or `2`: + +[source,yaml] +---------------------------- +discovery.zen.minimum_master_nodes: 2 <1> +---------------------------- +<1> Defaults to `1`. + +This setting can also be changed dynamically on a live cluster with the +<>: + +[source,js] +---------------------------- +PUT _cluster/settings +{ + "transient": { + "discovery.zen.minimum_master_nodes": 2 + } +} +---------------------------- +// AUTOSENSE + +TIP: An advantage of splitting the master and data roles between dedicated +nodes is that you can have just three master-eligible nodes and set +`minimum_master_nodes` to `2`. You never have to change this setting, no +matter how many dedicated data nodes you add to the cluster. + + +[float] +[[data-node]] +=== Data Node + +Data nodes hold the shards that contain the documents you have indexed. Data +nodes handle data related operations like CRUD, search, and aggregations. +These operations are I/O-, memory-, and CPU-intensive. It is important to +monitor these resources and to add more data nodes if they are overloaded. + +The main benefit of having dedicated data nodes is the separation of the +master and data roles. + +To create a dedicated data node, set: + +[source,yaml] +------------------- +node.master: false <1> +node.data: true <2> +------------------- +<1> Disable the `node.master` role (enabled by default). +<2> The `node.data` role is enabled by default. + +[float] +[[client-node]] +=== Client Node + +If you take away the ability to be able to handle master duties and take away +the ability to hold data, then you are left with a _client_ node that can only +route requests, handle the search reduce phase, and distribute bulk indexing. +Essentially, client nodes behave as smart load balancers. + +Standalone client nodes can benefit large clusters by offloading the +coordinating node role from data and master-eligible nodes. Client nodes join +the cluster and receive the full <>, like every +other node, and they use the cluster state to route requests directly to the +appropriate place(s). + +WARNING: Adding too many client nodes to a cluster can increase the burden on +the entire cluster because the elected master node must await acknowledgement +of cluster state updates from every node! The benefit of client nodes should +not be overstated -- data nodes can happily serve the same purpose as client +nodes. + +To create a deciated client node, set: + +[source,yaml] +------------------- +node.master: false <1> +node.data: false <2> +------------------- +<1> Disable the `node.master` role (enabled by default). +<2> Disable the `node.data` role (enabled by default). + +[float] +== Node data path settings + +[float] +[[data-path]] +=== `path.data` + +Every data and master-eligible node requires access to a data directory where +shards and index and cluster metadata will be stored. The `path.data` defaults +to `$ES_HOME/data` but can be configured in the `elasticsearch.yml` config +file an absolute path or a path relative to `$ES_HOME` as follows: + +[source,yaml] +----------------------- +path.data: /var/elasticsearch/data +----------------------- + +Like all node settings, it can also be specified on the command line as: + +[source,sh] +----------------------- +./bin/elasticsearch --path.data /var/elasticsearch/data +----------------------- + +TIP: When using the `.zip` or `.tar.gz` distributions, the `path.data` setting +should be configured to locate the data directory outside the Elasticsearch +home directory, so that the home directory can be deleted without deleting +your data! The RPM and Debian distributions do this for you already. + + +[float] +[[max-local-storage-nodes]] +=== `node.max_local_storage_nodes` + +The <> can be shared by multiple nodes, even by nodes +from different clusters. This is very useful for testing failover and +different configurations on your development machine. In production, however, +it is recommended to run only one node of Elasticsearch per server. + +To prevent more than one node from sharing the same data path, add this +setting to the `elasticsearch.yml` config file: + +[source,yaml] +------------------------------ +node.max_local_storage_nodes: 1 +------------------------------ + +WARNING: Never run different node types (i.e. master, data, client) from the +same data directory. This can lead to unexpected data loss. + +[float] +== Other node settings + +More node settings can be found in <>. Of particular note are +the <>, the <> and the +<>. -This relieves the data nodes to do the heavy duty of indexing and -searching, without needing to process HTTP requests (parsing), overload -the network, or perform the gather processing. diff --git a/docs/reference/modules/scripting.asciidoc b/docs/reference/modules/scripting.asciidoc index 4f9d84f34f8..f4374a0f9b3 100644 --- a/docs/reference/modules/scripting.asciidoc +++ b/docs/reference/modules/scripting.asciidoc @@ -1,691 +1,6 @@ -[[modules-scripting]] -== Scripting +include::scripting/scripting.asciidoc[] -The scripting module allows to use scripts in order to evaluate custom -expressions. For example, scripts can be used to return "script fields" -as part of a search request, or can be used to evaluate a custom score -for a query and so on. +include::scripting/advanced-scripting.asciidoc[] -The scripting module uses by default http://groovy-lang.org/[groovy] -(previously http://mvel.codehaus.org/[mvel] in 1.3.x and earlier) as the -scripting language with some extensions. Groovy is used since it is extremely -fast and very simple to use. +include::scripting/security.asciidoc[] -.Groovy dynamic scripting off by default from v1.4.3 -[IMPORTANT] -=================================================== - -Groovy dynamic scripting is off by default, preventing dynamic Groovy scripts -from being accepted as part of a request or retrieved from the special -`.scripts` index. You will still be able to use Groovy scripts stored in files -in the `config/scripts/` directory on every node. - -To convert an inline script to a file, take this simple script -as an example: - -[source,js] ------------------------------------ -GET /_search -{ - "script_fields": { - "my_field": { - "inline": "1 + my_var", - "params": { - "my_var": 2 - } - } - } -} ------------------------------------ - -Save the contents of the `inline` field as a file called `config/scripts/my_script.groovy` -on every data node in the cluster: - -[source,js] ------------------------------------ -1 + my_var ------------------------------------ - -Now you can access the script by file name (without the extension): - -[source,js] ------------------------------------ -GET /_search -{ - "script_fields": { - "my_field": { - "script": { - "file": "my_script", - "params": { - "my_var": 2 - } - } - } - } -} ------------------------------------ - -=================================================== - - -Additional `lang` plugins are provided to allow to execute scripts in -different languages. All places where a script can be used, a `lang` parameter -can be provided to define the language of the script. The following are the -supported scripting languages: - -[cols="<,<,<",options="header",] -|======================================================================= -|Language |Sandboxed |Required plugin -|groovy |no |built-in -|expression |yes |built-in -|mustache |yes |built-in -|javascript |no |{plugins}/lang-javascript.html[elasticsearch-lang-javascript] -|python |no |{plugins}/lang-python.html[elasticsearch-lang-python] -|======================================================================= - -To increase security, Elasticsearch does not allow you to specify scripts for -non-sandboxed languages with a request. Instead, scripts must be placed in the -`scripts` directory inside the configuration directory (the directory where -elasticsearch.yml is). The default location of this `scripts` directory can be -changed by setting `path.scripts` in elasticsearch.yml. Scripts placed into -this directory will automatically be picked up and be available to be used. -Once a script has been placed in this directory, it can be referenced by name. -For example, a script called `calculate-score.groovy` can be referenced in a -request like this: - -[source,sh] --------------------------------------------------- -$ tree config -config -├── elasticsearch.yml -├── logging.yml -└── scripts - └── calculate-score.groovy --------------------------------------------------- - -[source,sh] --------------------------------------------------- -$ cat config/scripts/calculate-score.groovy -log(_score * 2) + my_modifier --------------------------------------------------- - -[source,js] --------------------------------------------------- -curl -XPOST localhost:9200/_search -d '{ - "query": { - "function_score": { - "query": { - "match": { - "body": "foo" - } - }, - "functions": [ - { - "script_score": { - "script": { - "lang": "groovy", - "file": "calculate-score", - "params": { - "my_modifier": 8 - } - } - } - } - ] - } - } -}' --------------------------------------------------- - -The name of the script is derived from the hierarchy of directories it -exists under, and the file name without the lang extension. For example, -a script placed under `config/scripts/group1/group2/test.py` will be -named `group1_group2_test`. - -[float] -=== Indexed Scripts -Elasticsearch allows you to store scripts in an internal index known as -`.scripts` and reference them by id. There are REST endpoints to manage -indexed scripts as follows: - -Requests to the scripts endpoint look like : -[source,js] ------------------------------------ -/_scripts/{lang}/{id} ------------------------------------ -Where the `lang` part is the language the script is in and the `id` part is the id -of the script. In the `.scripts` index the type of the document will be set to the `lang`. - - -[source,js] ------------------------------------ -curl -XPOST localhost:9200/_scripts/groovy/indexedCalculateScore -d '{ - "script": "log(_score * 2) + my_modifier" -}' ------------------------------------ - -This will create a document with id: `indexedCalculateScore` and type: `groovy` in the -`.scripts` index. The type of the document is the language used by the script. - -This script can be accessed at query time by using the `id` script parameter and passing -the script id: - -[source,js] --------------------------------------------------- -curl -XPOST localhost:9200/_search -d '{ - "query": { - "function_score": { - "query": { - "match": { - "body": "foo" - } - }, - "functions": [ - { - "script_score": { - "script": { - "id": "indexedCalculateScore", - "lang" : "groovy", - "params": { - "my_modifier": 8 - } - } - } - } - ] - } - } -}' --------------------------------------------------- - -The script can be viewed by: -[source,js] ------------------------------------ -curl -XGET localhost:9200/_scripts/groovy/indexedCalculateScore ------------------------------------ - -This is rendered as: - -[source,js] ------------------------------------ -'{ - "script": "log(_score * 2) + my_modifier" -}' ------------------------------------ - -Indexed scripts can be deleted by: -[source,js] ------------------------------------ -curl -XDELETE localhost:9200/_scripts/groovy/indexedCalculateScore ------------------------------------ - - - -[float] -[[enable-dynamic-scripting]] -=== Enabling dynamic scripting - -We recommend running Elasticsearch behind an application or proxy, which -protects Elasticsearch from the outside world. If users are allowed to run -inline scripts (even in a search request) or indexed scripts, then they have -the same access to your box as the user that Elasticsearch is running as. For -this reason dynamic scripting is allowed only for sandboxed languages by default. - -First, you should not run Elasticsearch as the `root` user, as this would allow -a script to access or do *anything* on your server, without limitations. Second, -you should not expose Elasticsearch directly to users, but instead have a proxy -application inbetween. If you *do* intend to expose Elasticsearch directly to -your users, then you have to decide whether you trust them enough to run scripts -on your box or not. - -It is possible to enable scripts based on their source, for -every script engine, through the following settings that need to be added to the -`config/elasticsearch.yml` file on every node. - -[source,yaml] ------------------------------------ -script.inline: true -script.indexed: true - ------------------------------------ - -While this still allows execution of named scripts provided in the config, or -_native_ Java scripts registered through plugins, it also allows users to run -arbitrary scripts via the API. Instead of sending the name of the file as the -script, the body of the script can be sent instead or retrieved from the -`.scripts` indexed if previously stored. - -There are three possible configuration values for any of the fine-grained -script settings: - -[cols="<,<",options="header",] -|======================================================================= -|Value |Description -| `false` |scripting is turned off completely, in the context of the setting being set. -| `true` |scripting is turned on, in the context of the setting being set. -| `sandbox` |scripts may be executed only for languages that are sandboxed -|======================================================================= - -The default values are the following: - -[source,yaml] ------------------------------------ -script.inline: sandbox -script.indexed: sandbox -script.file: true - ------------------------------------ - -NOTE: Global scripting settings affect the `mustache` scripting language. -<> internally use the `mustache` language, -and will still be enabled by default as the `mustache` engine is sandboxed, -but they will be enabled/disabled according to fine-grained settings -specified in `elasticsearch.yml`. - -It is also possible to control which operations can execute scripts. The -supported operations are: - -[cols="<,<",options="header",] -|======================================================================= -|Value |Description -| `aggs` |Aggregations (wherever they may be used) -| `search` |Search api, Percolator api and Suggester api (e.g filters, script_fields) -| `update` |Update api -| `plugin` |Any plugin that makes use of scripts under the generic `plugin` category -|======================================================================= - -Plugins can also define custom operations that they use scripts for instead -of using the generic `plugin` category. Those operations can be referred to -in the following form: `${pluginName}_${operation}`. - -The following example disables scripting for `update` and `mapping` operations, -regardless of the script source, for any engine. Scripts can still be -executed from sandboxed languages as part of `aggregations`, `search` -and plugins execution though, as the above defaults still get applied. - -[source,yaml] ------------------------------------ -script.update: false -script.mapping: false - ------------------------------------ - -Generic settings get applied in order, operation based ones have precedence -over source based ones. Language specific settings are supported too. They -need to be prefixed with the `script.engine.` prefix and have -precedence over any other generic settings. - -[source,yaml] ------------------------------------ -script.engine.groovy.file.aggs: true -script.engine.groovy.file.mapping: true -script.engine.groovy.file.search: true -script.engine.groovy.file.update: true -script.engine.groovy.file.plugin: true -script.engine.groovy.indexed.aggs: true -script.engine.groovy.indexed.mapping: false -script.engine.groovy.indexed.search: true -script.engine.groovy.indexed.update: false -script.engine.groovy.indexed.plugin: false -script.engine.groovy.inline.aggs: true -script.engine.groovy.inline.mapping: false -script.engine.groovy.inline.search: false -script.engine.groovy.inline.update: false -script.engine.groovy.inline.plugin: false - ------------------------------------ - -[float] -=== Default Scripting Language - -The default scripting language (assuming no `lang` parameter is provided) is -`groovy`. In order to change it, set the `script.default_lang` to the -appropriate language. - -[float] -=== Automatic Script Reloading - -The `config/scripts` directory is scanned periodically for changes. -New and changed scripts are reloaded and deleted script are removed -from preloaded scripts cache. The reload frequency can be specified -using `resource.reload.interval` setting, which defaults to `60s`. -To disable script reloading completely set `script.auto_reload_enabled` -to `false`. - -[[native-java-scripts]] -[float] -=== Native (Java) Scripts - -Sometimes `groovy` and `expressions` aren't enough. For those times you can -implement a native script. - -The best way to implement a native script is to write a plugin and install it. -The plugin {plugins}/plugin-authors.html[documentation] has more information on -how to write a plugin so that Elasticsearch will properly load it. - -To register the actual script you'll need to implement `NativeScriptFactory` -to construct the script. The actual script will extend either -`AbstractExecutableScript` or `AbstractSearchScript`. The second one is likely -the most useful and has several helpful subclasses you can extend like -`AbstractLongSearchScript`, `AbstractDoubleSearchScript`, and -`AbstractFloatSearchScript`. Finally, your plugin should register the native -script by declaring the `onModule(ScriptModule)` method. - -If you squashed the whole thing into one class it'd look like: - -[source,java] --------------------------------------------------- -public class MyNativeScriptPlugin extends Plugin { - @Override - public String name() { - return "my-native-script"; - } - @Override - public String description() { - return "my native script that does something great"; - } - public void onModule(ScriptModule scriptModule) { - scriptModule.registerScript("my_script", MyNativeScriptFactory.class); - } - - public static class MyNativeScriptFactory implements NativeScriptFactory { - @Override - public ExecutableScript newScript(@Nullable Map params) { - return new MyNativeScript(); - } - @Override - public boolean needsScores() { - return false; - } - } - - public static class MyNativeScript extends AbstractFloatSearchScript { - @Override - public float runAsFloat() { - float a = (float) source().get("a"); - float b = (float) source().get("b"); - return a * b; - } - } -} --------------------------------------------------- - -You can execute the script by specifying its `lang` as `native`, and the name -of the script as the `id`: - -[source,js] --------------------------------------------------- -curl -XPOST localhost:9200/_search -d '{ - "query": { - "function_score": { - "query": { - "match": { - "body": "foo" - } - }, - "functions": [ - { - "script_score": { - "script": { - "id": "my_script", - "lang" : "native" - } - } - } - ] - } - } -}' --------------------------------------------------- - - -[float] -=== Lucene Expressions Scripts - -experimental[The Lucene expressions module is undergoing significant development and the exposed functionality is likely to change in the future] - -Lucene's expressions module provides a mechanism to compile a -`javascript` expression to bytecode. This allows very fast execution, -as if you had written a `native` script. Expression scripts can be -used in `script_score`, `script_fields`, sort scripts and numeric aggregation scripts. - -See the link:http://lucene.apache.org/core/4_9_0/expressions/index.html?org/apache/lucene/expressions/js/package-summary.html[expressions module documentation] -for details on what operators and functions are available. - -Variables in `expression` scripts are available to access: - -* Single valued document fields, e.g. `doc['myfield'].value` -* Single valued document fields can also be accessed without `.value` e.g. `doc['myfield']` -* Parameters passed into the script, e.g. `mymodifier` -* The current document's score, `_score` (only available when used in a `script_score`) - -Variables in `expression` scripts that are of type `date` may use the following member methods: - -* getYear() -* getMonth() -* getDayOfMonth() -* getHourOfDay() -* getMinutes() -* getSeconds() - -The following example shows the difference in years between the `date` fields date0 and date1: - -`doc['date1'].getYear() - doc['date0'].getYear()` - -There are a few limitations relative to other script languages: - -* Only numeric fields may be accessed -* Stored fields are not available -* If a field is sparse (only some documents contain a value), documents missing the field will have a value of `0` - -[float] -=== Score - -In all scripts that can be used in aggregations, the current -document's score is accessible in `_score`. - -[float] -=== Computing scores based on terms in scripts - -see <> - -[float] -=== Document Fields - -Most scripting revolve around the use of specific document fields data. -The `doc['field_name']` can be used to access specific field data within -a document (the document in question is usually derived by the context -the script is used). Document fields are very fast to access since they -end up being loaded into memory (all the relevant field values/tokens -are loaded to memory). Note, however, that the `doc[...]` notation only -allows for simple valued fields (can’t return a json object from it) -and makes sense only on non-analyzed or single term based fields. - -The following data can be extracted from a field: - -[cols="<,<",options="header",] -|======================================================================= -|Expression |Description -|`doc['field_name'].value` |The native value of the field. For example, -if its a short type, it will be short. - -|`doc['field_name'].values` |The native array values of the field. For -example, if its a short type, it will be short[]. Remember, a field can -have several values within a single doc. Returns an empty array if the -field has no values. - -|`doc['field_name'].empty` |A boolean indicating if the field has no -values within the doc. - -|`doc['field_name'].multiValued` |A boolean indicating that the field -has several values within the corpus. - -|`doc['field_name'].lat` |The latitude of a geo point type. - -|`doc['field_name'].lon` |The longitude of a geo point type. - -|`doc['field_name'].lats` |The latitudes of a geo point type. - -|`doc['field_name'].lons` |The longitudes of a geo point type. - -|`doc['field_name'].distance(lat, lon)` |The `plane` distance (in meters) -of this geo point field from the provided lat/lon. - -|`doc['field_name'].distanceWithDefault(lat, lon, default)` |The `plane` distance (in meters) -of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].distanceInMiles(lat, lon)` |The `plane` distance (in -miles) of this geo point field from the provided lat/lon. - -|`doc['field_name'].distanceInMilesWithDefault(lat, lon, default)` |The `plane` distance (in -miles) of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].distanceInKm(lat, lon)` |The `plane` distance (in -km) of this geo point field from the provided lat/lon. - -|`doc['field_name'].distanceInKmWithDefault(lat, lon, default)` |The `plane` distance (in -km) of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].arcDistance(lat, lon)` |The `arc` distance (in -meters) of this geo point field from the provided lat/lon. - -|`doc['field_name'].arcDistanceWithDefault(lat, lon, default)` |The `arc` distance (in -meters) of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].arcDistanceInMiles(lat, lon)` |The `arc` distance (in -miles) of this geo point field from the provided lat/lon. - -|`doc['field_name'].arcDistanceInMilesWithDefault(lat, lon, default)` |The `arc` distance (in -miles) of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].arcDistanceInKm(lat, lon)` |The `arc` distance (in -km) of this geo point field from the provided lat/lon. - -|`doc['field_name'].arcDistanceInKmWithDefault(lat, lon, default)` |The `arc` distance (in -km) of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].factorDistance(lat, lon)` |The distance factor of this geo point field from the provided lat/lon. - -|`doc['field_name'].factorDistance(lat, lon, default)` |The distance factor of this geo point field from the provided lat/lon with a default value. - -|`doc['field_name'].geohashDistance(geohash)` |The `arc` distance (in meters) -of this geo point field from the provided geohash. - -|`doc['field_name'].geohashDistanceInKm(geohash)` |The `arc` distance (in km) -of this geo point field from the provided geohash. - -|`doc['field_name'].geohashDistanceInMiles(geohash)` |The `arc` distance (in -miles) of this geo point field from the provided geohash. -|======================================================================= - -[float] -=== Stored Fields - -Stored fields can also be accessed when executing a script. Note, they -are much slower to access compared with document fields, as they are not -loaded into memory. They can be simply accessed using -`_fields['my_field_name'].value` or `_fields['my_field_name'].values`. - -[float] -=== Accessing the score of a document within a script - -When using scripting for calculating the score of a document (for instance, with -the `function_score` query), you can access the score using the `_score` -variable inside of a Groovy script. - -[float] -=== Source Field - -The source field can also be accessed when executing a script. The -source field is loaded per doc, parsed, and then provided to the script -for evaluation. The `_source` forms the context under which the source -field can be accessed, for example `_source.obj2.obj1.field3`. - -Accessing `_source` is much slower compared to using `doc` -but the data is not loaded into memory. For a single field access `_fields` may be -faster than using `_source` due to the extra overhead of potentially parsing large documents. -However, `_source` may be faster if you access multiple fields or if the source has already been -loaded for other purposes. - - -[float] -=== Groovy Built In Functions - -There are several built in functions that can be used within scripts. -They include: - -[cols="<,<",options="header",] -|======================================================================= -|Function |Description -|`sin(a)` |Returns the trigonometric sine of an angle. - -|`cos(a)` |Returns the trigonometric cosine of an angle. - -|`tan(a)` |Returns the trigonometric tangent of an angle. - -|`asin(a)` |Returns the arc sine of a value. - -|`acos(a)` |Returns the arc cosine of a value. - -|`atan(a)` |Returns the arc tangent of a value. - -|`toRadians(angdeg)` |Converts an angle measured in degrees to an -approximately equivalent angle measured in radians - -|`toDegrees(angrad)` |Converts an angle measured in radians to an -approximately equivalent angle measured in degrees. - -|`exp(a)` |Returns Euler's number _e_ raised to the power of value. - -|`log(a)` |Returns the natural logarithm (base _e_) of a value. - -|`log10(a)` |Returns the base 10 logarithm of a value. - -|`sqrt(a)` |Returns the correctly rounded positive square root of a -value. - -|`cbrt(a)` |Returns the cube root of a double value. - -|`IEEEremainder(f1, f2)` |Computes the remainder operation on two -arguments as prescribed by the IEEE 754 standard. - -|`ceil(a)` |Returns the smallest (closest to negative infinity) value -that is greater than or equal to the argument and is equal to a -mathematical integer. - -|`floor(a)` |Returns the largest (closest to positive infinity) value -that is less than or equal to the argument and is equal to a -mathematical integer. - -|`rint(a)` |Returns the value that is closest in value to the argument -and is equal to a mathematical integer. - -|`atan2(y, x)` |Returns the angle _theta_ from the conversion of -rectangular coordinates (_x_, _y_) to polar coordinates (r,_theta_). - -|`pow(a, b)` |Returns the value of the first argument raised to the -power of the second argument. - -|`round(a)` |Returns the closest _int_ to the argument. - -|`random()` |Returns a random _double_ value. - -|`abs(a)` |Returns the absolute value of a value. - -|`max(a, b)` |Returns the greater of two values. - -|`min(a, b)` |Returns the smaller of two values. - -|`ulp(d)` |Returns the size of an ulp of the argument. - -|`signum(d)` |Returns the signum function of the argument. - -|`sinh(x)` |Returns the hyperbolic sine of a value. - -|`cosh(x)` |Returns the hyperbolic cosine of a value. - -|`tanh(x)` |Returns the hyperbolic tangent of a value. - -|`hypot(x, y)` |Returns sqrt(_x2_ + _y2_) without intermediate overflow -or underflow. -|======================================================================= diff --git a/docs/reference/modules/advanced-scripting.asciidoc b/docs/reference/modules/scripting/advanced-scripting.asciidoc similarity index 100% rename from docs/reference/modules/advanced-scripting.asciidoc rename to docs/reference/modules/scripting/advanced-scripting.asciidoc diff --git a/docs/reference/modules/scripting/scripting.asciidoc b/docs/reference/modules/scripting/scripting.asciidoc new file mode 100644 index 00000000000..4f9d84f34f8 --- /dev/null +++ b/docs/reference/modules/scripting/scripting.asciidoc @@ -0,0 +1,691 @@ +[[modules-scripting]] +== Scripting + +The scripting module allows to use scripts in order to evaluate custom +expressions. For example, scripts can be used to return "script fields" +as part of a search request, or can be used to evaluate a custom score +for a query and so on. + +The scripting module uses by default http://groovy-lang.org/[groovy] +(previously http://mvel.codehaus.org/[mvel] in 1.3.x and earlier) as the +scripting language with some extensions. Groovy is used since it is extremely +fast and very simple to use. + +.Groovy dynamic scripting off by default from v1.4.3 +[IMPORTANT] +=================================================== + +Groovy dynamic scripting is off by default, preventing dynamic Groovy scripts +from being accepted as part of a request or retrieved from the special +`.scripts` index. You will still be able to use Groovy scripts stored in files +in the `config/scripts/` directory on every node. + +To convert an inline script to a file, take this simple script +as an example: + +[source,js] +----------------------------------- +GET /_search +{ + "script_fields": { + "my_field": { + "inline": "1 + my_var", + "params": { + "my_var": 2 + } + } + } +} +----------------------------------- + +Save the contents of the `inline` field as a file called `config/scripts/my_script.groovy` +on every data node in the cluster: + +[source,js] +----------------------------------- +1 + my_var +----------------------------------- + +Now you can access the script by file name (without the extension): + +[source,js] +----------------------------------- +GET /_search +{ + "script_fields": { + "my_field": { + "script": { + "file": "my_script", + "params": { + "my_var": 2 + } + } + } + } +} +----------------------------------- + +=================================================== + + +Additional `lang` plugins are provided to allow to execute scripts in +different languages. All places where a script can be used, a `lang` parameter +can be provided to define the language of the script. The following are the +supported scripting languages: + +[cols="<,<,<",options="header",] +|======================================================================= +|Language |Sandboxed |Required plugin +|groovy |no |built-in +|expression |yes |built-in +|mustache |yes |built-in +|javascript |no |{plugins}/lang-javascript.html[elasticsearch-lang-javascript] +|python |no |{plugins}/lang-python.html[elasticsearch-lang-python] +|======================================================================= + +To increase security, Elasticsearch does not allow you to specify scripts for +non-sandboxed languages with a request. Instead, scripts must be placed in the +`scripts` directory inside the configuration directory (the directory where +elasticsearch.yml is). The default location of this `scripts` directory can be +changed by setting `path.scripts` in elasticsearch.yml. Scripts placed into +this directory will automatically be picked up and be available to be used. +Once a script has been placed in this directory, it can be referenced by name. +For example, a script called `calculate-score.groovy` can be referenced in a +request like this: + +[source,sh] +-------------------------------------------------- +$ tree config +config +├── elasticsearch.yml +├── logging.yml +└── scripts + └── calculate-score.groovy +-------------------------------------------------- + +[source,sh] +-------------------------------------------------- +$ cat config/scripts/calculate-score.groovy +log(_score * 2) + my_modifier +-------------------------------------------------- + +[source,js] +-------------------------------------------------- +curl -XPOST localhost:9200/_search -d '{ + "query": { + "function_score": { + "query": { + "match": { + "body": "foo" + } + }, + "functions": [ + { + "script_score": { + "script": { + "lang": "groovy", + "file": "calculate-score", + "params": { + "my_modifier": 8 + } + } + } + } + ] + } + } +}' +-------------------------------------------------- + +The name of the script is derived from the hierarchy of directories it +exists under, and the file name without the lang extension. For example, +a script placed under `config/scripts/group1/group2/test.py` will be +named `group1_group2_test`. + +[float] +=== Indexed Scripts +Elasticsearch allows you to store scripts in an internal index known as +`.scripts` and reference them by id. There are REST endpoints to manage +indexed scripts as follows: + +Requests to the scripts endpoint look like : +[source,js] +----------------------------------- +/_scripts/{lang}/{id} +----------------------------------- +Where the `lang` part is the language the script is in and the `id` part is the id +of the script. In the `.scripts` index the type of the document will be set to the `lang`. + + +[source,js] +----------------------------------- +curl -XPOST localhost:9200/_scripts/groovy/indexedCalculateScore -d '{ + "script": "log(_score * 2) + my_modifier" +}' +----------------------------------- + +This will create a document with id: `indexedCalculateScore` and type: `groovy` in the +`.scripts` index. The type of the document is the language used by the script. + +This script can be accessed at query time by using the `id` script parameter and passing +the script id: + +[source,js] +-------------------------------------------------- +curl -XPOST localhost:9200/_search -d '{ + "query": { + "function_score": { + "query": { + "match": { + "body": "foo" + } + }, + "functions": [ + { + "script_score": { + "script": { + "id": "indexedCalculateScore", + "lang" : "groovy", + "params": { + "my_modifier": 8 + } + } + } + } + ] + } + } +}' +-------------------------------------------------- + +The script can be viewed by: +[source,js] +----------------------------------- +curl -XGET localhost:9200/_scripts/groovy/indexedCalculateScore +----------------------------------- + +This is rendered as: + +[source,js] +----------------------------------- +'{ + "script": "log(_score * 2) + my_modifier" +}' +----------------------------------- + +Indexed scripts can be deleted by: +[source,js] +----------------------------------- +curl -XDELETE localhost:9200/_scripts/groovy/indexedCalculateScore +----------------------------------- + + + +[float] +[[enable-dynamic-scripting]] +=== Enabling dynamic scripting + +We recommend running Elasticsearch behind an application or proxy, which +protects Elasticsearch from the outside world. If users are allowed to run +inline scripts (even in a search request) or indexed scripts, then they have +the same access to your box as the user that Elasticsearch is running as. For +this reason dynamic scripting is allowed only for sandboxed languages by default. + +First, you should not run Elasticsearch as the `root` user, as this would allow +a script to access or do *anything* on your server, without limitations. Second, +you should not expose Elasticsearch directly to users, but instead have a proxy +application inbetween. If you *do* intend to expose Elasticsearch directly to +your users, then you have to decide whether you trust them enough to run scripts +on your box or not. + +It is possible to enable scripts based on their source, for +every script engine, through the following settings that need to be added to the +`config/elasticsearch.yml` file on every node. + +[source,yaml] +----------------------------------- +script.inline: true +script.indexed: true + +----------------------------------- + +While this still allows execution of named scripts provided in the config, or +_native_ Java scripts registered through plugins, it also allows users to run +arbitrary scripts via the API. Instead of sending the name of the file as the +script, the body of the script can be sent instead or retrieved from the +`.scripts` indexed if previously stored. + +There are three possible configuration values for any of the fine-grained +script settings: + +[cols="<,<",options="header",] +|======================================================================= +|Value |Description +| `false` |scripting is turned off completely, in the context of the setting being set. +| `true` |scripting is turned on, in the context of the setting being set. +| `sandbox` |scripts may be executed only for languages that are sandboxed +|======================================================================= + +The default values are the following: + +[source,yaml] +----------------------------------- +script.inline: sandbox +script.indexed: sandbox +script.file: true + +----------------------------------- + +NOTE: Global scripting settings affect the `mustache` scripting language. +<> internally use the `mustache` language, +and will still be enabled by default as the `mustache` engine is sandboxed, +but they will be enabled/disabled according to fine-grained settings +specified in `elasticsearch.yml`. + +It is also possible to control which operations can execute scripts. The +supported operations are: + +[cols="<,<",options="header",] +|======================================================================= +|Value |Description +| `aggs` |Aggregations (wherever they may be used) +| `search` |Search api, Percolator api and Suggester api (e.g filters, script_fields) +| `update` |Update api +| `plugin` |Any plugin that makes use of scripts under the generic `plugin` category +|======================================================================= + +Plugins can also define custom operations that they use scripts for instead +of using the generic `plugin` category. Those operations can be referred to +in the following form: `${pluginName}_${operation}`. + +The following example disables scripting for `update` and `mapping` operations, +regardless of the script source, for any engine. Scripts can still be +executed from sandboxed languages as part of `aggregations`, `search` +and plugins execution though, as the above defaults still get applied. + +[source,yaml] +----------------------------------- +script.update: false +script.mapping: false + +----------------------------------- + +Generic settings get applied in order, operation based ones have precedence +over source based ones. Language specific settings are supported too. They +need to be prefixed with the `script.engine.` prefix and have +precedence over any other generic settings. + +[source,yaml] +----------------------------------- +script.engine.groovy.file.aggs: true +script.engine.groovy.file.mapping: true +script.engine.groovy.file.search: true +script.engine.groovy.file.update: true +script.engine.groovy.file.plugin: true +script.engine.groovy.indexed.aggs: true +script.engine.groovy.indexed.mapping: false +script.engine.groovy.indexed.search: true +script.engine.groovy.indexed.update: false +script.engine.groovy.indexed.plugin: false +script.engine.groovy.inline.aggs: true +script.engine.groovy.inline.mapping: false +script.engine.groovy.inline.search: false +script.engine.groovy.inline.update: false +script.engine.groovy.inline.plugin: false + +----------------------------------- + +[float] +=== Default Scripting Language + +The default scripting language (assuming no `lang` parameter is provided) is +`groovy`. In order to change it, set the `script.default_lang` to the +appropriate language. + +[float] +=== Automatic Script Reloading + +The `config/scripts` directory is scanned periodically for changes. +New and changed scripts are reloaded and deleted script are removed +from preloaded scripts cache. The reload frequency can be specified +using `resource.reload.interval` setting, which defaults to `60s`. +To disable script reloading completely set `script.auto_reload_enabled` +to `false`. + +[[native-java-scripts]] +[float] +=== Native (Java) Scripts + +Sometimes `groovy` and `expressions` aren't enough. For those times you can +implement a native script. + +The best way to implement a native script is to write a plugin and install it. +The plugin {plugins}/plugin-authors.html[documentation] has more information on +how to write a plugin so that Elasticsearch will properly load it. + +To register the actual script you'll need to implement `NativeScriptFactory` +to construct the script. The actual script will extend either +`AbstractExecutableScript` or `AbstractSearchScript`. The second one is likely +the most useful and has several helpful subclasses you can extend like +`AbstractLongSearchScript`, `AbstractDoubleSearchScript`, and +`AbstractFloatSearchScript`. Finally, your plugin should register the native +script by declaring the `onModule(ScriptModule)` method. + +If you squashed the whole thing into one class it'd look like: + +[source,java] +-------------------------------------------------- +public class MyNativeScriptPlugin extends Plugin { + @Override + public String name() { + return "my-native-script"; + } + @Override + public String description() { + return "my native script that does something great"; + } + public void onModule(ScriptModule scriptModule) { + scriptModule.registerScript("my_script", MyNativeScriptFactory.class); + } + + public static class MyNativeScriptFactory implements NativeScriptFactory { + @Override + public ExecutableScript newScript(@Nullable Map params) { + return new MyNativeScript(); + } + @Override + public boolean needsScores() { + return false; + } + } + + public static class MyNativeScript extends AbstractFloatSearchScript { + @Override + public float runAsFloat() { + float a = (float) source().get("a"); + float b = (float) source().get("b"); + return a * b; + } + } +} +-------------------------------------------------- + +You can execute the script by specifying its `lang` as `native`, and the name +of the script as the `id`: + +[source,js] +-------------------------------------------------- +curl -XPOST localhost:9200/_search -d '{ + "query": { + "function_score": { + "query": { + "match": { + "body": "foo" + } + }, + "functions": [ + { + "script_score": { + "script": { + "id": "my_script", + "lang" : "native" + } + } + } + ] + } + } +}' +-------------------------------------------------- + + +[float] +=== Lucene Expressions Scripts + +experimental[The Lucene expressions module is undergoing significant development and the exposed functionality is likely to change in the future] + +Lucene's expressions module provides a mechanism to compile a +`javascript` expression to bytecode. This allows very fast execution, +as if you had written a `native` script. Expression scripts can be +used in `script_score`, `script_fields`, sort scripts and numeric aggregation scripts. + +See the link:http://lucene.apache.org/core/4_9_0/expressions/index.html?org/apache/lucene/expressions/js/package-summary.html[expressions module documentation] +for details on what operators and functions are available. + +Variables in `expression` scripts are available to access: + +* Single valued document fields, e.g. `doc['myfield'].value` +* Single valued document fields can also be accessed without `.value` e.g. `doc['myfield']` +* Parameters passed into the script, e.g. `mymodifier` +* The current document's score, `_score` (only available when used in a `script_score`) + +Variables in `expression` scripts that are of type `date` may use the following member methods: + +* getYear() +* getMonth() +* getDayOfMonth() +* getHourOfDay() +* getMinutes() +* getSeconds() + +The following example shows the difference in years between the `date` fields date0 and date1: + +`doc['date1'].getYear() - doc['date0'].getYear()` + +There are a few limitations relative to other script languages: + +* Only numeric fields may be accessed +* Stored fields are not available +* If a field is sparse (only some documents contain a value), documents missing the field will have a value of `0` + +[float] +=== Score + +In all scripts that can be used in aggregations, the current +document's score is accessible in `_score`. + +[float] +=== Computing scores based on terms in scripts + +see <> + +[float] +=== Document Fields + +Most scripting revolve around the use of specific document fields data. +The `doc['field_name']` can be used to access specific field data within +a document (the document in question is usually derived by the context +the script is used). Document fields are very fast to access since they +end up being loaded into memory (all the relevant field values/tokens +are loaded to memory). Note, however, that the `doc[...]` notation only +allows for simple valued fields (can’t return a json object from it) +and makes sense only on non-analyzed or single term based fields. + +The following data can be extracted from a field: + +[cols="<,<",options="header",] +|======================================================================= +|Expression |Description +|`doc['field_name'].value` |The native value of the field. For example, +if its a short type, it will be short. + +|`doc['field_name'].values` |The native array values of the field. For +example, if its a short type, it will be short[]. Remember, a field can +have several values within a single doc. Returns an empty array if the +field has no values. + +|`doc['field_name'].empty` |A boolean indicating if the field has no +values within the doc. + +|`doc['field_name'].multiValued` |A boolean indicating that the field +has several values within the corpus. + +|`doc['field_name'].lat` |The latitude of a geo point type. + +|`doc['field_name'].lon` |The longitude of a geo point type. + +|`doc['field_name'].lats` |The latitudes of a geo point type. + +|`doc['field_name'].lons` |The longitudes of a geo point type. + +|`doc['field_name'].distance(lat, lon)` |The `plane` distance (in meters) +of this geo point field from the provided lat/lon. + +|`doc['field_name'].distanceWithDefault(lat, lon, default)` |The `plane` distance (in meters) +of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].distanceInMiles(lat, lon)` |The `plane` distance (in +miles) of this geo point field from the provided lat/lon. + +|`doc['field_name'].distanceInMilesWithDefault(lat, lon, default)` |The `plane` distance (in +miles) of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].distanceInKm(lat, lon)` |The `plane` distance (in +km) of this geo point field from the provided lat/lon. + +|`doc['field_name'].distanceInKmWithDefault(lat, lon, default)` |The `plane` distance (in +km) of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].arcDistance(lat, lon)` |The `arc` distance (in +meters) of this geo point field from the provided lat/lon. + +|`doc['field_name'].arcDistanceWithDefault(lat, lon, default)` |The `arc` distance (in +meters) of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].arcDistanceInMiles(lat, lon)` |The `arc` distance (in +miles) of this geo point field from the provided lat/lon. + +|`doc['field_name'].arcDistanceInMilesWithDefault(lat, lon, default)` |The `arc` distance (in +miles) of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].arcDistanceInKm(lat, lon)` |The `arc` distance (in +km) of this geo point field from the provided lat/lon. + +|`doc['field_name'].arcDistanceInKmWithDefault(lat, lon, default)` |The `arc` distance (in +km) of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].factorDistance(lat, lon)` |The distance factor of this geo point field from the provided lat/lon. + +|`doc['field_name'].factorDistance(lat, lon, default)` |The distance factor of this geo point field from the provided lat/lon with a default value. + +|`doc['field_name'].geohashDistance(geohash)` |The `arc` distance (in meters) +of this geo point field from the provided geohash. + +|`doc['field_name'].geohashDistanceInKm(geohash)` |The `arc` distance (in km) +of this geo point field from the provided geohash. + +|`doc['field_name'].geohashDistanceInMiles(geohash)` |The `arc` distance (in +miles) of this geo point field from the provided geohash. +|======================================================================= + +[float] +=== Stored Fields + +Stored fields can also be accessed when executing a script. Note, they +are much slower to access compared with document fields, as they are not +loaded into memory. They can be simply accessed using +`_fields['my_field_name'].value` or `_fields['my_field_name'].values`. + +[float] +=== Accessing the score of a document within a script + +When using scripting for calculating the score of a document (for instance, with +the `function_score` query), you can access the score using the `_score` +variable inside of a Groovy script. + +[float] +=== Source Field + +The source field can also be accessed when executing a script. The +source field is loaded per doc, parsed, and then provided to the script +for evaluation. The `_source` forms the context under which the source +field can be accessed, for example `_source.obj2.obj1.field3`. + +Accessing `_source` is much slower compared to using `doc` +but the data is not loaded into memory. For a single field access `_fields` may be +faster than using `_source` due to the extra overhead of potentially parsing large documents. +However, `_source` may be faster if you access multiple fields or if the source has already been +loaded for other purposes. + + +[float] +=== Groovy Built In Functions + +There are several built in functions that can be used within scripts. +They include: + +[cols="<,<",options="header",] +|======================================================================= +|Function |Description +|`sin(a)` |Returns the trigonometric sine of an angle. + +|`cos(a)` |Returns the trigonometric cosine of an angle. + +|`tan(a)` |Returns the trigonometric tangent of an angle. + +|`asin(a)` |Returns the arc sine of a value. + +|`acos(a)` |Returns the arc cosine of a value. + +|`atan(a)` |Returns the arc tangent of a value. + +|`toRadians(angdeg)` |Converts an angle measured in degrees to an +approximately equivalent angle measured in radians + +|`toDegrees(angrad)` |Converts an angle measured in radians to an +approximately equivalent angle measured in degrees. + +|`exp(a)` |Returns Euler's number _e_ raised to the power of value. + +|`log(a)` |Returns the natural logarithm (base _e_) of a value. + +|`log10(a)` |Returns the base 10 logarithm of a value. + +|`sqrt(a)` |Returns the correctly rounded positive square root of a +value. + +|`cbrt(a)` |Returns the cube root of a double value. + +|`IEEEremainder(f1, f2)` |Computes the remainder operation on two +arguments as prescribed by the IEEE 754 standard. + +|`ceil(a)` |Returns the smallest (closest to negative infinity) value +that is greater than or equal to the argument and is equal to a +mathematical integer. + +|`floor(a)` |Returns the largest (closest to positive infinity) value +that is less than or equal to the argument and is equal to a +mathematical integer. + +|`rint(a)` |Returns the value that is closest in value to the argument +and is equal to a mathematical integer. + +|`atan2(y, x)` |Returns the angle _theta_ from the conversion of +rectangular coordinates (_x_, _y_) to polar coordinates (r,_theta_). + +|`pow(a, b)` |Returns the value of the first argument raised to the +power of the second argument. + +|`round(a)` |Returns the closest _int_ to the argument. + +|`random()` |Returns a random _double_ value. + +|`abs(a)` |Returns the absolute value of a value. + +|`max(a, b)` |Returns the greater of two values. + +|`min(a, b)` |Returns the smaller of two values. + +|`ulp(d)` |Returns the size of an ulp of the argument. + +|`signum(d)` |Returns the signum function of the argument. + +|`sinh(x)` |Returns the hyperbolic sine of a value. + +|`cosh(x)` |Returns the hyperbolic cosine of a value. + +|`tanh(x)` |Returns the hyperbolic tangent of a value. + +|`hypot(x, y)` |Returns sqrt(_x2_ + _y2_) without intermediate overflow +or underflow. +|======================================================================= diff --git a/docs/reference/modules/scripting/security.asciidoc b/docs/reference/modules/scripting/security.asciidoc new file mode 100644 index 00000000000..2761fb02ad9 --- /dev/null +++ b/docs/reference/modules/scripting/security.asciidoc @@ -0,0 +1,160 @@ +[[modules-scripting-security]] +=== Scripting and the Java Security Manager + +Elasticsearch runs with the https://docs.oracle.com/javase/tutorial/essential/environment/security.html[Java Security Manager] +enabled by default. The security policy in Elasticsearch locks down the +permissions granted to each class to the bare minimum required to operate. +The benefit of doing this is that it severely limits the attack vectors +available to a hacker. + +Restricting permissions is particularly important with scripting languages +like Groovy and Javascript which are designed to do anything that can be done +in Java itself, including writing to the file system, opening sockets to +remote servers, etc. + +[float] +=== Script Classloader Whitelist + +Scripting languages are only allowed to load classes which appear in a +hardcoded whitelist that can be found in +https://github.com/elastic/elasticsearch/blob/{branch}/core/src/main/java/org/elasticsearch/script/ClassPermission.java[`org.elasticsearch.script.ClassPermission`]. + + +In a script, attempting to load a class that does not appear in the whitelist +_may_ result in a `ClassNotFoundException`, for instance this script: + +[source,json] +------------------------------ +GET _search +{ + "script_fields": { + "the_hour": { + "script": "use(java.math.BigInteger); new BigInteger(1)" + } + } +} +------------------------------ + +will return the following exception: + +[source,json] +------------------------------ +{ + "reason": { + "type": "script_exception", + "reason": "failed to run inline script [use(java.math.BigInteger); new BigInteger(1)] using lang [groovy]", + "caused_by": { + "type": "no_class_def_found_error", + "reason": "java/math/BigInteger", + "caused_by": { + "type": "class_not_found_exception", + "reason": "java.math.BigInteger" + } + } + } +} +------------------------------ + +However, classloader issues may also result in more difficult to interpret +exceptions. For instance, this script: + +[source,groovy] +------------------------------ +use(groovy.time.TimeCategory); new Date(123456789).format('HH') +------------------------------ + +Returns the following exception: + +[source,json] +------------------------------ +{ + "reason": { + "type": "script_exception", + "reason": "failed to run inline script [use(groovy.time.TimeCategory); new Date(123456789).format('HH')] using lang [groovy]", + "caused_by": { + "type": "missing_property_exception", + "reason": "No such property: groovy for class: 8d45f5c1a07a1ab5dda953234863e283a7586240" + } + } +} +------------------------------ + +[float] +== Dealing with Java Security Manager issues + +If you encounter issues with the Java Security Manager, you have three options +for resolving these issues: + +[float] +=== Fix the security problem + +The safest and most secure long term solution is to change the code causing +the security issue. We recognise that this may take time to do correctly and +so we provide the following two alternatives. + +[float] +=== Disable the Java Security Manager + +deprecated[2.2.0,The ability to disable the Java Security Manager will be removed in a future version] + +You can disable the Java Security Manager entirely with the +`security.manager.enabled` command line flag: + +[source,sh] +----------------------------- +./bin/elasticsearch --security.manager.enabled false +----------------------------- + +WARNING: This disables the Security Manager entirely and makes Elasticsearch +much more vulnerable to attacks! It is an option that should only be used in +the most urgent of situations and for the shortest amount of time possible. +Optional security is not secure at all because it **will** be disabled and +leave the system vulnerable. This option will be removed in a future version. + +[float] +=== Customising the classloader whitelist + +The classloader whitelist can be customised by tweaking the local Java +Security Policy either: + +* system wide: `$JAVA_HOME/lib/security/java.policy`, +* for just the `elasticsearch` user: `/home/elasticsearch/.java.policy`, or +* from a file specified on the command line: `-Djava.security.policy=someURL` + +Permissions may be granted at the class, package, or global level. For instance: + +[source,js] +---------------------------------- +grant { + permission org.elasticsearch.script.ClassPermission "java.util.Base64"; // allow class + permission org.elasticsearch.script.ClassPermission "java.util.*"; // allow package + permission org.elasticsearch.script.ClassPermission "*"; // allow all (disables filtering basically) +}; +---------------------------------- + +Here is an example of how to enable the `groovy.time.TimeCategory` class: + +[source,js] +---------------------------------- +grant { + permission org.elasticsearch.script.ClassPermission "java.lang.Class"; + permission org.elasticsearch.script.ClassPermission "groovy.time.TimeCategory"; +}; +---------------------------------- + +[TIP] +====================================== + +Before adding classes to the whitelist, consider the security impact that it +will have on Elasticsearch. Do you really need an extra class or can your code +be rewritten in a more secure way? + +It is quite possible that we have not whitelisted a generically useful and +safe class. If you have a class that you think should be whitelisted by +default, please open an issue on GitHub and we will consider the impact of +doing so. + +====================================== + +See http://docs.oracle.com/javase/7/docs/technotes/guides/security/PolicyFiles.html for more information. + diff --git a/docs/reference/setup/repositories.asciidoc b/docs/reference/setup/repositories.asciidoc index 70b000ec48c..7d95b2dcf20 100644 --- a/docs/reference/setup/repositories.asciidoc +++ b/docs/reference/setup/repositories.asciidoc @@ -109,7 +109,7 @@ yum install elasticsearch -------------------------------------------------- Configure Elasticsearch to automatically start during bootup. If your -distribution is using SysV init, then you will need to run: +distribution is using SysV `init` (check with `ps -p 1`), then you will need to run: WARNING: The repositories do not work with older rpm based distributions that still use RPM v3, like CentOS5. @@ -119,7 +119,7 @@ WARNING: The repositories do not work with older rpm based distributions chkconfig --add elasticsearch -------------------------------------------------- -Otherwise if your distribution is using systemd: +Otherwise if your distribution is using `systemd`: [source,sh] -------------------------------------------------- diff --git a/modules/ingest-grok/src/main/java/org/elasticsearch/ingest/grok/GrokProcessor.java b/modules/ingest-grok/src/main/java/org/elasticsearch/ingest/grok/GrokProcessor.java index 4df8d673072..b4755d61c56 100644 --- a/modules/ingest-grok/src/main/java/org/elasticsearch/ingest/grok/GrokProcessor.java +++ b/modules/ingest-grok/src/main/java/org/elasticsearch/ingest/grok/GrokProcessor.java @@ -74,9 +74,9 @@ public final class GrokProcessor extends AbstractProcessor { @Override public GrokProcessor doCreate(String processorTag, Map config) throws Exception { - String matchField = ConfigurationUtils.readStringProperty(config, "field"); - String matchPattern = ConfigurationUtils.readStringProperty(config, "pattern"); - Map customPatternBank = ConfigurationUtils.readOptionalMap(config, "pattern_definitions"); + String matchField = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "field"); + String matchPattern = ConfigurationUtils.readStringProperty(TYPE, processorTag, config, "pattern"); + Map customPatternBank = ConfigurationUtils.readOptionalMap(TYPE, processorTag, config, "pattern_definitions"); Map patternBank = new HashMap<>(builtinPatterns); if (customPatternBank != null) { patternBank.putAll(customPatternBank); diff --git a/modules/ingest-grok/src/test/java/org/elasticsearch/ingest/grok/GrokProcessorFactoryTests.java b/modules/ingest-grok/src/test/java/org/elasticsearch/ingest/grok/GrokProcessorFactoryTests.java index f6bed139552..1c36e26925d 100644 --- a/modules/ingest-grok/src/test/java/org/elasticsearch/ingest/grok/GrokProcessorFactoryTests.java +++ b/modules/ingest-grok/src/test/java/org/elasticsearch/ingest/grok/GrokProcessorFactoryTests.java @@ -20,6 +20,8 @@ package org.elasticsearch.ingest.grok; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import org.elasticsearch.test.ESTestCase; import java.util.Collections; @@ -45,6 +47,32 @@ public class GrokProcessorFactoryTests extends ESTestCase { assertThat(processor.getGrok(), notNullValue()); } + public void testBuildMissingField() throws Exception { + GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap()); + Map config = new HashMap<>(); + config.put("pattern", "(?\\w+)"); + try { + factory.create(config); + fail("should fail"); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[field] required property is missing")); + + } + } + + public void testBuildMissingPattern() throws Exception { + GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap()); + Map config = new HashMap<>(); + config.put("field", "foo"); + try { + factory.create(config); + fail("should fail"); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[pattern] required property is missing")); + } + + } + public void testCreateWithCustomPatterns() throws Exception { GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap()); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java index c78e51330e4..559e366bb41 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BucketSelectorTests.java @@ -279,7 +279,7 @@ public class BucketSelectorTests extends ESIntegTestCase { .subAggregation(sum("field3Sum").field(FIELD_3_NAME)) .subAggregation( bucketSelector("bucketSelector", bucketPathsMap, new Script("Double.isNaN(my_value1) ? false : (my_value1 + my_value2 > 100)", - ScriptType.INLINE, null, null)))).execute() + ScriptType.INLINE, null, null)))).execute() .actionGet(); assertSearchResponse(response); @@ -459,7 +459,7 @@ public class BucketSelectorTests extends ESIntegTestCase { public void testEmptyBuckets() { SearchResponse response = client().prepareSearch("idx_with_gaps") .addAggregation(histogram("histo").field(FIELD_1_NAME).interval(1) - .subAggregation(histogram("inner_histo").field(FIELD_1_NAME).interval(1).extendedBounds(new ExtendedBounds(1l, 4l)) + .subAggregation(histogram("inner_histo").field(FIELD_1_NAME).interval(1).extendedBounds(new ExtendedBounds(1L, 4L)) .minDocCount(0).subAggregation(derivative("derivative", "_count").gapPolicy(GapPolicy.INSERT_ZEROS)))) .execute().actionGet(); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java index f05938b4c98..0551a4ea3f3 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/BulkTests.java @@ -95,26 +95,26 @@ public class BulkTests extends ESIntegTestCase { assertThat(bulkItemResponse.getIndex(), equalTo("test")); } assertThat(((UpdateResponse) bulkResponse.getItems()[0].getResponse()).getId(), equalTo("1")); - assertThat(((UpdateResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(2l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(2L)); assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getId(), equalTo("2")); - assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(2l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(2L)); assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getId(), equalTo("3")); - assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(2l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(2L)); GetResponse getResponse = client().prepareGet().setIndex("test").setType("type1").setId("1").setFields("field").execute() .actionGet(); assertThat(getResponse.isExists(), equalTo(true)); - assertThat(getResponse.getVersion(), equalTo(2l)); - assertThat(((Long) getResponse.getField("field").getValue()), equalTo(2l)); + assertThat(getResponse.getVersion(), equalTo(2L)); + assertThat(((Long) getResponse.getField("field").getValue()), equalTo(2L)); getResponse = client().prepareGet().setIndex("test").setType("type1").setId("2").setFields("field").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); - assertThat(getResponse.getVersion(), equalTo(2l)); - assertThat(((Long) getResponse.getField("field").getValue()), equalTo(3l)); + assertThat(getResponse.getVersion(), equalTo(2L)); + assertThat(((Long) getResponse.getField("field").getValue()), equalTo(3L)); getResponse = client().prepareGet().setIndex("test").setType("type1").setId("3").setFields("field1").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); - assertThat(getResponse.getVersion(), equalTo(2l)); + assertThat(getResponse.getVersion(), equalTo(2L)); assertThat(getResponse.getField("field1").getValue().toString(), equalTo("test")); bulkResponse = client() @@ -131,27 +131,27 @@ public class BulkTests extends ESIntegTestCase { assertThat(bulkResponse.hasFailures(), equalTo(true)); assertThat(bulkResponse.getItems().length, equalTo(3)); assertThat(((UpdateResponse) bulkResponse.getItems()[0].getResponse()).getId(), equalTo("6")); - assertThat(((UpdateResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(1l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(1L)); assertThat(bulkResponse.getItems()[1].getResponse(), nullValue()); assertThat(bulkResponse.getItems()[1].getFailure().getIndex(), equalTo("test")); assertThat(bulkResponse.getItems()[1].getFailure().getId(), equalTo("7")); assertThat(bulkResponse.getItems()[1].getFailure().getMessage(), containsString("document missing")); assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getId(), equalTo("2")); assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getIndex(), equalTo("test")); - assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(3l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(3L)); getResponse = client().prepareGet().setIndex("test").setType("type1").setId("6").setFields("field").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); - assertThat(getResponse.getVersion(), equalTo(1l)); - assertThat(((Long) getResponse.getField("field").getValue()), equalTo(0l)); + assertThat(getResponse.getVersion(), equalTo(1L)); + assertThat(((Long) getResponse.getField("field").getValue()), equalTo(0L)); getResponse = client().prepareGet().setIndex("test").setType("type1").setId("7").setFields("field").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(false)); getResponse = client().prepareGet().setIndex("test").setType("type1").setId("2").setFields("field").execute().actionGet(); assertThat(getResponse.isExists(), equalTo(true)); - assertThat(getResponse.getVersion(), equalTo(3l)); - assertThat(((Long) getResponse.getField("field").getValue()), equalTo(4l)); + assertThat(getResponse.getVersion(), equalTo(3L)); + assertThat(((Long) getResponse.getField("field").getValue()), equalTo(4L)); } public void testBulkVersioning() throws Exception { @@ -163,20 +163,20 @@ public class BulkTests extends ESIntegTestCase { .add(client().prepareIndex("test", "type", "1").setSource("field", "2")).get(); assertTrue(((IndexResponse) bulkResponse.getItems()[0].getResponse()).isCreated()); - assertThat(((IndexResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(1l)); + assertThat(((IndexResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(1L)); assertTrue(((IndexResponse) bulkResponse.getItems()[1].getResponse()).isCreated()); - assertThat(((IndexResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(1l)); + assertThat(((IndexResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(1L)); assertFalse(((IndexResponse) bulkResponse.getItems()[2].getResponse()).isCreated()); - assertThat(((IndexResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(2l)); + assertThat(((IndexResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(2L)); bulkResponse = client().prepareBulk() - .add(client().prepareUpdate("test", "type", "1").setVersion(4l).setDoc("field", "2")) + .add(client().prepareUpdate("test", "type", "1").setVersion(4L).setDoc("field", "2")) .add(client().prepareUpdate("test", "type", "2").setDoc("field", "2")) - .add(client().prepareUpdate("test", "type", "1").setVersion(2l).setDoc("field", "3")).get(); + .add(client().prepareUpdate("test", "type", "1").setVersion(2L).setDoc("field", "3")).get(); assertThat(bulkResponse.getItems()[0].getFailureMessage(), containsString("version conflict")); - assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(2l)); - assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(3l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(2L)); + assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(3L)); bulkResponse = client().prepareBulk() .add(client().prepareIndex("test", "type", "e1").setSource("field", "1").setVersion(10).setVersionType(VersionType.EXTERNAL)) @@ -184,11 +184,11 @@ public class BulkTests extends ESIntegTestCase { .add(client().prepareIndex("test", "type", "e1").setSource("field", "2").setVersion(12).setVersionType(VersionType.EXTERNAL)).get(); assertTrue(((IndexResponse) bulkResponse.getItems()[0].getResponse()).isCreated()); - assertThat(((IndexResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(10l)); + assertThat(((IndexResponse) bulkResponse.getItems()[0].getResponse()).getVersion(), equalTo(10L)); assertTrue(((IndexResponse) bulkResponse.getItems()[1].getResponse()).isCreated()); - assertThat(((IndexResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(10l)); + assertThat(((IndexResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(10L)); assertFalse(((IndexResponse) bulkResponse.getItems()[2].getResponse()).isCreated()); - assertThat(((IndexResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(12l)); + assertThat(((IndexResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(12L)); bulkResponse = client().prepareBulk() .add(client().prepareUpdate("test", "type", "e1").setDoc("field", "2").setVersion(10)) // INTERNAL @@ -196,8 +196,8 @@ public class BulkTests extends ESIntegTestCase { .add(client().prepareUpdate("test", "type", "e1").setDoc("field", "4").setVersion(20).setVersionType(VersionType.INTERNAL)).get(); assertThat(bulkResponse.getItems()[0].getFailureMessage(), containsString("version conflict")); - assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(20l)); - assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(21l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(20L)); + assertThat(((UpdateResponse) bulkResponse.getItems()[2].getResponse()).getVersion(), equalTo(21L)); } public void testBulkUpdateMalformedScripts() throws Exception { @@ -229,7 +229,7 @@ public class BulkTests extends ESIntegTestCase { assertThat(bulkResponse.getItems()[0].getResponse(), nullValue()); assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getId(), equalTo("2")); - assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(2l)); + assertThat(((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getVersion(), equalTo(2L)); assertThat(((Integer) ((UpdateResponse) bulkResponse.getItems()[1].getResponse()).getGetResult().field("field").getValue()), equalTo(2)); assertThat(bulkResponse.getItems()[1].getFailure(), nullValue()); @@ -262,12 +262,12 @@ public class BulkTests extends ESIntegTestCase { assertThat(response.getItems().length, equalTo(numDocs)); for (int i = 0; i < numDocs; i++) { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); - assertThat(response.getItems()[i].getVersion(), equalTo(1l)); + assertThat(response.getItems()[i].getVersion(), equalTo(1L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo("update")); assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getId(), equalTo(Integer.toString(i))); - assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getVersion(), equalTo(1l)); + assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getVersion(), equalTo(1L)); assertThat(((Integer) ((UpdateResponse) response.getItems()[i].getResponse()).getGetResult().field("counter").getValue()), equalTo(1)); @@ -275,8 +275,8 @@ public class BulkTests extends ESIntegTestCase { GetResponse getResponse = client().prepareGet("test", "type1", Integer.toString(i)).setFields("counter").execute() .actionGet(); assertThat(getResponse.isExists(), equalTo(true)); - assertThat(getResponse.getVersion(), equalTo(1l)); - assertThat((Long) getResponse.getField("counter").getValue(), equalTo(1l)); + assertThat(getResponse.getVersion(), equalTo(1L)); + assertThat((Long) getResponse.getField("counter").getValue(), equalTo(1L)); } } @@ -301,12 +301,12 @@ public class BulkTests extends ESIntegTestCase { assertThat(response.getItems().length, equalTo(numDocs)); for (int i = 0; i < numDocs; i++) { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(i))); - assertThat(response.getItems()[i].getVersion(), equalTo(2l)); + assertThat(response.getItems()[i].getVersion(), equalTo(2L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo("update")); assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getId(), equalTo(Integer.toString(i))); - assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getVersion(), equalTo(2l)); + assertThat(((UpdateResponse) response.getItems()[i].getResponse()).getVersion(), equalTo(2L)); assertThat(((Integer) ((UpdateResponse) response.getItems()[i].getResponse()).getGetResult().field("counter").getValue()), equalTo(2)); } @@ -327,7 +327,7 @@ public class BulkTests extends ESIntegTestCase { assertThat(response.getItems()[i].getFailure().getMessage(), containsString("document missing")); } else { assertThat(response.getItems()[i].getId(), equalTo(Integer.toString(id))); - assertThat(response.getItems()[i].getVersion(), equalTo(3l)); + assertThat(response.getItems()[i].getVersion(), equalTo(3L)); assertThat(response.getItems()[i].getIndex(), equalTo("test")); assertThat(response.getItems()[i].getType(), equalTo("type1")); assertThat(response.getItems()[i].getOpType(), equalTo("update")); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java index 6a06e4591d8..24d1f5eabc6 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DateRangeTests.java @@ -175,7 +175,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -184,7 +184,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -193,7 +193,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } public void testSingleValueFieldWithStringDates() throws Exception { @@ -221,7 +221,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -230,7 +230,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -239,7 +239,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } public void testSingleValueFieldWithStringDatesWithCustomFormat() throws Exception { @@ -268,7 +268,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -277,7 +277,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15")); assertThat(bucket.getToAsString(), equalTo("2012-03-15")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -286,7 +286,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } public void testSingleValueFieldWithDateMath() throws Exception { @@ -314,7 +314,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -323,7 +323,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -332,7 +332,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } public void testSingleValueFieldWithCustomKey() throws Exception { @@ -360,7 +360,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -369,7 +369,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -378,7 +378,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } /* @@ -419,12 +419,12 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) 1 + 2)); assertThat((String) propertiesKeys[0], equalTo("r1")); - assertThat((long) propertiesDocCounts[0], equalTo(2l)); + assertThat((long) propertiesDocCounts[0], equalTo(2L)); assertThat((double) propertiesCounts[0], equalTo((double) 1 + 2)); bucket = buckets.get(1); @@ -434,12 +434,12 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) 3 + 4)); assertThat((String) propertiesKeys[1], equalTo("r2")); - assertThat((long) propertiesDocCounts[1], equalTo(2l)); + assertThat((long) propertiesDocCounts[1], equalTo(2L)); assertThat((double) propertiesCounts[1], equalTo((double) 3 + 4)); bucket = buckets.get(2); @@ -449,11 +449,11 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat((String) propertiesKeys[2], equalTo("r3")); - assertThat((long) propertiesDocCounts[2], equalTo(numDocs - 4l)); + assertThat((long) propertiesDocCounts[2], equalTo(numDocs - 4L)); } public void testSingleValuedFieldWithSubAggregationInherited() throws Exception { @@ -482,7 +482,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Min min = bucket.getAggregations().get("min"); assertThat(min, notNullValue()); assertThat(min.getValue(), equalTo((double) date(1, 2).getMillis())); @@ -494,7 +494,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); min = bucket.getAggregations().get("min"); assertThat(min, notNullValue()); assertThat(min.getValue(), equalTo((double) date(2, 15).getMillis())); @@ -506,7 +506,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); min = bucket.getAggregations().get("min"); assertThat(min, notNullValue()); assertThat(min.getValue(), equalTo((double) date(3, 15).getMillis())); @@ -546,7 +546,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -555,7 +555,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -564,7 +564,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 2l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 2L)); } /* @@ -600,7 +600,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -609,7 +609,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -618,7 +618,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 1l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 1L)); } @@ -655,7 +655,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) date(3, 3).getMillis())); @@ -667,7 +667,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) date(4, 3).getMillis())); @@ -679,7 +679,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 1l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 1L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); } @@ -709,7 +709,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -718,7 +718,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -727,7 +727,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } public void testScriptSingleValueWithSubAggregatorInherited() throws Exception { @@ -753,7 +753,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) date(2, 2).getMillis())); @@ -765,7 +765,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) date(3, 2).getMillis())); @@ -777,7 +777,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); } @@ -815,7 +815,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -824,7 +824,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -833,7 +833,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 2l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 2L)); } public void testScriptMultiValuedWithAggregatorInherited() throws Exception { @@ -858,7 +858,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Min min = bucket.getAggregations().get("min"); assertThat(min, notNullValue()); assertThat(min.getValue(), equalTo((double) date(1, 2).getMillis())); @@ -870,7 +870,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); min = bucket.getAggregations().get("min"); assertThat(min, notNullValue()); assertThat(min.getValue(), equalTo((double) date(2, 2).getMillis())); @@ -882,7 +882,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 2l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 2L)); min = bucket.getAggregations().get("min"); assertThat(min, notNullValue()); assertThat(min.getValue(), equalTo((double) date(2, 15).getMillis())); @@ -915,7 +915,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -924,7 +924,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -933,7 +933,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } public void testUnmappedWithStringDates() throws Exception { @@ -961,7 +961,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -970,7 +970,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -979,7 +979,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } public void testPartiallyUnmapped() throws Exception { @@ -1007,7 +1007,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(2, 15))); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("2012-02-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -1016,7 +1016,7 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), equalTo(date(3, 15))); assertThat(bucket.getFromAsString(), equalTo("2012-02-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), equalTo("2012-03-15T00:00:00.000Z")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -1025,16 +1025,16 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(((DateTime) bucket.getTo()), nullValue()); assertThat(bucket.getFromAsString(), equalTo("2012-03-15T00:00:00.000Z")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(dateRange("date_range").addRange("0-1", 0, 1))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(dateRange("date_range").addRange("0-1", 0, 1))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -1047,9 +1047,9 @@ public class DateRangeTests extends ESIntegTestCase { assertThat(dateRange.getName(), equalTo("date_range")); assertThat(buckets.size(), is(1)); assertThat((String) buckets.get(0).getKey(), equalTo("0-1")); - assertThat(((DateTime) buckets.get(0).getFrom()).getMillis(), equalTo(0l)); - assertThat(((DateTime) buckets.get(0).getTo()).getMillis(), equalTo(1l)); - assertThat(buckets.get(0).getDocCount(), equalTo(0l)); + assertThat(((DateTime) buckets.get(0).getFrom()).getMillis(), equalTo(0L)); + assertThat(((DateTime) buckets.get(0).getTo()).getMillis(), equalTo(1L)); + assertThat(buckets.get(0).getDocCount(), equalTo(0L)); assertThat(buckets.get(0).getAggregations().asList().isEmpty(), is(true)); } } diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java index de6fc52783d..8c9da22a02d 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/DoubleTermsTests.java @@ -124,43 +124,43 @@ public class DoubleTermsTests extends AbstractTermsTestCase { expectedMultiSortBuckets = new HashMap<>(); Map bucketProps = new HashMap<>(); bucketProps.put("_term", 1d); - bucketProps.put("_count", 3l); + bucketProps.put("_count", 3L); bucketProps.put("avg_l", 1d); bucketProps.put("sum_d", 6d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", 2d); - bucketProps.put("_count", 3l); + bucketProps.put("_count", 3L); bucketProps.put("avg_l", 2d); bucketProps.put("sum_d", 6d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", 3d); - bucketProps.put("_count", 2l); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 3d); bucketProps.put("sum_d", 3d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", 4d); - bucketProps.put("_count", 2l); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 3d); bucketProps.put("sum_d", 4d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", 5d); - bucketProps.put("_count", 2l); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 3d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", 6d); - bucketProps.put("_count", 1l); + bucketProps.put("_count", 1L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", 7d); - bucketProps.put("_count", 1l); + bucketProps.put("_count", 1L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); @@ -272,7 +272,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -298,7 +298,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -327,7 +327,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { for (int i = 0; i < expecteds.length; i++) { Terms.Bucket bucket = terms.getBucketByKey("" + expecteds[i]); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -352,7 +352,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); i++; } } @@ -378,7 +378,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); i--; } } @@ -407,13 +407,13 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); - assertThat((long) sum.getValue(), equalTo(i+i+1l)); + assertThat((long) sum.getValue(), equalTo(i+i+1L)); assertThat((double) propertiesKeys[i], equalTo((double) i)); - assertThat((long) propertiesDocCounts[i], equalTo(1l)); - assertThat((double) propertiesCounts[i], equalTo((double) i + i + 1l)); + assertThat((long) propertiesDocCounts[i], equalTo(1L)); + assertThat((double) propertiesCounts[i], equalTo((double) i + i + 1L)); } } @@ -438,7 +438,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) i)); @@ -466,7 +466,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (i+1d))); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i + 1)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -491,9 +491,9 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -520,9 +520,9 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(key(bucket), equalTo("" + (i+1d))); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i + 1)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -547,7 +547,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("1.0")); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(1)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); } /* @@ -624,7 +624,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -649,7 +649,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) i)); @@ -677,9 +677,9 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -780,18 +780,18 @@ public class DoubleTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double) i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1L).minDocCount(0) .subAggregation(terms("terms"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -825,7 +825,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + (double) i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo((double) i)); @@ -858,7 +858,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + (double) i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); @@ -871,7 +871,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { for (Terms.Bucket subBucket : subTermsAgg.getBuckets()) { assertThat(subBucket, notNullValue()); assertThat(key(subBucket), equalTo(String.valueOf(j))); - assertThat(subBucket.getDocCount(), equalTo(1l)); + assertThat(subBucket.getDocCount(), equalTo(1L)); j++; } } @@ -900,18 +900,18 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "0" : "1")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); Filter filter = tag.getAggregations().get("filter"); assertThat(filter, notNullValue()); - assertThat(filter.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L)); tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "1" : "0")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); filter = tag.getAggregations().get("filter"); assertThat(filter, notNullValue()); - assertThat(filter.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter.getDocCount(), equalTo(asc ? 3L : 2L)); } public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels() throws Exception { @@ -945,13 +945,13 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "1" : "0")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter2 = filter1.getAggregations().get("filter2"); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L)); Max max = filter2.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo(asc ? 2.0 : 4.0)); @@ -959,13 +959,13 @@ public class DoubleTermsTests extends AbstractTermsTestCase { tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "0" : "1")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 2L : 3L)); filter2 = filter1.getAggregations().get("filter2"); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 2L : 3L)); max = filter2.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo(asc ? 4.0 : 2.0)); @@ -1071,7 +1071,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + (double) i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); @@ -1100,7 +1100,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + (double) i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1129,7 +1129,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + (double) i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1158,7 +1158,7 @@ public class DoubleTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + (double) i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (double)i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ExtendedStats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java index b610f9648b5..855c13b0a36 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ExtendedStatsTests.java @@ -71,10 +71,10 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(extendedStats("stats"))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(extendedStats("stats"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -84,7 +84,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats, notNullValue()); assertThat(stats.getName(), equalTo("stats")); assertThat(stats.getSumOfSquares(), equalTo(0.0)); - assertThat(stats.getCount(), equalTo(0l)); + assertThat(stats.getCount(), equalTo(0L)); assertThat(stats.getSum(), equalTo(0.0)); assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY)); assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY)); @@ -101,7 +101,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { .addAggregation(extendedStats("stats").field("value")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); ExtendedStats stats = searchResponse.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -110,7 +110,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY)); assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY)); assertThat(stats.getSum(), equalTo(0.0)); - assertThat(stats.getCount(), equalTo(0l)); + assertThat(stats.getCount(), equalTo(0L)); assertThat(stats.getSumOfSquares(), equalTo(0.0)); assertThat(stats.getVariance(), equalTo(Double.NaN)); assertThat(stats.getStdDeviation(), equalTo(Double.NaN)); @@ -135,7 +135,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); @@ -159,7 +159,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); @@ -184,7 +184,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMaxAsString(), equalTo("0010.0")); assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10)); assertThat(stats.getSumAsString(), equalTo("0055.0")); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getCountAsString(), equalTo("0010.0")); assertThat(stats.getSumOfSquares(), equalTo((double) 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100)); assertThat(stats.getSumOfSquaresAsString(), equalTo("0385.0")); @@ -205,7 +205,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); @@ -258,7 +258,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))); @@ -282,7 +282,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121)); assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11))); assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11))); @@ -310,7 +310,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121)); assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11))); assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11))); @@ -334,7 +334,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(12.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121+9+16+25+36+49+64+81+100+121+144)); assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))); assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))); @@ -358,7 +358,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+4+9+16+25+36+49+64+81+100+121)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11))); @@ -386,7 +386,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+4+9+16+25+36+49+64+81+100+121)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11))); @@ -410,7 +410,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10))); @@ -437,7 +437,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121)); assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11))); assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11))); @@ -461,7 +461,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(12.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); assertThat(stats.getSumOfSquares(), equalTo((double) 4+9+16+25+36+49+64+81+100+121+9+16+25+36+49+64+81+100+121+144)); assertThat(stats.getVariance(), equalTo(variance(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12))); assertThat(stats.getStdDeviation(), equalTo(stdDev(2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12))); @@ -490,7 +490,7 @@ public class ExtendedStatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(0.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+0+1+2+3+4+5+6+7+8+9)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); assertThat(stats.getSumOfSquares(), equalTo((double) 1+4+9+16+25+36+49+64+81+100+0+1+4+9+16+25+36+49+64+81)); assertThat(stats.getVariance(), equalTo(variance(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9))); assertThat(stats.getStdDeviation(), equalTo(stdDev(1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8 ,9))); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java index 22bb778c7be..fffeabcb807 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/FunctionScoreTests.java @@ -94,7 +94,7 @@ public class FunctionScoreTests extends ESIntegTestCase { assertSearchResponse(response); assertThat(response.getHits().getAt(0).score(), equalTo(1.0f)); assertThat(((Terms) response.getAggregations().asMap().get("score_agg")).getBuckets().get(0).getKeyAsString(), equalTo("1.0")); - assertThat(((Terms) response.getAggregations().asMap().get("score_agg")).getBuckets().get(0).getDocCount(), is(1l)); + assertThat(((Terms) response.getAggregations().asMap().get("score_agg")).getBuckets().get(0).getDocCount(), is(1L)); } public void testMinScoreFunctionScoreBasic() throws IOException { @@ -109,9 +109,9 @@ public class FunctionScoreTests extends ESIntegTestCase { functionScoreQuery(scriptFunction(new Script(Float.toString(score)))).setMinScore(minScore))) ).actionGet(); if (score < minScore) { - assertThat(searchResponse.getHits().getTotalHits(), is(0l)); + assertThat(searchResponse.getHits().getTotalHits(), is(0L)); } else { - assertThat(searchResponse.getHits().getTotalHits(), is(1l)); + assertThat(searchResponse.getHits().getTotalHits(), is(1L)); } searchResponse = client().search( @@ -121,9 +121,9 @@ public class FunctionScoreTests extends ESIntegTestCase { }).scoreMode(FiltersFunctionScoreQuery.ScoreMode.AVG).setMinScore(minScore))) ).actionGet(); if (score < minScore) { - assertThat(searchResponse.getHits().getTotalHits(), is(0l)); + assertThat(searchResponse.getHits().getTotalHits(), is(0L)); } else { - assertThat(searchResponse.getHits().getTotalHits(), is(1l)); + assertThat(searchResponse.getHits().getTotalHits(), is(1L)); } } @@ -188,7 +188,7 @@ public class FunctionScoreTests extends ESIntegTestCase { searchSource().explain(true).query( functionScoreQuery(termQuery("text", "text")).boostMode(boostMode).setMinScore(0.1f)))).get(); assertSearchResponse(response); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).getScore(), equalTo(expectedScore)); response = client().search( @@ -197,7 +197,7 @@ public class FunctionScoreTests extends ESIntegTestCase { functionScoreQuery(termQuery("text", "text")).boostMode(boostMode).setMinScore(2f)))).get(); assertSearchResponse(response); - assertThat(response.getHits().totalHits(), equalTo(0l)); + assertThat(response.getHits().totalHits(), equalTo(0L)); } } diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java index c5bf370e028..7defc727bd9 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentileRanksTests.java @@ -118,14 +118,14 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase { .addAggregation( histogram("histo") .field("value") - .interval(1l) + .interval(1L) .minDocCount(0) .subAggregation( percentileRanks("percentile_ranks").method(PercentilesMethod.HDR) .numberOfSignificantValueDigits(sigDigits).values(10, 15))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -149,7 +149,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase { .field("value").values(0, 10, 15, 100)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); PercentileRanks reversePercentiles = searchResponse.getAggregations().get("percentile_ranks"); assertThat(reversePercentiles, notNullValue()); @@ -196,7 +196,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); @@ -441,7 +441,7 @@ public class HDRPercentileRanksTests extends AbstractNumericTestCase { .prepareSearch("idx") .setQuery(matchAllQuery()) .addAggregation( - histogram("histo").field("value").interval(2l) + histogram("histo").field("value").interval(2L) .subAggregation( percentileRanks("percentile_ranks").method(PercentilesMethod.HDR) .numberOfSignificantValueDigits(sigDigits).values(99)) diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java index bfd094ac78c..8f9370e3b91 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HDRPercentilesTests.java @@ -119,14 +119,14 @@ public class HDRPercentilesTests extends AbstractNumericTestCase { .addAggregation( histogram("histo") .field("value") - .interval(1l) + .interval(1L) .minDocCount(0) .subAggregation( percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR) .percentiles(10, 15))).execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -149,7 +149,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase { percentiles("percentiles").numberOfSignificantValueDigits(sigDigits).method(PercentilesMethod.HDR).field("value") .percentiles(0, 10, 15, 100)).execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Percentiles percentiles = searchResponse.getAggregations().get("percentiles"); assertThat(percentiles, notNullValue()); @@ -196,7 +196,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); @@ -417,7 +417,7 @@ public class HDRPercentilesTests extends AbstractNumericTestCase { .prepareSearch("idx") .setQuery(matchAllQuery()) .addAggregation( - histogram("histo").field("value").interval(2l) + histogram("histo").field("value").interval(2L) .subAggregation( percentiles("percentiles").method(PercentilesMethod.HDR).numberOfSignificantValueDigits(sigDigits) .percentiles(99)) diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java index 1b1fa921207..cb9232b2021 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/HistogramTests.java @@ -910,12 +910,12 @@ public class HistogramTests extends ESIntegTestCase { Histogram.Bucket bucket = buckets.get(0); assertThat(bucket, notNullValue()); assertThat(((Number) bucket.getKey()).longValue(), equalTo((long) -1 * 2 * interval)); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); assertThat(((Number) bucket.getKey()).longValue(), equalTo((long) -1 * interval)); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); for (int i = 2; i < numValueBuckets + 2; ++i) { bucket = buckets.get(i); @@ -928,11 +928,11 @@ public class HistogramTests extends ESIntegTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0) - .subAggregation(histogram("sub_histo").interval(1l))) + .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1L).minDocCount(0) + .subAggregation(histogram("sub_histo").interval(1L))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); List buckets = histo.getBuckets(); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java index b93d090b56a..b1861b5607a 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IPv4RangeTests.java @@ -146,7 +146,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -155,7 +155,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -164,7 +164,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); } public void testSingleValueFieldWithMaskRange() throws Exception { @@ -191,7 +191,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), equalTo("10.0.0.0")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.128"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.128")); - assertThat(bucket.getDocCount(), equalTo(128l)); + assertThat(bucket.getDocCount(), equalTo(128L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -200,7 +200,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), equalTo("10.0.0.128")); assertThat((long) ((Number) bucket.getTo()).doubleValue(), equalTo(IpFieldMapper.ipToLong("10.0.1.0"))); // range is exclusive on the to side assertThat(bucket.getToAsString(), equalTo("10.0.1.0")); - assertThat(bucket.getDocCount(), equalTo(127l)); // include 10.0.0.128 + assertThat(bucket.getDocCount(), equalTo(127L)); // include 10.0.0.128 } public void testSingleValueFieldWithCustomKey() throws Exception { @@ -228,7 +228,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -237,7 +237,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -246,7 +246,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); } public void testSingleValuedFieldWithSubAggregation() throws Exception { @@ -278,12 +278,12 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) 100)); assertThat((String) propertiesKeys[0], equalTo("*-10.0.0.100")); - assertThat((long) propertiesDocCounts[0], equalTo(100l)); + assertThat((long) propertiesDocCounts[0], equalTo(100L)); assertThat((double) propertiesCounts[0], equalTo((double) 100)); bucket = buckets.get(1); @@ -293,12 +293,12 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) 200)); assertThat((String) propertiesKeys[1], equalTo("10.0.0.100-10.0.0.200")); - assertThat((long) propertiesDocCounts[1], equalTo(100l)); + assertThat((long) propertiesDocCounts[1], equalTo(100L)); assertThat((double) propertiesCounts[1], equalTo((double) 200)); bucket = buckets.get(2); @@ -308,12 +308,12 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) 55*3)); assertThat((String) propertiesKeys[2], equalTo("10.0.0.200-*")); - assertThat((long) propertiesDocCounts[2], equalTo(55l)); + assertThat((long) propertiesDocCounts[2], equalTo(55L)); assertThat((double) propertiesCounts[2], equalTo((double) 55 * 3)); } @@ -343,7 +343,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.99"))); @@ -355,7 +355,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.199"))); @@ -367,7 +367,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.254"))); @@ -395,7 +395,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -404,7 +404,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -413,7 +413,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); } /* @@ -458,7 +458,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -467,7 +467,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(101l)); + assertThat(bucket.getDocCount(), equalTo(101L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -476,7 +476,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(56l)); + assertThat(bucket.getDocCount(), equalTo(56L)); } public void testMultiValuedFieldWithValueScript() throws Exception { @@ -502,7 +502,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -511,7 +511,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(101l)); + assertThat(bucket.getDocCount(), equalTo(101L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -520,7 +520,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(56l)); + assertThat(bucket.getDocCount(), equalTo(56L)); } public void testMultiValuedFieldWithValueScriptWithInheritedSubAggregator() throws Exception { @@ -546,7 +546,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); Max max = bucket.getAggregations().get("max"); assertThat(max, Matchers.notNullValue()); assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.100"))); @@ -558,7 +558,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(101l)); + assertThat(bucket.getDocCount(), equalTo(101L)); max = bucket.getAggregations().get("max"); assertThat(max, Matchers.notNullValue()); assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.200"))); @@ -570,7 +570,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(56l)); + assertThat(bucket.getDocCount(), equalTo(56L)); max = bucket.getAggregations().get("max"); assertThat(max, Matchers.notNullValue()); assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.255"))); @@ -599,7 +599,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -608,7 +608,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -617,7 +617,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); } public void testScriptSingleValueWithSubAggregatorInherited() throws Exception { @@ -644,7 +644,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); Max max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.99"))); @@ -656,7 +656,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.199"))); @@ -668,7 +668,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); max = bucket.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.254"))); @@ -697,7 +697,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -706,7 +706,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(101l)); + assertThat(bucket.getDocCount(), equalTo(101L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -715,7 +715,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(56l)); + assertThat(bucket.getDocCount(), equalTo(56L)); } public void testScriptMultiValuedWithAggregatorInherited() throws Exception { @@ -742,7 +742,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); Max max = bucket.getAggregations().get("max"); assertThat(max, Matchers.notNullValue()); assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.100"))); @@ -754,7 +754,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(101l)); + assertThat(bucket.getDocCount(), equalTo(101L)); max = bucket.getAggregations().get("max"); assertThat(max, Matchers.notNullValue()); assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.200"))); @@ -766,7 +766,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(56l)); + assertThat(bucket.getDocCount(), equalTo(56L)); max = bucket.getAggregations().get("max"); assertThat(max, Matchers.notNullValue()); assertThat((long) max.getValue(), equalTo(IpFieldMapper.ipToLong("10.0.0.255"))); @@ -797,7 +797,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -806,7 +806,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -815,7 +815,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } public void testPartiallyUnmapped() throws Exception { @@ -843,7 +843,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("10.0.0.100")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -852,7 +852,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.100"))); assertThat(bucket.getToAsString(), equalTo("10.0.0.200")); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); - assertThat(bucket.getDocCount(), equalTo(100l)); + assertThat(bucket.getDocCount(), equalTo(100L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -861,17 +861,17 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getFrom()).doubleValue(), equalTo((double) IpFieldMapper.ipToLong("10.0.0.200"))); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(55l)); + assertThat(bucket.getDocCount(), equalTo(55L)); } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(ipRange("ip_range").field("ip").addRange("r1", "10.0.0.1", "10.0.0.10"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -886,7 +886,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat((String) buckets.get(0).getKey(), equalTo("r1")); assertThat(buckets.get(0).getFromAsString(), equalTo("10.0.0.1")); assertThat(buckets.get(0).getToAsString(), equalTo("10.0.0.10")); - assertThat(buckets.get(0).getDocCount(), equalTo(0l)); + assertThat(buckets.get(0).getDocCount(), equalTo(0L)); } public void testMask0() { @@ -909,7 +909,7 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), nullValue()); assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); - assertEquals(255l, bucket.getDocCount()); + assertEquals(255L, bucket.getDocCount()); } public void testMask0SpecialIps() { @@ -929,6 +929,6 @@ public class IPv4RangeTests extends ESIntegTestCase { assertThat(range.getBuckets().size(), equalTo(1)); Range.Bucket bucket = buckets.get(0); - assertEquals(4l, bucket.getDocCount()); + assertEquals(4L, bucket.getDocCount()); } } diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java index f972f3b8944..a092d35769d 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndexLookupTests.java @@ -474,23 +474,23 @@ public class IndexLookupTests extends ESIntegTestCase { // check doc frequencies for 'c' script = new Script("term = _index['float_payload_field']['c']; if (term != null) {term.df()}"); - expectedResults.put("1", 1l); - expectedResults.put("2", 1l); - expectedResults.put("3", 1l); - expectedResults.put("4", 1l); - expectedResults.put("5", 1l); - expectedResults.put("6", 1l); + expectedResults.put("1", 1L); + expectedResults.put("2", 1L); + expectedResults.put("3", 1L); + expectedResults.put("4", 1L); + expectedResults.put("5", 1L); + expectedResults.put("6", 1L); checkValueInEachDoc(script, expectedResults, 6); expectedResults.clear(); // check doc frequencies for term that does not exist script = new Script("term = _index['float_payload_field']['non_existent_term']; if (term != null) {term.df()}"); - expectedResults.put("1", 0l); - expectedResults.put("2", 0l); - expectedResults.put("3", 0l); - expectedResults.put("4", 0l); - expectedResults.put("5", 0l); - expectedResults.put("6", 0l); + expectedResults.put("1", 0L); + expectedResults.put("2", 0L); + expectedResults.put("3", 0L); + expectedResults.put("4", 0L); + expectedResults.put("5", 0L); + expectedResults.put("6", 0L); checkValueInEachDoc(script, expectedResults, 6); expectedResults.clear(); @@ -507,12 +507,12 @@ public class IndexLookupTests extends ESIntegTestCase { // check total term frequencies for 'a' script = new Script("term = _index['float_payload_field']['a']; if (term != null) {term.ttf()}"); - expectedResults.put("1", 4l); - expectedResults.put("2", 4l); - expectedResults.put("3", 4l); - expectedResults.put("4", 4l); - expectedResults.put("5", 4l); - expectedResults.put("6", 4l); + expectedResults.put("1", 4L); + expectedResults.put("2", 4L); + expectedResults.put("3", 4L); + expectedResults.put("4", 4L); + expectedResults.put("5", 4L); + expectedResults.put("6", 4L); checkValueInEachDoc(script, expectedResults, 6); expectedResults.clear(); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java index b5cd130e191..1e40afdfce5 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/IndicesRequestTests.java @@ -592,7 +592,7 @@ public class IndicesRequestTests extends ESIntegTestCase { SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_THEN_FETCH); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); + assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); clearInterceptedActions(); assertSameIndices(searchRequest, SearchServiceTransportAction.QUERY_ACTION_NAME, SearchServiceTransportAction.FETCH_ID_ACTION_NAME); @@ -613,7 +613,7 @@ public class IndicesRequestTests extends ESIntegTestCase { SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_THEN_FETCH); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); + assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); clearInterceptedActions(); assertSameIndices(searchRequest, SearchServiceTransportAction.DFS_ACTION_NAME, SearchServiceTransportAction.QUERY_ID_ACTION_NAME, @@ -635,7 +635,7 @@ public class IndicesRequestTests extends ESIntegTestCase { SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.QUERY_AND_FETCH); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); + assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); clearInterceptedActions(); assertSameIndices(searchRequest, SearchServiceTransportAction.QUERY_FETCH_ACTION_NAME); @@ -656,7 +656,7 @@ public class IndicesRequestTests extends ESIntegTestCase { SearchRequest searchRequest = new SearchRequest(randomIndicesOrAliases).searchType(SearchType.DFS_QUERY_AND_FETCH); SearchResponse searchResponse = internalCluster().clientNodeClient().search(searchRequest).actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), greaterThan(0l)); + assertThat(searchResponse.getHits().totalHits(), greaterThan(0L)); clearInterceptedActions(); assertSameIndices(searchRequest, SearchServiceTransportAction.QUERY_QUERY_FETCH_ACTION_NAME); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java index 0f79ca8fdfd..5bf515249aa 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/LongTermsTests.java @@ -125,44 +125,44 @@ public class LongTermsTests extends AbstractTermsTestCase { private void getMultiSortDocs(List builders) throws IOException { expectedMultiSortBuckets = new HashMap<>(); Map bucketProps = new HashMap<>(); - bucketProps.put("_term", 1l); - bucketProps.put("_count", 3l); + bucketProps.put("_term", 1L); + bucketProps.put("_count", 3L); bucketProps.put("avg_l", 1d); bucketProps.put("sum_d", 6d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); - bucketProps.put("_term", 2l); - bucketProps.put("_count", 3l); + bucketProps.put("_term", 2L); + bucketProps.put("_count", 3L); bucketProps.put("avg_l", 2d); bucketProps.put("sum_d", 6d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); - bucketProps.put("_term", 3l); - bucketProps.put("_count", 2l); + bucketProps.put("_term", 3L); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 3d); bucketProps.put("sum_d", 3d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); - bucketProps.put("_term", 4l); - bucketProps.put("_count", 2l); + bucketProps.put("_term", 4L); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 3d); bucketProps.put("sum_d", 4d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); - bucketProps.put("_term", 5l); - bucketProps.put("_count", 2l); + bucketProps.put("_term", 5L); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 3d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); - bucketProps.put("_term", 6l); - bucketProps.put("_count", 1l); + bucketProps.put("_term", 6L); + bucketProps.put("_count", 1L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); - bucketProps.put("_term", 7l); - bucketProps.put("_count", 1l); + bucketProps.put("_term", 7L); + bucketProps.put("_count", 1L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Long) bucketProps.get("_term"), bucketProps); @@ -274,7 +274,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -303,7 +303,7 @@ public class LongTermsTests extends AbstractTermsTestCase { for (int i = 0; i < expecteds.length; i++) { Terms.Bucket bucket = terms.getBucketByKey("" + expecteds[i]); assertThat(bucket, notNullValue()); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -329,7 +329,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -352,7 +352,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); i++; } } @@ -378,7 +378,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); i--; } } @@ -407,13 +407,13 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); - assertThat((long) sum.getValue(), equalTo(i+i+1l)); + assertThat((long) sum.getValue(), equalTo(i+i+1L)); assertThat((long) propertiesKeys[i], equalTo((long) i)); - assertThat((long) propertiesDocCounts[i], equalTo(1l)); - assertThat((double) propertiesCounts[i], equalTo((double) i + i + 1l)); + assertThat((long) propertiesDocCounts[i], equalTo(1L)); + assertThat((double) propertiesCounts[i], equalTo((double) i + i + 1L)); } } @@ -438,7 +438,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) i)); @@ -466,7 +466,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + (i+1d))); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i+1)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -491,9 +491,9 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -520,9 +520,9 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(key(bucket), equalTo("" + (i-1d))); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i-1)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -547,7 +547,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("1.0")); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(1)); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); } /* @@ -625,7 +625,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -650,7 +650,7 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo((double) i)); @@ -679,9 +679,9 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -776,18 +776,18 @@ public class LongTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); assertThat(bucket.getKeyAsNumber().intValue(), equalTo(i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1L).minDocCount(0) .subAggregation(terms("terms"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -821,7 +821,7 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo((double) i)); @@ -851,7 +851,7 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); @@ -864,7 +864,7 @@ public class LongTermsTests extends AbstractTermsTestCase { for (Terms.Bucket subBucket : subTermsAgg.getBuckets()) { assertThat(subBucket, notNullValue()); assertThat(key(subBucket), equalTo(String.valueOf(j))); - assertThat(subBucket.getDocCount(), equalTo(1l)); + assertThat(subBucket.getDocCount(), equalTo(1L)); j++; } } @@ -893,18 +893,18 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "0" : "1")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); Filter filter = tag.getAggregations().get("filter"); assertThat(filter, notNullValue()); - assertThat(filter.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L)); tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "1" : "0")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); filter = tag.getAggregations().get("filter"); assertThat(filter, notNullValue()); - assertThat(filter.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter.getDocCount(), equalTo(asc ? 3L : 2L)); } public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels() throws Exception { @@ -935,13 +935,13 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "1" : "0")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter2 = filter1.getAggregations().get("filter2"); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L)); Max max = filter2.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo(asc ? 2.0 : 4.0)); @@ -949,13 +949,13 @@ public class LongTermsTests extends AbstractTermsTestCase { tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "0" : "1")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 2L : 3L)); filter2 = filter1.getAggregations().get("filter2"); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 2L : 3L)); max = filter2.getAggregations().get("max"); assertThat(max, notNullValue()); assertThat(max.getValue(), equalTo(asc ? 4.0 : 2.0)); @@ -1062,7 +1062,7 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); @@ -1092,7 +1092,7 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1122,7 +1122,7 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1152,7 +1152,7 @@ public class LongTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ExtendedStats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java index 7ecd99062aa..d2e0d20b558 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MaxTests.java @@ -54,10 +54,10 @@ public class MaxTests extends AbstractNumericTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(max("max"))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(max("max"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -76,7 +76,7 @@ public class MaxTests extends AbstractNumericTestCase { .addAggregation(max("max").field("value")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Max max = searchResponse.getAggregations().get("max"); assertThat(max, notNullValue()); @@ -122,7 +122,7 @@ public class MaxTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java index b5f0105537e..caa7b2f4bc4 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/MinTests.java @@ -54,10 +54,10 @@ public class MinTests extends AbstractNumericTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(min("min"))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(min("min"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -76,7 +76,7 @@ public class MinTests extends AbstractNumericTestCase { .addAggregation(min("min").field("value")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Min min = searchResponse.getAggregations().get("min"); assertThat(min, notNullValue()); @@ -123,7 +123,7 @@ public class MinTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java index 288d5ed1857..def0d823272 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/RangeTests.java @@ -180,7 +180,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -189,7 +189,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -224,7 +224,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -233,7 +233,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3")); assertThat(bucket.getToAsString(), equalTo("6")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -270,7 +270,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -279,7 +279,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -320,12 +320,12 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo(3.0)); // 1 + 2 assertThat((String) propertiesKeys[0], equalTo("*-3.0")); - assertThat((long) propertiesDocCounts[0], equalTo(2l)); + assertThat((long) propertiesDocCounts[0], equalTo(2L)); assertThat((double) propertiesCounts[0], equalTo(3.0)); bucket = buckets.get(1); @@ -335,12 +335,12 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getValue(), equalTo(12.0)); // 3 + 4 + 5 assertThat((String) propertiesKeys[1], equalTo("3.0-6.0")); - assertThat((long) propertiesDocCounts[1], equalTo(3l)); + assertThat((long) propertiesDocCounts[1], equalTo(3L)); assertThat((double) propertiesCounts[1], equalTo(12.0)); bucket = buckets.get(2); @@ -350,7 +350,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 5l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 5L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); long total = 0; @@ -359,7 +359,7 @@ public class RangeTests extends ESIntegTestCase { } assertThat(sum.getValue(), equalTo((double) total)); assertThat((String) propertiesKeys[2], equalTo("6.0-*")); - assertThat((long) propertiesDocCounts[2], equalTo(numDocs - 5l)); + assertThat((long) propertiesDocCounts[2], equalTo(numDocs - 5L)); assertThat((double) propertiesCounts[2], equalTo((double) total)); } @@ -389,7 +389,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Avg avg = bucket.getAggregations().get("avg"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo(1.5)); // (1 + 2) / 2 @@ -401,7 +401,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); avg = bucket.getAggregations().get("avg"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo(4.0)); // (3 + 4 + 5) / 3 @@ -413,7 +413,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 5l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 5L)); avg = bucket.getAggregations().get("avg"); assertThat(avg, notNullValue()); long total = 0; @@ -445,7 +445,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(1l)); // 2 + assertThat(bucket.getDocCount(), equalTo(1L)); // 2 bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -454,7 +454,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); // 3, 4, 5 + assertThat(bucket.getDocCount(), equalTo(3L)); // 3, 4, 5 bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -463,7 +463,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } /* @@ -504,7 +504,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -513,7 +513,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -522,7 +522,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } /* @@ -561,7 +561,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -570,7 +570,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -579,7 +579,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 3l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 3L)); } /* @@ -622,7 +622,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getName(), equalTo("sum")); @@ -635,7 +635,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getName(), equalTo("sum")); @@ -682,7 +682,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -691,7 +691,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -700,7 +700,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 5l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 5L)); } public void testScriptSingleValueWithSubAggregatorInherited() throws Exception { @@ -726,7 +726,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Avg avg = bucket.getAggregations().get("avg"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo(1.5)); // (1 + 2) / 2 @@ -738,7 +738,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); avg = bucket.getAggregations().get("avg"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo(4.0)); // (3 + 4 + 5) / 3 @@ -750,7 +750,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 5l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 5L)); avg = bucket.getAggregations().get("avg"); assertThat(avg, notNullValue()); long total = 0; @@ -784,7 +784,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(-1.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("-1.0")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -793,7 +793,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("1000.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } public void testScriptMultiValued() throws Exception { @@ -819,7 +819,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -828,7 +828,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -837,7 +837,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); } /* @@ -880,7 +880,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); Sum sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getName(), equalTo("sum")); @@ -893,7 +893,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getName(), equalTo("sum")); @@ -906,7 +906,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 4l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 4L)); sum = bucket.getAggregations().get("sum"); assertThat(sum, notNullValue()); assertThat(sum.getName(), equalTo("sum")); @@ -942,7 +942,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -951,7 +951,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -960,7 +960,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(0l)); + assertThat(bucket.getDocCount(), equalTo(0L)); } public void testPartiallyUnmapped() throws Exception { @@ -990,7 +990,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(3.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("3.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -999,7 +999,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(3l)); + assertThat(bucket.getDocCount(), equalTo(3L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -1008,7 +1008,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("6.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 5l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 5L)); } public void testOverlappingRanges() throws Exception { @@ -1037,7 +1037,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(5.0)); assertThat(bucket.getFromAsString(), nullValue()); assertThat(bucket.getToAsString(), equalTo("5.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); bucket = buckets.get(1); assertThat(bucket, notNullValue()); @@ -1046,7 +1046,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(6.0)); assertThat(bucket.getFromAsString(), equalTo("3.0")); assertThat(bucket.getToAsString(), equalTo("6.0")); - assertThat(bucket.getDocCount(), equalTo(4l)); + assertThat(bucket.getDocCount(), equalTo(4L)); bucket = buckets.get(2); assertThat(bucket, notNullValue()); @@ -1055,7 +1055,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(5.0)); assertThat(bucket.getFromAsString(), equalTo("4.0")); assertThat(bucket.getToAsString(), equalTo("5.0")); - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); bucket = buckets.get(3); assertThat(bucket, notNullValue()); @@ -1064,17 +1064,17 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) bucket.getTo()).doubleValue(), equalTo(Double.POSITIVE_INFINITY)); assertThat(bucket.getFromAsString(), equalTo("4.0")); assertThat(bucket.getToAsString(), nullValue()); - assertThat(bucket.getDocCount(), equalTo(numDocs - 2l)); + assertThat(bucket.getDocCount(), equalTo(numDocs - 2L)); } public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1L).minDocCount(0) .subAggregation(range("range").addRange("0-2", 0.0, 2.0))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -1091,7 +1091,7 @@ public class RangeTests extends ESIntegTestCase { assertThat(((Number) buckets.get(0).getTo()).doubleValue(), equalTo(2.0)); assertThat(buckets.get(0).getFromAsString(), equalTo("0.0")); assertThat(buckets.get(0).getToAsString(), equalTo("2.0")); - assertThat(buckets.get(0).getDocCount(), equalTo(0l)); + assertThat(buckets.get(0).getDocCount(), equalTo(0L)); } } diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java index 2c1d5256379..752165902ed 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptQuerySearchTests.java @@ -78,7 +78,7 @@ public class ScriptQuerySearchTests extends ESIntegTestCase { .setQuery(scriptQuery(new Script("doc['num1'].value > 1"))).addSort("num1", SortOrder.ASC) .addScriptField("sNum1", new Script("doc['num1'].value")).execute().actionGet(); - assertThat(response.getHits().totalHits(), equalTo(2l)); + assertThat(response.getHits().totalHits(), equalTo(2L)); assertThat(response.getHits().getAt(0).id(), equalTo("2")); assertThat((Double) response.getHits().getAt(0).fields().get("sNum1").values().get(0), equalTo(2.0)); assertThat(response.getHits().getAt(1).id(), equalTo("3")); @@ -93,7 +93,7 @@ public class ScriptQuerySearchTests extends ESIntegTestCase { .setQuery(scriptQuery(new Script("doc['num1'].value > param1", ScriptType.INLINE, null, params))) .addSort("num1", SortOrder.ASC).addScriptField("sNum1", new Script("doc['num1'].value")).execute().actionGet(); - assertThat(response.getHits().totalHits(), equalTo(1l)); + assertThat(response.getHits().totalHits(), equalTo(1L)); assertThat(response.getHits().getAt(0).id(), equalTo("3")); assertThat((Double) response.getHits().getAt(0).fields().get("sNum1").values().get(0), equalTo(3.0)); @@ -106,7 +106,7 @@ public class ScriptQuerySearchTests extends ESIntegTestCase { scriptQuery(new Script("doc['num1'].value > param1", ScriptType.INLINE, null, params))) .addSort("num1", SortOrder.ASC).addScriptField("sNum1", new Script("doc['num1'].value")).execute().actionGet(); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().getAt(0).id(), equalTo("1")); assertThat((Double) response.getHits().getAt(0).fields().get("sNum1").values().get(0), equalTo(1.0)); assertThat(response.getHits().getAt(1).id(), equalTo("2")); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java index fb57c545c11..6840ce5c6e8 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/ScriptedMetricTests.java @@ -279,7 +279,7 @@ public class ScriptedMetricTests extends ESIntegTestCase { // A particular shard may not have any documents stored on it so // we have to assume the lower bound may be 0. The check at the // bottom of the test method will make sure the count is correct - assertThat(numberValue.longValue(), allOf(greaterThanOrEqualTo(0l), lessThanOrEqualTo(numDocs))); + assertThat(numberValue.longValue(), allOf(greaterThanOrEqualTo(0L), lessThanOrEqualTo(numDocs))); totalCount += numberValue.longValue(); } } @@ -329,7 +329,7 @@ public class ScriptedMetricTests extends ESIntegTestCase { // A particular shard may not have any documents stored on it so // we have to assume the lower bound may be 0. The check at the // bottom of the test method will make sure the count is correct - assertThat(numberValue.longValue(), allOf(greaterThanOrEqualTo(0l), lessThanOrEqualTo(numDocs * 3))); + assertThat(numberValue.longValue(), allOf(greaterThanOrEqualTo(0L), lessThanOrEqualTo(numDocs * 3))); totalCount += numberValue.longValue(); } } @@ -687,7 +687,7 @@ public class ScriptedMetricTests extends ESIntegTestCase { assertThat(buckets, notNullValue()); for (Bucket b : buckets) { assertThat(b, notNullValue()); - assertThat(b.getDocCount(), equalTo(1l)); + assertThat(b.getDocCount(), equalTo(1L)); Aggregations subAggs = b.getAggregations(); assertThat(subAggs, notNullValue()); assertThat(subAggs.asList().size(), equalTo(1)); @@ -703,7 +703,7 @@ public class ScriptedMetricTests extends ESIntegTestCase { Object object = aggregationList.get(0); assertThat(object, notNullValue()); assertThat(object, instanceOf(Number.class)); - assertThat(((Number) object).longValue(), equalTo(3l)); + assertThat(((Number) object).longValue(), equalTo(3L)); } } @@ -716,7 +716,7 @@ public class ScriptedMetricTests extends ESIntegTestCase { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation( scriptedMetric("scripted") .params(params) @@ -730,7 +730,7 @@ public class ScriptedMetricTests extends ESIntegTestCase { "newaggregation = []; sum = 0;for (aggregation in _aggs) { for (a in aggregation) { sum += a} }; newaggregation.add(sum); return newaggregation")))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java index 217aa2f1a8f..f38b4e36e4e 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchFieldsTests.java @@ -103,33 +103,33 @@ public class SearchFieldsTests extends ESIntegTestCase { client().admin().indices().prepareRefresh().execute().actionGet(); SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("field1").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().get("field1").value().toString(), equalTo("value1")); // field2 is not stored, check that it is not extracted from source. searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("field2").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(0)); assertThat(searchResponse.getHits().getAt(0).fields().get("field2"), nullValue()); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("field3").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3")); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("*3").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3")); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("*3").addField("field1").addField("field2").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(2)); assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3")); @@ -137,20 +137,20 @@ public class SearchFieldsTests extends ESIntegTestCase { searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("field*").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(2)); assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3")); assertThat(searchResponse.getHits().getAt(0).fields().get("field1").value().toString(), equalTo("value1")); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("f*3").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(1)); assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3")); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("*").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).source(), nullValue()); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(2)); @@ -158,7 +158,7 @@ public class SearchFieldsTests extends ESIntegTestCase { assertThat(searchResponse.getHits().getAt(0).fields().get("field3").value().toString(), equalTo("value3")); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addField("*").addField("_source").execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); assertThat(searchResponse.getHits().getAt(0).source(), notNullValue()); assertThat(searchResponse.getHits().getAt(0).fields().size(), equalTo(2)); @@ -200,7 +200,7 @@ public class SearchFieldsTests extends ESIntegTestCase { assertNoFailures(response); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().getAt(0).isSourceEmpty(), equalTo(true)); assertThat(response.getHits().getAt(0).id(), equalTo("1")); Set fields = new HashSet<>(response.getHits().getAt(0).fields().keySet()); @@ -208,21 +208,21 @@ public class SearchFieldsTests extends ESIntegTestCase { assertThat(fields, equalTo(newHashSet("sNum1", "sNum1_field", "date1"))); assertThat((Double) response.getHits().getAt(0).fields().get("sNum1").values().get(0), equalTo(1.0)); assertThat((Double) response.getHits().getAt(0).fields().get("sNum1_field").values().get(0), equalTo(1.0)); - assertThat((Long) response.getHits().getAt(0).fields().get("date1").values().get(0), equalTo(0l)); + assertThat((Long) response.getHits().getAt(0).fields().get("date1").values().get(0), equalTo(0L)); assertThat(response.getHits().getAt(1).id(), equalTo("2")); fields = new HashSet<>(response.getHits().getAt(0).fields().keySet()); fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates assertThat(fields, equalTo(newHashSet("sNum1", "sNum1_field", "date1"))); assertThat((Double) response.getHits().getAt(1).fields().get("sNum1").values().get(0), equalTo(2.0)); assertThat((Double) response.getHits().getAt(1).fields().get("sNum1_field").values().get(0), equalTo(2.0)); - assertThat((Long) response.getHits().getAt(1).fields().get("date1").values().get(0), equalTo(25000l)); + assertThat((Long) response.getHits().getAt(1).fields().get("date1").values().get(0), equalTo(25000L)); assertThat(response.getHits().getAt(2).id(), equalTo("3")); fields = new HashSet<>(response.getHits().getAt(0).fields().keySet()); fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates assertThat(fields, equalTo(newHashSet("sNum1", "sNum1_field", "date1"))); assertThat((Double) response.getHits().getAt(2).fields().get("sNum1").values().get(0), equalTo(3.0)); assertThat((Double) response.getHits().getAt(2).fields().get("sNum1_field").values().get(0), equalTo(3.0)); - assertThat((Long) response.getHits().getAt(2).fields().get("date1").values().get(0), equalTo(120000l)); + assertThat((Long) response.getHits().getAt(2).fields().get("date1").values().get(0), equalTo(120000L)); logger.info("running doc['num1'].value * factor"); Map params = MapBuilder.newMapBuilder().put("factor", 2.0).map(); @@ -232,7 +232,7 @@ public class SearchFieldsTests extends ESIntegTestCase { .addScriptField("sNum1", new Script("doc['num1'].value * factor", ScriptType.INLINE, null, params)) .execute().actionGet(); - assertThat(response.getHits().totalHits(), equalTo(3l)); + assertThat(response.getHits().totalHits(), equalTo(3L)); assertThat(response.getHits().getAt(0).id(), equalTo("1")); fields = new HashSet<>(response.getHits().getAt(0).fields().keySet()); fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates @@ -408,7 +408,7 @@ public class SearchFieldsTests extends ESIntegTestCase { .field("byte_field", (byte) 1) .field("short_field", (short) 2) .field("integer_field", 3) - .field("long_field", 4l) + .field("long_field", 4L) .field("float_field", 5.0f) .field("double_field", 6.0d) .field("date_field", Joda.forPattern("dateOptionalTime").printer().print(new DateTime(2012, 3, 22, 0, 0, DateTimeZone.UTC))) @@ -430,7 +430,7 @@ public class SearchFieldsTests extends ESIntegTestCase { .addField("binary_field") .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); Set fields = new HashSet<>(searchResponse.getHits().getAt(0).fields().keySet()); fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates @@ -441,7 +441,7 @@ public class SearchFieldsTests extends ESIntegTestCase { assertThat(searchResponse.getHits().getAt(0).fields().get("byte_field").value().toString(), equalTo("1")); assertThat(searchResponse.getHits().getAt(0).fields().get("short_field").value().toString(), equalTo("2")); assertThat(searchResponse.getHits().getAt(0).fields().get("integer_field").value(), equalTo((Object) 3)); - assertThat(searchResponse.getHits().getAt(0).fields().get("long_field").value(), equalTo((Object) 4l)); + assertThat(searchResponse.getHits().getAt(0).fields().get("long_field").value(), equalTo((Object) 4L)); assertThat(searchResponse.getHits().getAt(0).fields().get("float_field").value(), equalTo((Object) 5.0f)); assertThat(searchResponse.getHits().getAt(0).fields().get("double_field").value(), equalTo((Object) 6.0d)); String dateTime = Joda.forPattern("dateOptionalTime").printer().print(new DateTime(2012, 3, 22, 0, 0, DateTimeZone.UTC)); @@ -463,7 +463,7 @@ public class SearchFieldsTests extends ESIntegTestCase { .addField("field1").addField("_routing") .get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).field("field1"), nullValue()); assertThat(searchResponse.getHits().getAt(0).field("_routing").isMetadataField(), equalTo(true)); assertThat(searchResponse.getHits().getAt(0).field("_routing").getValue().toString(), equalTo("1")); @@ -523,14 +523,14 @@ public class SearchFieldsTests extends ESIntegTestCase { String field = "field1.field2.field3.field4"; SearchResponse searchResponse = client().prepareSearch("my-index").setTypes("my-type1").addField(field).get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).field(field).isMetadataField(), equalTo(false)); assertThat(searchResponse.getHits().getAt(0).field(field).getValues().size(), equalTo(2)); assertThat(searchResponse.getHits().getAt(0).field(field).getValues().get(0).toString(), equalTo("value1")); assertThat(searchResponse.getHits().getAt(0).field(field).getValues().get(1).toString(), equalTo("value2")); searchResponse = client().prepareSearch("my-index").setTypes("my-type2").addField(field).get(); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).field(field).isMetadataField(), equalTo(false)); assertThat(searchResponse.getHits().getAt(0).field(field).getValues().size(), equalTo(2)); assertThat(searchResponse.getHits().getAt(0).field(field).getValues().get(0).toString(), equalTo("value1")); @@ -573,7 +573,7 @@ public class SearchFieldsTests extends ESIntegTestCase { .field("byte_field", (byte) 1) .field("short_field", (short) 2) .field("integer_field", 3) - .field("long_field", 4l) + .field("long_field", 4L) .field("float_field", 5.0f) .field("double_field", 6.0d) .field("date_field", Joda.forPattern("dateOptionalTime").printer().print(new DateTime(2012, 3, 22, 0, 0, DateTimeZone.UTC))) @@ -594,7 +594,7 @@ public class SearchFieldsTests extends ESIntegTestCase { .addFieldDataField("boolean_field"); SearchResponse searchResponse = builder.execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().hits().length, equalTo(1)); Set fields = new HashSet<>(searchResponse.getHits().getAt(0).fields().keySet()); fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates @@ -603,8 +603,8 @@ public class SearchFieldsTests extends ESIntegTestCase { assertThat(searchResponse.getHits().getAt(0).fields().get("byte_field").value().toString(), equalTo("1")); assertThat(searchResponse.getHits().getAt(0).fields().get("short_field").value().toString(), equalTo("2")); - assertThat(searchResponse.getHits().getAt(0).fields().get("integer_field").value(), equalTo((Object) 3l)); - assertThat(searchResponse.getHits().getAt(0).fields().get("long_field").value(), equalTo((Object) 4l)); + assertThat(searchResponse.getHits().getAt(0).fields().get("integer_field").value(), equalTo((Object) 3L)); + assertThat(searchResponse.getHits().getAt(0).fields().get("long_field").value(), equalTo((Object) 4L)); assertThat(searchResponse.getHits().getAt(0).fields().get("float_field").value(), equalTo((Object) 5.0)); assertThat(searchResponse.getHits().getAt(0).fields().get("double_field").value(), equalTo((Object) 6.0d)); assertThat(searchResponse.getHits().getAt(0).fields().get("date_field").value(), equalTo((Object) 1332374400000L)); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java index c301f97ccc2..72abe487d89 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SearchStatsTests.java @@ -117,18 +117,18 @@ public class SearchStatsTests extends ESIntegTestCase { IndicesStatsResponse indicesStats = client().admin().indices().prepareStats().execute().actionGet(); logger.debug("###### indices search stats: " + indicesStats.getTotal().getSearch()); - assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryCount(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryTimeInMillis(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getSearch().getTotal().getFetchCount(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getSearch().getTotal().getFetchTimeInMillis(), greaterThan(0l)); + assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryCount(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryTimeInMillis(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getSearch().getTotal().getFetchCount(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getSearch().getTotal().getFetchTimeInMillis(), greaterThan(0L)); assertThat(indicesStats.getTotal().getSearch().getGroupStats(), nullValue()); indicesStats = client().admin().indices().prepareStats().setGroups("group1").execute().actionGet(); assertThat(indicesStats.getTotal().getSearch().getGroupStats(), notNullValue()); - assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getQueryCount(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getQueryTimeInMillis(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getFetchCount(), greaterThan(0l)); - assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getFetchTimeInMillis(), greaterThan(0l)); + assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getQueryCount(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getQueryTimeInMillis(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getFetchCount(), greaterThan(0L)); + assertThat(indicesStats.getTotal().getSearch().getGroupStats().get("group1").getFetchTimeInMillis(), greaterThan(0L)); NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().execute().actionGet(); NodeStats[] nodes = nodeStats.getNodes(); Set nodeIdsWithIndex = nodeIdsWithIndex("test1", "test2"); @@ -136,12 +136,12 @@ public class SearchStatsTests extends ESIntegTestCase { for (NodeStats stat : nodes) { Stats total = stat.getIndices().getSearch().getTotal(); if (nodeIdsWithIndex.contains(stat.getNode().getId())) { - assertThat(total.getQueryCount(), greaterThan(0l)); - assertThat(total.getQueryTimeInMillis(), greaterThan(0l)); + assertThat(total.getQueryCount(), greaterThan(0L)); + assertThat(total.getQueryTimeInMillis(), greaterThan(0L)); num++; } else { - assertThat(total.getQueryCount(), equalTo(0l)); - assertThat(total.getQueryTimeInMillis(), equalTo(0l)); + assertThat(total.getQueryCount(), equalTo(0L)); + assertThat(total.getQueryTimeInMillis(), equalTo(0L)); } } @@ -186,7 +186,7 @@ public class SearchStatsTests extends ESIntegTestCase { client().admin().indices().prepareRefresh(index).execute().actionGet(); IndicesStatsResponse indicesStats = client().admin().indices().prepareStats(index).execute().actionGet(); - assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0l)); + assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0L)); int size = scaledRandomIntBetween(1, docs); SearchResponse searchResponse = client().prepareSearch() @@ -228,9 +228,9 @@ public class SearchStatsTests extends ESIntegTestCase { indicesStats = client().admin().indices().prepareStats().execute().actionGet(); stats = indicesStats.getTotal().getSearch().getTotal(); - assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0l)); + assertThat(indicesStats.getTotal().getSearch().getOpenContexts(), equalTo(0L)); assertThat(stats.getScrollCount(), equalTo((long)numAssignedShards(index))); - assertThat(stats.getScrollTimeInMillis(), greaterThan(0l)); + assertThat(stats.getScrollTimeInMillis(), greaterThan(0L)); } protected int numAssignedShards(String... indices) { diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java index 309da10d680..b0c77f54197 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/SimpleSortTests.java @@ -690,7 +690,7 @@ public class SimpleSortTests extends ESIntegTestCase { size = 1 + random.nextInt(10); searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("long_value", SortOrder.DESC).execute() .actionGet(); - assertHitCount(searchResponse, 10l); + assertHitCount(searchResponse, 10L); assertHitCount(searchResponse, 10); assertThat(searchResponse.getHits().hits().length, equalTo(size)); for (int i = 0; i < size; i++) { @@ -705,7 +705,7 @@ public class SimpleSortTests extends ESIntegTestCase { searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("float_value", SortOrder.ASC).execute() .actionGet(); - assertHitCount(searchResponse, 10l); + assertHitCount(searchResponse, 10L); assertThat(searchResponse.getHits().hits().length, equalTo(size)); for (int i = 0; i < size; i++) { assertThat(searchResponse.getHits().getAt(i).id(), equalTo(Integer.toString(i))); @@ -731,7 +731,7 @@ public class SimpleSortTests extends ESIntegTestCase { searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("double_value", SortOrder.ASC).execute() .actionGet(); - assertHitCount(searchResponse, 10l); + assertHitCount(searchResponse, 10L); assertThat(searchResponse.getHits().hits().length, equalTo(size)); for (int i = 0; i < size; i++) { assertThat(searchResponse.getHits().getAt(i).id(), equalTo(Integer.toString(i))); @@ -743,7 +743,7 @@ public class SimpleSortTests extends ESIntegTestCase { searchResponse = client().prepareSearch().setQuery(matchAllQuery()).setSize(size).addSort("double_value", SortOrder.DESC).execute() .actionGet(); - assertHitCount(searchResponse, 10l); + assertHitCount(searchResponse, 10L); assertThat(searchResponse.getHits().hits().length, equalTo(size)); for (int i = 0; i < size; i++) { assertThat(searchResponse.getHits().getAt(i).id(), equalTo(Integer.toString(9 - i))); @@ -809,7 +809,7 @@ public class SimpleSortTests extends ESIntegTestCase { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(20L)); for (int i = 0; i < 10; i++) { assertThat("res: " + i + " id: " + searchResponse.getHits().getAt(i).getId(), (Long) searchResponse.getHits().getAt(i).field("min").value(), equalTo((long) i)); } @@ -822,7 +822,7 @@ public class SimpleSortTests extends ESIntegTestCase { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(20L)); for (int i = 0; i < 10; i++) { assertThat("res: " + i + " id: " + searchResponse.getHits().getAt(i).getId(), (Double) searchResponse.getHits().getAt(i).field("min").value(), equalTo((double) i)); } @@ -836,7 +836,7 @@ public class SimpleSortTests extends ESIntegTestCase { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(20L)); for (int i = 0; i < 10; i++) { assertThat("res: " + i + " id: " + searchResponse.getHits().getAt(i).getId(), (Integer) searchResponse.getHits().getAt(i).field("min").value(), equalTo(i)); } @@ -850,7 +850,7 @@ public class SimpleSortTests extends ESIntegTestCase { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(20l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(20L)); for (int i = 0; i < 10; i++) { assertThat("res: " + i + " id: " + searchResponse.getHits().getAt(i).getId(), (Double) searchResponse.getHits().getAt(i).field("min").value(), closeTo((double) i, TOLERANCE)); } @@ -893,7 +893,7 @@ public class SimpleSortTests extends ESIntegTestCase { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).field("id").value(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).field("id").value(), equalTo("3")); assertThat(searchResponse.getHits().getAt(2).field("id").value(), equalTo("2")); @@ -906,7 +906,7 @@ public class SimpleSortTests extends ESIntegTestCase { assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).field("id").value(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).field("id").value(), equalTo("3")); assertThat(searchResponse.getHits().getAt(2).field("id").value(), equalTo("2")); @@ -925,7 +925,7 @@ public class SimpleSortTests extends ESIntegTestCase { } assertThat(searchResponse.getFailedShards(), equalTo(0)); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).field("id").value(), equalTo("3")); assertThat(searchResponse.getHits().getAt(1).field("id").value(), equalTo("1")); assertThat(searchResponse.getHits().getAt(2).field("id").value(), equalTo("2")); @@ -945,7 +945,7 @@ public class SimpleSortTests extends ESIntegTestCase { } assertThat(searchResponse.getFailedShards(), equalTo(0)); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(0).field("id").value(), equalTo("2")); } @@ -993,7 +993,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("3")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("2")); @@ -1005,7 +1005,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("3")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("2")); @@ -1017,7 +1017,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("3")); @@ -1068,7 +1068,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0)); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("3")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("2")); @@ -1080,7 +1080,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0)); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("3")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("2")); @@ -1092,7 +1092,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0)); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("2")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("3")); @@ -1104,7 +1104,7 @@ public class SimpleSortTests extends ESIntegTestCase { .execute().actionGet(); assertThat(Arrays.toString(searchResponse.getShardFailures()), searchResponse.getFailedShards(), equalTo(0)); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1")); assertThat(searchResponse.getHits().getAt(1).id(), equalTo("2")); assertThat(searchResponse.getHits().getAt(2).id(), equalTo("3")); @@ -1155,7 +1155,7 @@ public class SimpleSortTests extends ESIntegTestCase { ensureGreen(); client().prepareIndex("test", "type1", Integer.toString(1)).setSource(jsonBuilder().startObject() - .array("long_values", 1l, 5l, 10l, 8l) + .array("long_values", 1L, 5L, 10L, 8L) .array("int_values", 1, 5, 10, 8) .array("short_values", 1, 5, 10, 8) .array("byte_values", 1, 5, 10, 8) @@ -1164,7 +1164,7 @@ public class SimpleSortTests extends ESIntegTestCase { .array("string_values", "01", "05", "10", "08") .endObject()).execute().actionGet(); client().prepareIndex("test", "type1", Integer.toString(2)).setSource(jsonBuilder().startObject() - .array("long_values", 11l, 15l, 20l, 7l) + .array("long_values", 11L, 15L, 20L, 7L) .array("int_values", 11, 15, 20, 7) .array("short_values", 11, 15, 20, 7) .array("byte_values", 11, 15, 20, 7) @@ -1173,7 +1173,7 @@ public class SimpleSortTests extends ESIntegTestCase { .array("string_values", "11", "15", "20", "07") .endObject()).execute().actionGet(); client().prepareIndex("test", "type1", Integer.toString(3)).setSource(jsonBuilder().startObject() - .array("long_values", 2l, 1l, 3l, -4l) + .array("long_values", 2L, 1L, 3L, -4L) .array("int_values", 2, 1, 3, -4) .array("short_values", 2, 1, 3, -4) .array("byte_values", 2, 1, 3, -4) @@ -1190,17 +1190,17 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("long_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); - assertThat(((Number) searchResponse.getHits().getAt(0).sortValues()[0]).longValue(), equalTo(-4l)); + assertThat(((Number) searchResponse.getHits().getAt(0).sortValues()[0]).longValue(), equalTo(-4L)); assertThat(searchResponse.getHits().getAt(1).id(), equalTo(Integer.toString(1))); - assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).longValue(), equalTo(1l)); + assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).longValue(), equalTo(1L)); assertThat(searchResponse.getHits().getAt(2).id(), equalTo(Integer.toString(2))); - assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).longValue(), equalTo(7l)); + assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).longValue(), equalTo(7L)); searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) @@ -1208,17 +1208,17 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("long_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); - assertThat(((Number) searchResponse.getHits().getAt(0).sortValues()[0]).longValue(), equalTo(20l)); + assertThat(((Number) searchResponse.getHits().getAt(0).sortValues()[0]).longValue(), equalTo(20L)); assertThat(searchResponse.getHits().getAt(1).id(), equalTo(Integer.toString(1))); - assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).longValue(), equalTo(10l)); + assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).longValue(), equalTo(10L)); assertThat(searchResponse.getHits().getAt(2).id(), equalTo(Integer.toString(3))); - assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).longValue(), equalTo(3l)); + assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).longValue(), equalTo(3L)); searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) @@ -1226,17 +1226,17 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort(SortBuilders.fieldSort("long_values").order(SortOrder.DESC).sortMode("sum")) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); - assertThat(((Number) searchResponse.getHits().getAt(0).sortValues()[0]).longValue(), equalTo(53l)); + assertThat(((Number) searchResponse.getHits().getAt(0).sortValues()[0]).longValue(), equalTo(53L)); assertThat(searchResponse.getHits().getAt(1).id(), equalTo(Integer.toString(1))); - assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).longValue(), equalTo(24l)); + assertThat(((Number) searchResponse.getHits().getAt(1).sortValues()[0]).longValue(), equalTo(24L)); assertThat(searchResponse.getHits().getAt(2).id(), equalTo(Integer.toString(3))); - assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).longValue(), equalTo(2l)); + assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).longValue(), equalTo(2L)); searchResponse = client().prepareSearch() .setQuery(matchAllQuery()) @@ -1244,7 +1244,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("int_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); @@ -1262,7 +1262,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("int_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); @@ -1280,7 +1280,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("short_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); @@ -1298,7 +1298,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("short_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); @@ -1316,7 +1316,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("byte_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); @@ -1334,7 +1334,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("byte_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); @@ -1352,7 +1352,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("float_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); @@ -1370,7 +1370,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("float_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); @@ -1388,7 +1388,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("double_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); @@ -1406,7 +1406,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("double_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); @@ -1424,7 +1424,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("string_values", SortOrder.ASC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(3))); @@ -1442,7 +1442,7 @@ public class SimpleSortTests extends ESIntegTestCase { .addSort("string_values", SortOrder.DESC) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(3L)); assertThat(searchResponse.getHits().hits().length, equalTo(3)); assertThat(searchResponse.getHits().getAt(0).id(), equalTo(Integer.toString(2))); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java index f480ba4d2e0..2f53d5cb7ae 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StatsTests.java @@ -57,12 +57,12 @@ public class StatsTests extends AbstractNumericTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0).subAggregation(stats("stats"))) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0).subAggregation(stats("stats"))) .execute().actionGet(); assertShardExecutionState(searchResponse, 0); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -71,7 +71,7 @@ public class StatsTests extends AbstractNumericTestCase { Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); assertThat(stats.getName(), equalTo("stats")); - assertThat(stats.getCount(), equalTo(0l)); + assertThat(stats.getCount(), equalTo(0L)); assertThat(stats.getSum(), equalTo(0.0)); assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY)); assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY)); @@ -87,7 +87,7 @@ public class StatsTests extends AbstractNumericTestCase { assertShardExecutionState(searchResponse, 0); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Stats stats = searchResponse.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -96,7 +96,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(Double.POSITIVE_INFINITY)); assertThat(stats.getMax(), equalTo(Double.NEGATIVE_INFINITY)); assertThat(stats.getSum(), equalTo(0.0)); - assertThat(stats.getCount(), equalTo(0l)); + assertThat(stats.getCount(), equalTo(0L)); } @Override @@ -117,7 +117,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); } public void testSingleValuedField_WithFormatter() throws Exception { @@ -138,7 +138,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMaxAsString(), equalTo("0010.0")); assertThat(stats.getSum(), equalTo((double) 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10)); assertThat(stats.getSumAsString(), equalTo("0055.0")); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); assertThat(stats.getCountAsString(), equalTo("0010.0")); } @@ -152,7 +152,7 @@ public class StatsTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); @@ -197,7 +197,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); } @Override @@ -218,7 +218,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); } @Override @@ -241,7 +241,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); } @Override @@ -262,7 +262,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(12.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); } @Override @@ -283,7 +283,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); } @Override @@ -306,7 +306,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); } @Override @@ -327,7 +327,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(1.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); } @Override @@ -350,7 +350,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(11.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11)); - assertThat(stats.getCount(), equalTo(10l)); + assertThat(stats.getCount(), equalTo(10L)); } @Override @@ -371,7 +371,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(2.0)); assertThat(stats.getMax(), equalTo(12.0)); assertThat(stats.getSum(), equalTo((double) 2+3+4+5+6+7+8+9+10+11+3+4+5+6+7+8+9+10+11+12)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); } @Override @@ -396,7 +396,7 @@ public class StatsTests extends AbstractNumericTestCase { assertThat(stats.getMin(), equalTo(0.0)); assertThat(stats.getMax(), equalTo(10.0)); assertThat(stats.getSum(), equalTo((double) 1+2+3+4+5+6+7+8+9+10+0+1+2+3+4+5+6+7+8+9)); - assertThat(stats.getCount(), equalTo(20l)); + assertThat(stats.getCount(), equalTo(20L)); } diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java index f4b7fc7adf5..8b54b4bda15 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/StringTermsTests.java @@ -123,43 +123,43 @@ public class StringTermsTests extends AbstractTermsTestCase { expectedMultiSortBuckets = new HashMap<>(); Map bucketProps = new HashMap<>(); bucketProps.put("_term", "val1"); - bucketProps.put("_count", 3l); + bucketProps.put("_count", 3L); bucketProps.put("avg_l", 1d); bucketProps.put("sum_d", 6d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", "val2"); - bucketProps.put("_count", 3l); + bucketProps.put("_count", 3L); bucketProps.put("avg_l", 2d); bucketProps.put("sum_d", 6d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", "val3"); - bucketProps.put("_count", 2l); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 3d); bucketProps.put("sum_d", 3d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", "val4"); - bucketProps.put("_count", 2l); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 3d); bucketProps.put("sum_d", 4d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", "val5"); - bucketProps.put("_count", 2l); + bucketProps.put("_count", 2L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 3d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", "val6"); - bucketProps.put("_count", 1l); + bucketProps.put("_count", 1L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); bucketProps = new HashMap<>(); bucketProps.put("_term", "val7"); - bucketProps.put("_count", 1l); + bucketProps.put("_count", 1L); bucketProps.put("avg_l", 5d); bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((String) bucketProps.get("_term"), bucketProps); @@ -233,9 +233,9 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); assertThat((String) propertiesKeys[i], equalTo("val" + i)); - assertThat((long) propertiesDocCounts[i], equalTo(1l)); + assertThat((long) propertiesDocCounts[i], equalTo(1L)); } } @@ -261,7 +261,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } } @@ -289,7 +289,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val00" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val00" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } // include and exclude @@ -315,7 +315,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val00" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val00" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } // exclude without include @@ -341,7 +341,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val00" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val00" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -367,7 +367,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey(incVal); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo(incVal)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } // include and exclude @@ -396,7 +396,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val00" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val00" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } // Check case with only exact term exclude clauses @@ -424,7 +424,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + nf.format(i)); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + nf.format(i))); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -449,7 +449,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + Strings.padStart(i + "", 3, '0')); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + Strings.padStart(i + "", 3, '0'))); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -473,7 +473,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); i++; } } @@ -498,7 +498,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); i--; } } @@ -526,12 +526,12 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat(valueCount.getValue(), equalTo(2l)); + assertThat(valueCount.getValue(), equalTo(2L)); assertThat((String) propertiesKeys[i], equalTo("val" + i)); - assertThat((long) propertiesDocCounts[i], equalTo(1l)); + assertThat((long) propertiesDocCounts[i], equalTo(1L)); assertThat((double) propertiesCounts[i], equalTo(2.0)); } } @@ -556,10 +556,10 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat(valueCount.getValue(), equalTo(1l)); + assertThat(valueCount.getValue(), equalTo(1L)); } } @@ -583,7 +583,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("foo_val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("foo_val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -606,7 +606,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val"); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val")); - assertThat(bucket.getDocCount(), equalTo(5l)); + assertThat(bucket.getDocCount(), equalTo(5L)); } public void testMultiValuedField() throws Exception { @@ -629,9 +629,9 @@ public class StringTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -656,9 +656,9 @@ public class StringTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -684,9 +684,9 @@ public class StringTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("foo_val" + i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -724,15 +724,15 @@ public class StringTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("foo_val" + i)); if (i == 0 | i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat(valueCount.getValue(), equalTo(2l)); + assertThat(valueCount.getValue(), equalTo(2L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat("term[" + key(bucket) + "]", valueCount.getValue(), equalTo(4l)); + assertThat("term[" + key(bucket) + "]", valueCount.getValue(), equalTo(4L)); } } } @@ -756,7 +756,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -779,7 +779,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -803,10 +803,10 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat(valueCount.getValue(), equalTo(1l)); + assertThat(valueCount.getValue(), equalTo(1L)); } } @@ -830,9 +830,9 @@ public class StringTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); if (i == 0 || i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); } } } @@ -858,15 +858,15 @@ public class StringTermsTests extends AbstractTermsTestCase { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); if (i == 0 | i == 5) { - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat(valueCount.getValue(), equalTo(2l)); + assertThat(valueCount.getValue(), equalTo(2L)); } else { - assertThat(bucket.getDocCount(), equalTo(2l)); + assertThat(bucket.getDocCount(), equalTo(2L)); ValueCount valueCount = bucket.getAggregations().get("count"); assertThat(valueCount, notNullValue()); - assertThat(valueCount.getValue(), equalTo(4l)); + assertThat(valueCount.getValue(), equalTo(4L)); } } } @@ -906,7 +906,7 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket bucket = terms.getBucketByKey("val" + i); assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); } } @@ -942,10 +942,10 @@ public class StringTermsTests extends AbstractTermsTestCase { .prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) .addAggregation( - histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1l).minDocCount(0).subAggregation(terms("terms"))) + histogram("histo").field(SINGLE_VALUED_FIELD_NAME).interval(1L).minDocCount(0).subAggregation(terms("terms"))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, Matchers.notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -978,7 +978,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); assertThat(avg.getValue(), equalTo((double) i)); @@ -1037,18 +1037,18 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "less" : "more")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); Filter filter = tag.getAggregations().get("filter"); assertThat(filter, notNullValue()); - assertThat(filter.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter.getDocCount(), equalTo(asc ? 2L : 3L)); tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "more" : "less")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); filter = tag.getAggregations().get("filter"); assertThat(filter, notNullValue()); - assertThat(filter.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter.getDocCount(), equalTo(asc ? 3L : 2L)); } public void testSingleValuedFieldOrderedBySubAggregationAscMultiHierarchyLevels() throws Exception { @@ -1082,13 +1082,13 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "more" : "less")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter2 = filter1.getAggregations().get("filter2"); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L)); Stats stats = filter2.getAggregations().get("stats"); assertThat(stats, notNullValue()); assertThat(stats.getMax(), equalTo(asc ? 2.0 : 4.0)); @@ -1096,13 +1096,13 @@ public class StringTermsTests extends AbstractTermsTestCase { tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "less" : "more")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 2L : 3L)); filter2 = filter1.getAggregations().get("filter2"); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 2L : 3L)); stats = filter2.getAggregations().get("stats"); assertThat(stats, notNullValue()); assertThat(stats.getMax(), equalTo(asc ? 4.0 : 2.0)); @@ -1145,13 +1145,13 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "more" : "less")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter2 = filter1.getAggregations().get(filter2Name); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L)); Stats stats = filter2.getAggregations().get(statsName); assertThat(stats, notNullValue()); assertThat(stats.getMax(), equalTo(asc ? 2.0 : 4.0)); @@ -1159,13 +1159,13 @@ public class StringTermsTests extends AbstractTermsTestCase { tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "less" : "more")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 2L : 3L)); filter2 = filter1.getAggregations().get(filter2Name); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 2L : 3L)); stats = filter2.getAggregations().get(statsName); assertThat(stats, notNullValue()); assertThat(stats.getMax(), equalTo(asc ? 4.0 : 2.0)); @@ -1208,13 +1208,13 @@ public class StringTermsTests extends AbstractTermsTestCase { Terms.Bucket tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "more" : "less")); - assertThat(tag.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(tag.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 3L : 2L)); Filter filter2 = filter1.getAggregations().get(filter2Name); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 3l : 2l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 3L : 2L)); Stats stats = filter2.getAggregations().get(statsName); assertThat(stats, notNullValue()); assertThat(stats.getMax(), equalTo(asc ? 2.0 : 4.0)); @@ -1222,13 +1222,13 @@ public class StringTermsTests extends AbstractTermsTestCase { tag = iters.next(); assertThat(tag, notNullValue()); assertThat(key(tag), equalTo(asc ? "less" : "more")); - assertThat(tag.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(tag.getDocCount(), equalTo(asc ? 2L : 3L)); filter1 = tag.getAggregations().get("filter1"); assertThat(filter1, notNullValue()); - assertThat(filter1.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter1.getDocCount(), equalTo(asc ? 2L : 3L)); filter2 = filter1.getAggregations().get(filter2Name); assertThat(filter2, notNullValue()); - assertThat(filter2.getDocCount(), equalTo(asc ? 2l : 3l)); + assertThat(filter2.getDocCount(), equalTo(asc ? 2L : 3L)); stats = filter2.getAggregations().get(statsName); assertThat(stats, notNullValue()); assertThat(stats.getMax(), equalTo(asc ? 4.0 : 2.0)); @@ -1333,7 +1333,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Avg avg = bucket.getAggregations().get("avg_i"); assertThat(avg, notNullValue()); @@ -1364,7 +1364,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1394,7 +1394,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); Stats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1426,7 +1426,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ExtendedStats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1460,7 +1460,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket bucket : terms.getBuckets()) { assertThat(bucket, notNullValue()); assertThat(key(bucket), equalTo("val" + i)); - assertThat(bucket.getDocCount(), equalTo(1l)); + assertThat(bucket.getDocCount(), equalTo(1L)); ExtendedStats stats = bucket.getAggregations().get("stats"); assertThat(stats, notNullValue()); @@ -1473,7 +1473,7 @@ public class StringTermsTests extends AbstractTermsTestCase { for (Terms.Bucket subBucket : subTermsAgg.getBuckets()) { assertThat(subBucket, notNullValue()); assertThat(key(subBucket), equalTo("val" + j)); - assertThat(subBucket.getDocCount(), equalTo(1l)); + assertThat(subBucket.getDocCount(), equalTo(1L)); j++; } i++; diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java index ae23856dc33..93e0bec6ab6 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentileRanksTests.java @@ -115,12 +115,12 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(randomCompression(percentileRanks("percentile_ranks")) .values(10, 15))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -142,7 +142,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase { .values(0, 10, 15, 100)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); PercentileRanks reversePercentiles = searchResponse.getAggregations().get("percentile_ranks"); assertThat(reversePercentiles, notNullValue()); @@ -185,7 +185,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); @@ -404,7 +404,7 @@ public class TDigestPercentileRanksTests extends AbstractNumericTestCase { SearchResponse searchResponse = client().prepareSearch("idx") .setQuery(matchAllQuery()) .addAggregation( - histogram("histo").field("value").interval(2l) + histogram("histo").field("value").interval(2L) .subAggregation(randomCompression(percentileRanks("percentile_ranks").values(99))) .order(Order.aggregation("percentile_ranks", "99", asc))) .execute().actionGet(); diff --git a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java index da1bfc022d2..5bc34dc96d9 100644 --- a/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java +++ b/modules/lang-groovy/src/test/java/org/elasticsearch/messy/tests/TDigestPercentilesTests.java @@ -114,12 +114,12 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase { public void testEmptyAggregation() throws Exception { SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx") .setQuery(matchAllQuery()) - .addAggregation(histogram("histo").field("value").interval(1l).minDocCount(0) + .addAggregation(histogram("histo").field("value").interval(1L).minDocCount(0) .subAggregation(randomCompression(percentiles("percentiles")) .percentiles(10, 15))) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(2L)); Histogram histo = searchResponse.getAggregations().get("histo"); assertThat(histo, notNullValue()); Histogram.Bucket bucket = histo.getBuckets().get(1); @@ -141,7 +141,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase { .percentiles(0, 10, 15, 100)) .execute().actionGet(); - assertThat(searchResponse.getHits().getTotalHits(), equalTo(0l)); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(0L)); Percentiles percentiles = searchResponse.getAggregations().get("percentiles"); assertThat(percentiles, notNullValue()); @@ -183,7 +183,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase { Global global = searchResponse.getAggregations().get("global"); assertThat(global, notNullValue()); assertThat(global.getName(), equalTo("global")); - assertThat(global.getDocCount(), equalTo(10l)); + assertThat(global.getDocCount(), equalTo(10L)); assertThat(global.getAggregations(), notNullValue()); assertThat(global.getAggregations().asMap().size(), equalTo(1)); @@ -387,7 +387,7 @@ public class TDigestPercentilesTests extends AbstractNumericTestCase { SearchResponse searchResponse = client().prepareSearch("idx") .setQuery(matchAllQuery()) .addAggregation( - histogram("histo").field("value").interval(2l) + histogram("histo").field("value").interval(2L) .subAggregation(randomCompression(percentiles("percentiles").percentiles(99))) .order(Order.aggregation("percentiles", "99", asc))) .execute().actionGet(); diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java index 4fd83f9a850..9f00f58ae99 100644 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java +++ b/modules/lang-mustache/src/test/java/org/elasticsearch/messy/tests/SuggestSearchTests.java @@ -20,43 +20,6 @@ package org.elasticsearch.messy.tests; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; -import org.elasticsearch.action.index.IndexRequestBuilder; -import org.elasticsearch.action.search.ReduceSearchPhaseException; -import org.elasticsearch.action.search.SearchPhaseExecutionException; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.ShardSearchFailure; -import org.elasticsearch.action.suggest.SuggestRequestBuilder; -import org.elasticsearch.action.suggest.SuggestResponse; -import org.elasticsearch.common.io.PathUtils; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.script.mustache.MustachePlugin; -import org.elasticsearch.search.suggest.Suggest; -import org.elasticsearch.search.suggest.SuggestBuilder; -import org.elasticsearch.search.suggest.SuggestBuilder.SuggestionBuilder; -import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder; -import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.DirectCandidateGenerator; -import org.elasticsearch.search.suggest.term.TermSuggestionBuilder; -import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ExecutionException; - import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -76,6 +39,43 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.nullValue; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.search.ReduceSearchPhaseException; +import org.elasticsearch.action.search.SearchPhaseExecutionException; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.ShardSearchFailure; +import org.elasticsearch.action.suggest.SuggestRequestBuilder; +import org.elasticsearch.action.suggest.SuggestResponse; +import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.script.mustache.MustachePlugin; +import org.elasticsearch.search.suggest.Suggest; +import org.elasticsearch.search.suggest.SuggestBuilder; +import org.elasticsearch.search.suggest.SuggestBuilder.SuggestionBuilder; +import org.elasticsearch.search.suggest.phrase.DirectCandidateGeneratorBuilder; +import org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder; +import org.elasticsearch.search.suggest.term.TermSuggestionBuilder; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; + /** * Integration tests for term and phrase suggestions. Many of these tests many requests that vary only slightly from one another. Where * possible these tests should declare for the first request, make the request, modify the configuration for the next request, make that @@ -213,7 +213,7 @@ public class SuggestSearchTests extends ESIntegTestCase { index("test", "type1", "3", "name", "I like ice cream."); refresh(); - DirectCandidateGenerator generator = candidateGenerator("name").prefixLength(0).minWordLength(0).suggestMode("always").maxEdits(2); + DirectCandidateGeneratorBuilder generator = candidateGenerator("name").prefixLength(0).minWordLength(0).suggestMode("always").maxEdits(2); PhraseSuggestionBuilder phraseSuggestion = phraseSuggestion("did_you_mean").field("name.shingled") .addCandidateGenerator(generator) .gramSize(3); diff --git a/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java b/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java index a4aa334e399..232b056535c 100644 --- a/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java +++ b/plugins/delete-by-query/src/test/java/org/elasticsearch/plugin/deletebyquery/DeleteByQueryTests.java @@ -72,7 +72,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { public void testDeleteByQueryWithNoIndices() throws Exception { DeleteByQueryRequestBuilder delete = newDeleteByQuery().setQuery(QueryBuilders.matchAllQuery()); delete.setIndicesOptions(IndicesOptions.fromOptions(false, true, true, false)); - assertDBQResponse(delete.get(), 0L, 0l, 0l, 0l); + assertDBQResponse(delete.get(), 0L, 0L, 0L, 0L); assertSearchContextsClosed(); } @@ -85,7 +85,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { assertHitCount(client().prepareSearch("test").setSize(0).get(), docs); DeleteByQueryRequestBuilder delete = newDeleteByQuery().setIndices("t*").setQuery(QueryBuilders.matchAllQuery()); - assertDBQResponse(delete.get(), docs, docs, 0l, 0l); + assertDBQResponse(delete.get(), docs, docs, 0L, 0L); refresh(); assertHitCount(client().prepareSearch("test").setSize(0).get(), 0); assertSearchContextsClosed(); @@ -124,7 +124,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { refresh(); // Checks that the DBQ response returns the expected number of deletions - assertDBQResponse(response, deletions, deletions, 0l, 0l); + assertDBQResponse(response, deletions, deletions, 0L, 0L); assertNotNull(response.getIndices()); assertThat(response.getIndices().length, equalTo(indices)); @@ -160,7 +160,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { } delete.setIndicesOptions(IndicesOptions.lenientExpandOpen()); - assertDBQResponse(delete.get(), 1L, 1L, 0l, 0l); + assertDBQResponse(delete.get(), 1L, 1L, 0L, 0L); refresh(); assertHitCount(client().prepareSearch("test").setSize(0).get(), 0); assertSearchContextsClosed(); @@ -178,7 +178,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { assertHitCount(client().prepareSearch().setSize(0).setTypes("type2").get(), docs); DeleteByQueryRequestBuilder delete = newDeleteByQuery().setTypes("type1").setQuery(QueryBuilders.matchAllQuery()); - assertDBQResponse(delete.get(), docs, docs, 0l, 0l); + assertDBQResponse(delete.get(), docs, docs, 0L, 0L); refresh(); assertHitCount(client().prepareSearch().setSize(0).get(), docs); @@ -208,7 +208,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { logger.info("--> delete all documents with routing [{}] with a delete-by-query", routing); DeleteByQueryRequestBuilder delete = newDeleteByQuery().setRouting(routing).setQuery(QueryBuilders.matchAllQuery()); - assertDBQResponse(delete.get(), expected, expected, 0l, 0l); + assertDBQResponse(delete.get(), expected, expected, 0L, 0L); refresh(); assertHitCount(client().prepareSearch().setSize(0).get(), docs - expected); @@ -231,7 +231,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { assertHitCount(client().prepareSearch("test").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get(), numDocs); DeleteByQueryRequestBuilder delete = newDeleteByQuery().setIndices("alias").setQuery(QueryBuilders.matchQuery("_id", Integer.toString(n))); - assertDBQResponse(delete.get(), 1L, 1L, 0l, 0l); + assertDBQResponse(delete.get(), 1L, 1L, 0L, 0L); refresh(); assertHitCount(client().prepareSearch("test").setSize(0).setQuery(QueryBuilders.matchAllQuery()).get(), numDocs - 1); assertSearchContextsClosed(); @@ -244,7 +244,7 @@ public class DeleteByQueryTests extends ESIntegTestCase { assertHitCount(client().prepareSearch("test").setSize(0).get(), 1); DeleteByQueryRequestBuilder delete = newDeleteByQuery().setIndices("test").setQuery(QueryBuilders.rangeQuery("d").to("now-1h")); - assertDBQResponse(delete.get(), 1L, 1L, 0l, 0l); + assertDBQResponse(delete.get(), 1L, 1L, 0L, 0L); refresh(); assertHitCount(client().prepareSearch("test").setSize(0).get(), 0); assertSearchContextsClosed(); @@ -267,12 +267,12 @@ public class DeleteByQueryTests extends ESIntegTestCase { assertThat(searchResponse.getHits().totalHits(), equalTo((long) numDocs + 1)); DeleteByQueryResponse delete = newDeleteByQuery().setIndices("test").setQuery(QueryBuilders.termQuery("field", "value")).get(); - assertDBQResponse(delete, numDocs, numDocs, 0l, 0l); + assertDBQResponse(delete, numDocs, numDocs, 0L, 0L); refresh(); searchResponse = client().prepareSearch("test").get(); assertNoFailures(searchResponse); - assertThat(searchResponse.getHits().totalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().totalHits(), equalTo(1L)); assertSearchContextsClosed(); } diff --git a/plugins/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java b/plugins/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java index b1c25f5a1ec..dbcdbbc1a7d 100644 --- a/plugins/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java +++ b/plugins/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java @@ -35,6 +35,8 @@ import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.ingest.core.AbstractProcessor; import org.elasticsearch.ingest.core.AbstractProcessorFactory; import org.elasticsearch.ingest.core.IngestDocument; +import org.elasticsearch.ingest.core.Processor; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import java.io.Closeable; import java.io.IOException; @@ -226,10 +228,10 @@ public final class GeoIpProcessor extends AbstractProcessor { @Override public GeoIpProcessor doCreate(String processorTag, Map config) throws Exception { - String ipField = readStringProperty(config, "source_field"); - String targetField = readStringProperty(config, "target_field", "geoip"); - String databaseFile = readStringProperty(config, "database_file", "GeoLite2-City.mmdb"); - List fieldNames = readOptionalList(config, "fields"); + String ipField = readStringProperty(TYPE, processorTag, config, "source_field"); + String targetField = readStringProperty(TYPE, processorTag, config, "target_field", "geoip"); + String databaseFile = readStringProperty(TYPE, processorTag, config, "database_file", "GeoLite2-City.mmdb"); + List fieldNames = readOptionalList(TYPE, processorTag, config, "fields"); final Set fields; if (fieldNames != null) { @@ -238,7 +240,7 @@ public final class GeoIpProcessor extends AbstractProcessor { try { fields.add(Field.parse(fieldName)); } catch (Exception e) { - throw new IllegalArgumentException("illegal field option [" + fieldName +"]. valid values are [" + Arrays.toString(Field.values()) +"]", e); + throw new ConfigurationPropertyException(TYPE, processorTag, "fields", "illegal field option [" + fieldName + "]. valid values are [" + Arrays.toString(Field.values()) +"]"); } } } else { @@ -247,7 +249,7 @@ public final class GeoIpProcessor extends AbstractProcessor { DatabaseReader databaseReader = databaseReaders.get(databaseFile); if (databaseReader == null) { - throw new IllegalArgumentException("database file [" + databaseFile + "] doesn't exist"); + throw new ConfigurationPropertyException(TYPE, processorTag, "database_file", "database file [" + databaseFile + "] doesn't exist"); } return new GeoIpProcessor(processorTag, ipField, databaseReader, targetField, fields); } diff --git a/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java b/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java index 271476cc2f6..410f6e343f7 100644 --- a/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java +++ b/plugins/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/GeoIpProcessorFactoryTests.java @@ -21,6 +21,8 @@ package org.elasticsearch.ingest.geoip; import com.maxmind.geoip2.DatabaseReader; import org.elasticsearch.ingest.core.AbstractProcessorFactory; +import org.elasticsearch.ingest.core.Processor; +import org.elasticsearch.ingest.processor.ConfigurationPropertyException; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.StreamsUtils; import org.junit.AfterClass; @@ -111,8 +113,8 @@ public class GeoIpProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("Exception expected"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("database file [does-not-exist.mmdb] doesn't exist")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[database_file] database file [does-not-exist.mmdb] doesn't exist")); } } @@ -144,8 +146,8 @@ public class GeoIpProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("exception expected"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("illegal field option [invalid]. valid values are [[IP, COUNTRY_ISO_CODE, COUNTRY_NAME, CONTINENT_NAME, REGION_NAME, CITY_NAME, TIMEZONE, LATITUDE, LONGITUDE, LOCATION]]")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[fields] illegal field option [invalid]. valid values are [[IP, COUNTRY_ISO_CODE, COUNTRY_NAME, CONTINENT_NAME, REGION_NAME, CITY_NAME, TIMEZONE, LATITUDE, LONGITUDE, LOCATION]]")); } config = new HashMap<>(); @@ -154,8 +156,8 @@ public class GeoIpProcessorFactoryTests extends ESTestCase { try { factory.create(config); fail("exception expected"); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), equalTo("property [fields] isn't a list, but of type [java.lang.String]")); + } catch (ConfigurationPropertyException e) { + assertThat(e.getMessage(), equalTo("[fields] property isn't a list, but of type [java.lang.String]")); } } } diff --git a/plugins/lang-painless/src/test/java/org/elasticsearch/painless/FieldTests.java b/plugins/lang-painless/src/test/java/org/elasticsearch/painless/FieldTests.java index 86324ae6aa3..f31a022d038 100644 --- a/plugins/lang-painless/src/test/java/org/elasticsearch/painless/FieldTests.java +++ b/plugins/lang-painless/src/test/java/org/elasticsearch/painless/FieldTests.java @@ -29,7 +29,7 @@ public class FieldTests extends ScriptTestCase { public char c = 'c'; public int i = 2; public int si = -1; - public long j = 3l; + public long j = 3L; public float f = 4.0f; public double d = 5.0; public String t = "s"; diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureRepositoryF.java b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureRepositoryF.java index 771344d56eb..4150fe54979 100644 --- a/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureRepositoryF.java +++ b/plugins/repository-azure/src/test/java/org/elasticsearch/repositories/azure/AzureRepositoryF.java @@ -19,12 +19,15 @@ package org.elasticsearch.repositories.azure; +import org.apache.lucene.util.IOUtils; +import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.MockNode; import org.elasticsearch.node.Node; import org.elasticsearch.plugin.repository.azure.AzureRepositoryPlugin; +import java.io.IOException; import java.util.Collections; import java.util.concurrent.CountDownLatch; @@ -112,8 +115,13 @@ public class AzureRepositoryF { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - node.close(); - latch.countDown(); + try { + IOUtils.close(node); + } catch (IOException e) { + throw new ElasticsearchException(e); + } finally { + latch.countDown(); + } } }); node.start(); diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java index 1756e6b7dad..ca9f5aa96a7 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.tribe; +import org.apache.lucene.util.IOUtils; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -34,6 +35,7 @@ import org.elasticsearch.test.InternalTestCluster; import org.junit.AfterClass; import org.junit.BeforeClass; +import java.io.IOException; import java.nio.file.Path; import static org.hamcrest.CoreMatchers.either; @@ -76,10 +78,9 @@ public class TribeUnitTests extends ESTestCase { } @AfterClass - public static void closeTribes() { - tribe1.close(); + public static void closeTribes() throws IOException { + IOUtils.close(tribe1, tribe2); tribe1 = null; - tribe2.close(); tribe2 = null; } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_crud.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_crud.yaml index bf0817f2da1..74808331446 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_crud.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/10_crud.yaml @@ -50,6 +50,29 @@ ] } +--- +"Test invalid processor config": + - do: + ingest.put_pipeline: + id: "my_pipeline" + body: > + { + "description": "_description", + "processors": [ + { + "set" : { + "tag" : "fritag" + } + } + ] + } + - match: { "acknowledged": false } + - length: { "error": 4 } + - match: { "error.reason": "[field] required property is missing" } + - match: { "error.property_name": "field" } + - match: { "error.type": "set" } + - match: { "error.tag": "fritag" } + --- "Test basic pipeline with on_failure in processor": - do: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/40_simulate.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/40_simulate.yaml index e61ad4e60a6..92fad242db9 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/40_simulate.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/ingest/40_simulate.yaml @@ -81,6 +81,7 @@ "processors": [ { "set" : { + "tag" : "fails", "value" : "_value" } } @@ -97,10 +98,11 @@ } ] } - - length: { error: 3 } - - match: { status: 400 } - - match: { error.type: "illegal_argument_exception" } - - match: { error.reason: "required property [field] is missing" } + - length: { error: 4 } + - match: { error.tag: "fails" } + - match: { error.type: "set" } + - match: { error.reason: "[field] required property is missing" } + - match: { error.property_name: "field" } --- "Test simulate without index type and id": @@ -189,10 +191,45 @@ } ] } - - length: { error: 3 } - - match: { status: 400 } - - match: { error.type: "illegal_argument_exception" } - - match: { error.reason: "required property [pipeline] is missing" } + - length: { error: 4 } + - is_false: error.processor_type + - is_false: error.processor_tag + - match: { error.property_name: "pipeline" } + - match: { error.reason: "[pipeline] required property is missing" } + +--- +"Test simulate with invalid processor config": + - do: + catch: request + ingest.simulate: + body: > + { + "pipeline": { + "description": "_description", + "processors": [ + { + "set" : { + "field" : "field2" + } + } + ] + }, + "docs": [ + { + "_index": "index", + "_type": "type", + "_id": "id", + "_source": { + "foo": "bar" + } + } + ] + } + - length: { error: 4 } + - match: { error.type: "set" } + - is_false: error.tag + - match: { error.reason: "[value] required property is missing" } + - match: { error.property_name: "value" } --- "Test simulate with verbose flag": diff --git a/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java index 2148d0a71c5..f9f57feb916 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/CompositeTestCluster.java @@ -241,8 +241,8 @@ public class CompositeTestCluster extends TestCluster { } @Override - public synchronized Iterator iterator() { - return Collections.singleton(client()).iterator(); + public synchronized Iterable getClients() { + return Collections.singleton(client()); } /** diff --git a/test/framework/src/main/java/org/elasticsearch/test/CorruptionUtils.java b/test/framework/src/main/java/org/elasticsearch/test/CorruptionUtils.java index a630f24214d..15b72c4cccd 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/CorruptionUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/CorruptionUtils.java @@ -80,7 +80,7 @@ public final class CorruptionUtils { long checksumAfterCorruption; long actualChecksumAfterCorruption; try (ChecksumIndexInput input = dir.openChecksumInput(fileToCorrupt.getFileName().toString(), IOContext.DEFAULT)) { - assertThat(input.getFilePointer(), is(0l)); + assertThat(input.getFilePointer(), is(0L)); input.seek(input.length() - 8); // one long is the checksum... 8 bytes checksumAfterCorruption = input.getChecksum(); actualChecksumAfterCorruption = input.readLong(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index d2a6039d1a2..cddf4632cf8 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -129,6 +129,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.lang.annotation.Annotation; @@ -675,7 +676,7 @@ public abstract class ESIntegTestCase extends ESTestCase { } public static Iterable clients() { - return cluster(); + return cluster().getClients(); } protected int minimumNumberOfShards() { @@ -1099,7 +1100,7 @@ public abstract class ESIntegTestCase extends ESTestCase { Map masterStateMap = convertToMap(masterClusterState); int masterClusterStateSize = masterClusterState.toString().length(); String masterId = masterClusterState.nodes().masterNodeId(); - for (Client client : cluster()) { + for (Client client : cluster().getClients()) { ClusterState localClusterState = client.admin().cluster().prepareState().all().setLocal(true).get().getState(); byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState); // remove local node reference diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java index f2f1d19bc9f..a3736f691d4 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java @@ -18,6 +18,7 @@ */ package org.elasticsearch.test; +import org.apache.lucene.util.IOUtils; import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; @@ -51,6 +52,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -68,7 +70,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { private static Node NODE = null; - private void reset() { + private void reset() throws IOException { assert NODE != null; stopNode(); startNode(); @@ -83,13 +85,13 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { assertFalse(clusterHealthResponse.isTimedOut()); } - private static void stopNode() { + private static void stopNode() throws IOException { Node node = NODE; NODE = null; - Releasables.close(node); + IOUtils.close(node); } - private void cleanup(boolean resetNode) { + private void cleanup(boolean resetNode) throws IOException { assertAcked(client().admin().indices().prepareDelete("*").get()); if (resetNode) { reset(); @@ -126,7 +128,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { } @AfterClass - public static void tearDownClass() { + public static void tearDownClass() throws IOException { stopNode(); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 558d05e19c2..67cae85f4c3 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -29,6 +29,7 @@ import com.carrotsearch.randomizedtesting.generators.RandomInts; import com.carrotsearch.randomizedtesting.generators.RandomPicks; import com.carrotsearch.randomizedtesting.generators.RandomStrings; import com.carrotsearch.randomizedtesting.rules.TestRuleAdapter; +import junit.framework.AssertionFailedError; import org.apache.lucene.uninverting.UninvertingReader; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; @@ -620,4 +621,25 @@ public abstract class ESTestCase extends LuceneTestCase { assertEquals(expected.getLineNumber(), actual.getLineNumber()); assertEquals(expected.isNativeMethod(), actual.isNativeMethod()); } + + /** A runnable that can throw any checked exception. */ + @FunctionalInterface + public interface ThrowingRunnable { + void run() throws Throwable; + } + + /** Checks a specific exception class is thrown by the given runnable, and returns it. */ + public static T expectThrows(Class expectedType, ThrowingRunnable runnable) { + try { + runnable.run(); + } catch (Throwable e) { + if (expectedType.isInstance(e)) { + return expectedType.cast(e); + } + AssertionFailedError assertion = new AssertionFailedError("Unexpected exception type, expected " + expectedType.getSimpleName()); + assertion.initCause(e); + throw assertion; + } + throw new AssertionFailedError("Expected exception " + expectedType.getSimpleName()); + } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java index e54b177fb30..21cf79f6075 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ExternalTestCluster.java @@ -159,16 +159,16 @@ public final class ExternalTestCluster extends TestCluster { // because checking it requires a network request, which in // turn increments the breaker, making it non-0 - assertThat("Fielddata size must be 0 on node: " + stats.getNode(), stats.getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0l)); - assertThat("Query cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0l)); - assertThat("FixedBitSet cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getSegments().getBitsetMemoryInBytes(), equalTo(0l)); + assertThat("Fielddata size must be 0 on node: " + stats.getNode(), stats.getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); + assertThat("Query cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); + assertThat("FixedBitSet cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); } } } @Override - public Iterator iterator() { - return Collections.singleton(client).iterator(); + public Iterable getClients() { + return Collections.singleton(client); } @Override diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index c1136c248f6..658264864e0 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -815,7 +815,7 @@ public final class InternalTestCluster extends TestCluster { } } - void closeNode() { + void closeNode() throws IOException { registerDataPath(); node.close(); } @@ -1720,27 +1720,29 @@ public final class InternalTestCluster extends TestCluster { return null; } - @Override - public synchronized Iterator iterator() { + public synchronized Iterable getClients() { ensureOpen(); - final Iterator iterator = nodes.values().iterator(); - return new Iterator() { + return () -> { + ensureOpen(); + final Iterator iterator = nodes.values().iterator(); + return new Iterator() { - @Override - public boolean hasNext() { - return iterator.hasNext(); - } + @Override + public boolean hasNext() { + return iterator.hasNext(); + } - @Override - public Client next() { - return iterator.next().client(random); - } + @Override + public Client next() { + return iterator.next().client(random); + } - @Override - public void remove() { - throw new UnsupportedOperationException(""); - } + @Override + public void remove() { + throw new UnsupportedOperationException(""); + } + }; }; } @@ -1847,9 +1849,9 @@ public final class InternalTestCluster extends TestCluster { NodeService nodeService = getInstanceFromNode(NodeService.class, nodeAndClient.node); NodeStats stats = nodeService.stats(CommonStatsFlags.ALL, false, false, false, false, false, false, false, false, false, false); - assertThat("Fielddata size must be 0 on node: " + stats.getNode(), stats.getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0l)); - assertThat("Query cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0l)); - assertThat("FixedBitSet cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getSegments().getBitsetMemoryInBytes(), equalTo(0l)); + assertThat("Fielddata size must be 0 on node: " + stats.getNode(), stats.getIndices().getFieldData().getMemorySizeInBytes(), equalTo(0L)); + assertThat("Query cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getQueryCache().getMemorySizeInBytes(), equalTo(0L)); + assertThat("FixedBitSet cache size must be 0 on node: " + stats.getNode(), stats.getIndices().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); } } } diff --git a/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java index 77f8de84390..2629f655c95 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/TestCluster.java @@ -43,7 +43,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke * Base test cluster that exposes the basis to run tests against any elasticsearch cluster, whose layout * (e.g. number of nodes) is predefined and cannot be changed during the tests execution */ -public abstract class TestCluster implements Iterable, Closeable { +public abstract class TestCluster implements Closeable { protected final ESLogger logger = Loggers.getLogger(getClass()); private final long seed; @@ -228,5 +228,10 @@ public abstract class TestCluster implements Iterable, Closeable { */ public abstract String getClusterName(); + /** + * Returns an {@link Iterable} over all clients in this test cluster + */ + public abstract Iterable getClients(); + } diff --git a/test/framework/src/main/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java b/test/framework/src/main/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java index 153850416f9..fea083b841b 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java +++ b/test/framework/src/main/java/org/elasticsearch/test/discovery/ClusterDiscoveryConfiguration.java @@ -115,9 +115,7 @@ public class ClusterDiscoveryConfiguration extends NodeConfigurationSource { } else { // we need to pin the node port & host so we'd know where to point things builder.put(TransportSettings.PORT.getKey(), unicastHostPorts[nodeOrdinal]); - builder.put("transport.host", IP_ADDR); // only bind on one IF we use v4 here by default - builder.put("transport.bind_host", IP_ADDR); - builder.put("transport.publish_host", IP_ADDR); + builder.put(TransportSettings.HOST.getKey(), IP_ADDR); // only bind on one IF we use v4 here by default builder.put("http.enabled", false); for (int i = 0; i < unicastHostOrdinals.length; i++) { unicastHosts[i] = IP_ADDR + ":" + (unicastHostPorts[unicastHostOrdinals[i]]); diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java new file mode 100644 index 00000000000..0d44fc4abcd --- /dev/null +++ b/test/framework/src/test/java/org/elasticsearch/test/test/ESTestCaseTests.java @@ -0,0 +1,51 @@ +/* + * 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.test.test; + +import junit.framework.AssertionFailedError; +import org.elasticsearch.test.ESTestCase; + +public class ESTestCaseTests extends ESTestCase { + public void testExpectThrows() { + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> { + throw new IllegalArgumentException("bad arg"); + }); + assertEquals("bad arg", e.getMessage()); + + try { + expectThrows(IllegalArgumentException.class, () -> { + throw new IllegalStateException("bad state"); + }); + fail("expected assertion error"); + } catch (AssertionFailedError assertFailed) { + assertEquals("Unexpected exception type, expected IllegalArgumentException", assertFailed.getMessage()); + assertNotNull(assertFailed.getCause()); + assertEquals("bad state", assertFailed.getCause().getMessage()); + } + + try { + expectThrows(IllegalArgumentException.class, () -> {}); + fail("expected assertion error"); + } catch (AssertionFailedError assertFailed) { + assertNull(assertFailed.getCause()); + assertEquals("Expected exception IllegalArgumentException", assertFailed.getMessage()); + } + } +} diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java index 8b75e7f6e1e..2c7e35fa4ea 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java @@ -130,8 +130,8 @@ public class InternalTestClusterTests extends ESTestCase { cluster1.beforeTest(random, random.nextDouble()); } assertArrayEquals(cluster0.getNodeNames(), cluster1.getNodeNames()); - Iterator iterator1 = cluster1.iterator(); - for (Client client : cluster0) { + Iterator iterator1 = cluster1.getClients().iterator(); + for (Client client : cluster0.getClients()) { assertTrue(iterator1.hasNext()); Client other = iterator1.next(); assertSettings(client.settings(), other.settings(), false);