Class AggregatorTestCase
- Direct Known Subclasses:
BaseCompositeAggregatorTestCase
Aggregator implementations.
Provides helpers for constructing and searching an Aggregator implementation based on a provided
AggregationBuilder instance.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classWrapper around Aggregator class Maintains a count for times collect() is invoked - number of documents visitedstatic classNested classes/interfaces inherited from class org.opensearch.test.OpenSearchTestCase
OpenSearchTestCase.AnnotatedFeatureFlagRule, OpenSearchTestCase.GeohashGenerator, OpenSearchTestCase.LockFeatureFlag, OpenSearchTestCase.TestAnalysisNested classes/interfaces inherited from class org.apache.lucene.tests.util.LuceneTestCase
org.apache.lucene.tests.util.LuceneTestCase.AwaitsFix, org.apache.lucene.tests.util.LuceneTestCase.Concurrency, org.apache.lucene.tests.util.LuceneTestCase.Monster, org.apache.lucene.tests.util.LuceneTestCase.Nightly, org.apache.lucene.tests.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.tests.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.tests.util.LuceneTestCase.SuppressFsync, org.apache.lucene.tests.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.tests.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.tests.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.tests.util.LuceneTestCase.ThrowingConsumer<T>, org.apache.lucene.tests.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.tests.util.LuceneTestCase.Weekly -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.opensearch.common.TriConsumer<org.apache.lucene.document.Document, String, String> protected static final org.opensearch.common.TriConsumer<org.apache.lucene.document.Document, String, String> protected org.opensearch.search.aggregations.support.ValuesSourceRegistryFields inherited from class org.opensearch.test.OpenSearchTestCase
checkIndexFailures, DEFAULT_NAMED_WRITABLE_REGISTRY, DEFAULT_TEST_WORKER_ID, failureAndSuccessEvents, flagLockRule, JAVA_TIMEZONE_IDS, JAVA_ZONE_IDS, JODA_TIMEZONE_IDS, logger, TEST_WORKER_SYS_PROPERTY, TEST_WORKER_VM_IDFields inherited from class org.apache.lucene.tests.util.LuceneTestCase
assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_THROTTLING, TEST_WEEKLY, VERBOSE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidHook for checking things after allAggregators have been closed.static org.opensearch.search.aggregations.AggregationBuilderaggCardinality(String name) Request an aggregation that returns theCardinalityUpperBoundthat was passed to its ctor.protected org.opensearch.search.aggregations.AggregationBuildercreateAggBuilderForTypeTest(org.opensearch.index.mapper.MappedFieldType fieldType, String fieldName) This method is invoked each time a field type is tested intestSupportedFieldTypes().protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregator(org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregator(org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregator(org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.opensearch.search.internal.SearchContext searchContext) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateAggregatorWithCustomizableSearchContext(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, Consumer<org.opensearch.search.internal.SearchContext> customizeSearchContext, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected AggregatorTestCase.CountingAggregatorcreateCountingAggregator(org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.index.codec.composite.CompositeIndexFieldInfo starTree, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected org.opensearch.index.IndexSettingsprotected org.opensearch.search.internal.SearchContextcreateSearchContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected org.opensearch.search.internal.SearchContextcreateSearchContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) Create a SearchContext for testing anAggregator.protected org.opensearch.search.internal.SearchContextcreateSearchContextWithStarTreeContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.index.codec.composite.CompositeIndexFieldInfo starTree, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.Aggregator>
AcreateStreamAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected org.opensearch.index.mapper.DateFieldMapper.DateFieldTypeMake a DateFieldMapper.DateFieldType for adate.protected voiddoAssertReducedMultiBucketConsumer(org.opensearch.search.aggregations.Aggregation agg, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer) protected org.opensearch.index.mapper.NumberFieldMapper.NumberFieldTypedoubleField(String name) Make a NumberFieldMapper.NumberFieldType for adouble.protected org.opensearch.index.mapper.GeoPointFieldMapper.GeoPointFieldTypegeoPointField(String name) Make a GeoPointFieldMapper.GeoPointFieldType for ageo_point.getFieldAliases(org.opensearch.index.mapper.MappedFieldType... fieldTypes) Allows subclasses to provide alternate names for the provided field type, which can be useful when testing aggregations on field aliases.protected org.opensearch.common.TriFunction<org.opensearch.index.mapper.MappedFieldType, String, Supplier<org.opensearch.search.lookup.SearchLookup>, org.opensearch.index.fielddata.IndexFieldData<?>> getIndexFieldDataLookup(org.opensearch.index.mapper.MapperService mapperService, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService) Sub-tests that need a more complex index field data provider can override thisprotected org.opensearch.script.ScriptServiceSub-tests that need scripting can override this method to provide a script service and pre-baked scriptsprotected List<org.opensearch.plugins.SearchPlugin> Test cases should override this if they have plugins that need to be loaded, e.g.protected List<org.opensearch.search.aggregations.support.ValuesSourceType> Implementors should return a list ofValuesSourceTypethat the aggregator supports.voidprotected org.opensearch.index.mapper.KeywordFieldMapper.KeywordFieldTypekeywordField(String name) Make a DateFieldMapper.DateFieldType for adate.protected org.opensearch.index.mapper.NumberFieldMapper.NumberFieldTypeMake a NumberFieldMapper.NumberFieldType for along.protected org.opensearch.index.mapper.MapperServicesub-tests that need a more complex mock can overwrite thisprotected static org.apache.lucene.index.IndexReadermaybeWrapReaderEs(org.apache.lucene.index.DirectoryReader reader) Added to randomly run with more assertions on the index reader level, likeLuceneTestCase.wrapReader(IndexReader), which can't be used because it also wraps in the IndexReader with other implementations that we can't handle.protected static org.apache.lucene.search.IndexSearchernewIndexSearcher(org.apache.lucene.index.IndexReader indexReader) Added to randomly run with more assertions on the index searcher level, likeLuceneTestCase.newSearcher(IndexReader), which can't be used because it also wraps in the IndexSearcher's IndexReader with other implementations that we can't handle.protected org.opensearch.index.query.QueryShardContextqueryShardContextMock(org.apache.lucene.search.IndexSearcher searcher, org.opensearch.index.mapper.MapperService mapperService, org.opensearch.index.IndexSettings indexSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, org.opensearch.common.util.BigArrays bigArrays) sub-tests that need a more complex mock can overwrite thisprotected org.opensearch.index.mapper.RangeFieldMapper.RangeFieldTyperangeField(String name, org.opensearch.index.mapper.RangeType rangeType) Make a NumberFieldMapper.NumberFieldType for arange.protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduce(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, boolean hasNested, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) Collects all documents that match the provided queryQueryand returns the reducedInternalAggregation.protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduce(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduce(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduceCounting(int expectedCount, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, boolean hasNested, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) Collects all documents that match the provided queryQueryand returns the reducedInternalAggregation.protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduceStarTree(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.codec.composite.CompositeIndexFieldInfo compositeIndexFieldInfo, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, int maxBucket, boolean hasNested, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, boolean assertCollectorEarlyTermination, boolean skipReducedMultiBucketConsumerAssertion, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator>
AsearchAndReduceStarTree(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.codec.composite.CompositeIndexFieldInfo compositeIndexFieldInfo, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, int maxBucket, boolean hasNested, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, boolean assertCollectorEarlyTermination, org.opensearch.index.mapper.MappedFieldType... fieldTypes) protected <T extends org.opensearch.search.aggregations.AggregationBuilder, V extends org.opensearch.search.aggregations.InternalAggregation>
voidtestCase(T aggregationBuilder, org.apache.lucene.search.Query query, org.opensearch.common.CheckedConsumer<org.apache.lucene.tests.index.RandomIndexWriter, IOException> buildIndex, Consumer<V> verify, org.opensearch.index.mapper.MappedFieldType... fieldTypes) voidThis test will validate that an aggregator succeeds or fails to run against all the field types that are registered inIndicesModule(e.g.A method that allows implementors to specifically denylist particular field types (based on their content_name).protected org.apache.lucene.index.IndexReaderwrapDirectoryReader(org.apache.lucene.index.DirectoryReader reader) Override to wrap the DirectoryReader for aggs likeNestedAggregationBuilder.protected static org.apache.lucene.index.DirectoryReaderwrapInMockESDirectoryReader(org.apache.lucene.index.DirectoryReader directoryReader) Methods inherited from class org.opensearch.test.OpenSearchTestCase
after, afterIfFailed, afterIfSuccessful, allowedWarnings, assertArrayEquals, assertBusy, assertBusy, assertBusyWithFixedSleepTime, assertEquals, assertNoDeprecationWarnings, assertSettingDeprecationsAndWarnings, assertSettingDeprecationsAndWarnings, assertWarnings, assertWarnings, before, between, buildEnvSettings, buildNewFakeTransportAddress, checkStaticState, clearAdditionalRoles, copyInstance, copyNamedWriteable, copyNamedWriteable, copyWriteable, copyWriteable, createDefaultIndexAnalyzers, createParser, createParser, createParser, createParser, createParser, createParser, createTestAnalysis, createTestAnalysis, createTestAnalysis, enableJodaDeprecationWarningsCheck, enableWarningsCheck, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureSupportedLocale, frequently, generateRandomStringArray, generateRandomStringArray, getBasePort, getBasePort, getDataPath, getPortRange, getShardLevelBlobPath, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, inFipsJvm, iterations, maybeSet, mockScript, newNodeEnvironment, newNodeEnvironment, persistedStateRegistry, randomAlphaOfLength, randomAlphaOfLengthBetween, randomArray, randomArray, randomBigInteger, randomBoolean, randomByte, randomByteArrayOfLength, randomDateFormatterPattern, randomDateTimeZone, randomDouble, randomDoubleBetween, randomFloat, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomInt, randomInt, randomIntBetween, randomIp, randomList, randomList, randomLong, randomLongBetween, randomNonNegativeInt, randomNonNegativeLong, randomPositiveTimeValue, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomUnsignedLong, randomValueOtherThan, randomValueOtherThanMany, randomZone, remoteIndexSettings, removeHeaderWarningAppender, replaceUnicodeControlCharacters, replaceUnicodeControlCharacters, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, scaledRandomIntBetween, setContentType, setFileSystem, setHeaderWarningAppender, settings, shuffleMap, shuffleXContent, shuffleXContent, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, tearDown, terminate, terminate, tmpPaths, toShuffledXContent, toShuffledXContent, waitUntil, waitUntil, warmIndexSettings, writableRegistry, xContentRegistryMethods inherited from class org.apache.lucene.tests.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertDoubleUlpEquals, assertFieldInfosEquals, assertFloatUlpEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, assertThat, assertThat, asSet, assumeFalse, assumeNoException, assumeTrue, atLeast, atLeast, callStackContains, callStackContains, callStackContainsAnyOf, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, ensureSaneIWCOnNightly, expectThrows, expectThrows, expectThrows, expectThrowsAnyOf, expectThrowsAnyOf, getDataInputStream, getJvmForkArguments, getOnlyLeafReader, getTestClass, getTestName, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newBytesRef, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newSearcher, newSearcher, newSnapshotIndexWriterConfig, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, randomVectorFormat, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setUp, setupCPUCoreCount, setUpExecutorService, shutdownExecutorService, slowFileExists, usually, usually, wrapReaderMethods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
Field Details
-
valuesSourceRegistry
protected org.opensearch.search.aggregations.support.ValuesSourceRegistry valuesSourceRegistry -
ADD_SORTED_SET_FIELD_NOT_INDEXED
-
ADD_SORTED_SET_FIELD_INDEXED
-
-
Constructor Details
-
AggregatorTestCase
public AggregatorTestCase()
-
-
Method Details
-
getFieldAliases
-
initValuesSourceRegistry
public void initValuesSourceRegistry() -
getSearchPlugins
Test cases should override this if they have plugins that need to be loaded, e.g. the plugins their aggregators are in. -
createAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregator(org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregator(org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createStreamAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createStreamAggregator(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregatorWithCustomizableSearchContext
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregatorWithCustomizableSearchContext(org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, Consumer<org.opensearch.search.internal.SearchContext> customizeSearchContext, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createAggregator
protected <A extends org.opensearch.search.aggregations.Aggregator> A createAggregator(org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.opensearch.search.internal.SearchContext searchContext) throws IOException - Throws:
IOException
-
createCountingAggregator
protected AggregatorTestCase.CountingAggregator createCountingAggregator(org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.search.aggregations.AggregationBuilder aggregationBuilder, org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.opensearch.index.codec.composite.CompositeIndexFieldInfo starTree, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createSearchContext
protected org.opensearch.search.internal.SearchContext createSearchContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException Create a SearchContext for testing anAggregator.- Throws:
IOException
-
createSearchContextWithStarTreeContext
protected org.opensearch.search.internal.SearchContext createSearchContextWithStarTreeContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.index.codec.composite.CompositeIndexFieldInfo starTree, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createSearchContext
protected org.opensearch.search.internal.SearchContext createSearchContext(org.apache.lucene.search.IndexSearcher indexSearcher, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
createIndexSettings
protected org.opensearch.index.IndexSettings createIndexSettings() -
mapperServiceMock
protected org.opensearch.index.mapper.MapperService mapperServiceMock()sub-tests that need a more complex mock can overwrite this -
queryShardContextMock
protected org.opensearch.index.query.QueryShardContext queryShardContextMock(org.apache.lucene.search.IndexSearcher searcher, org.opensearch.index.mapper.MapperService mapperService, org.opensearch.index.IndexSettings indexSettings, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService, org.opensearch.common.util.BigArrays bigArrays) sub-tests that need a more complex mock can overwrite this -
getIndexFieldDataLookup
protected org.opensearch.common.TriFunction<org.opensearch.index.mapper.MappedFieldType, String, Supplier<org.opensearch.search.lookup.SearchLookup>, org.opensearch.index.fielddata.IndexFieldData<?>> getIndexFieldDataLookup(org.opensearch.index.mapper.MapperService mapperService, org.opensearch.core.indices.breaker.CircuitBreakerService circuitBreakerService) Sub-tests that need a more complex index field data provider can override this -
getMockScriptService
protected org.opensearch.script.ScriptService getMockScriptService()Sub-tests that need scripting can override this method to provide a script service and pre-baked scripts -
searchAndReduce
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduce(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduce(org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduce(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduce
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduce(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, boolean hasNested, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException Collects all documents that match the provided queryQueryand returns the reducedInternalAggregation.Half the time it aggregates each leaf individually and reduces all results together. The other half the time it aggregates across the entire index at once and runs a final reduction on the single resulting agg.
- Throws:
IOException
-
searchAndReduceCounting
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduceCounting(int expectedCount, org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.search.aggregations.AggregationBuilder builder, int maxBucket, boolean hasNested, boolean shardFanOut, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException Collects all documents that match the provided queryQueryand returns the reducedInternalAggregation.Half the time it aggregates each leaf individually and reduces all results together. The other half the time it aggregates across the entire index at once and runs a final reduction on the single resulting agg. The difference between this method and
<A,C>searchAndReduce(org.apache.lucene.search.IndexSearcher,org.apache.lucene.search.Query,org.opensearch.search.aggregations.AggregationBuilder,boolean,org.opensearch.index.mapper.MappedFieldType...)is that this method also asserts the the number of documents match the expectedCount.- Throws:
IOException
-
searchAndReduceStarTree
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduceStarTree(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.codec.composite.CompositeIndexFieldInfo compositeIndexFieldInfo, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, int maxBucket, boolean hasNested, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, boolean assertCollectorEarlyTermination, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
searchAndReduceStarTree
protected <A extends org.opensearch.search.aggregations.InternalAggregation, C extends org.opensearch.search.aggregations.Aggregator> A searchAndReduceStarTree(org.opensearch.index.IndexSettings indexSettings, org.apache.lucene.search.IndexSearcher searcher, org.apache.lucene.search.Query query, org.opensearch.index.query.QueryBuilder queryBuilder, org.opensearch.search.aggregations.AggregationBuilder builder, org.opensearch.index.codec.composite.CompositeIndexFieldInfo compositeIndexFieldInfo, LinkedHashMap<org.opensearch.index.compositeindex.datacube.Dimension, org.opensearch.index.mapper.MappedFieldType> supportedDimensions, List<org.opensearch.index.compositeindex.datacube.Metric> supportedMetrics, int maxBucket, boolean hasNested, org.opensearch.search.aggregations.AggregatorFactory aggregatorFactory, boolean assertCollectorEarlyTermination, boolean skipReducedMultiBucketConsumerAssertion, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
doAssertReducedMultiBucketConsumer
protected void doAssertReducedMultiBucketConsumer(org.opensearch.search.aggregations.Aggregation agg, org.opensearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer bucketConsumer) -
testCase
protected <T extends org.opensearch.search.aggregations.AggregationBuilder, V extends org.opensearch.search.aggregations.InternalAggregation> void testCase(T aggregationBuilder, org.apache.lucene.search.Query query, org.opensearch.common.CheckedConsumer<org.apache.lucene.tests.index.RandomIndexWriter, IOException> buildIndex, Consumer<V> verify, org.opensearch.index.mapper.MappedFieldType... fieldTypes) throws IOException - Throws:
IOException
-
wrapDirectoryReader
protected org.apache.lucene.index.IndexReader wrapDirectoryReader(org.apache.lucene.index.DirectoryReader reader) throws IOException Override to wrap the DirectoryReader for aggs likeNestedAggregationBuilder.- Throws:
IOException
-
wrapInMockESDirectoryReader
protected static org.apache.lucene.index.DirectoryReader wrapInMockESDirectoryReader(org.apache.lucene.index.DirectoryReader directoryReader) throws IOException - Throws:
IOException
-
newIndexSearcher
protected static org.apache.lucene.search.IndexSearcher newIndexSearcher(org.apache.lucene.index.IndexReader indexReader) Added to randomly run with more assertions on the index searcher level, likeLuceneTestCase.newSearcher(IndexReader), which can't be used because it also wraps in the IndexSearcher's IndexReader with other implementations that we can't handle. (e.g. ParallelCompositeReader) -
maybeWrapReaderEs
protected static org.apache.lucene.index.IndexReader maybeWrapReaderEs(org.apache.lucene.index.DirectoryReader reader) throws IOException Added to randomly run with more assertions on the index reader level, likeLuceneTestCase.wrapReader(IndexReader), which can't be used because it also wraps in the IndexReader with other implementations that we can't handle. (e.g. ParallelCompositeReader)- Throws:
IOException
-
getSupportedValuesSourceTypes
protected List<org.opensearch.search.aggregations.support.ValuesSourceType> getSupportedValuesSourceTypes()Implementors should return a list ofValuesSourceTypethat the aggregator supports. This is used to test the matrix of supported/unsupported field types against the aggregator and verify it works (or doesn't) as expected.If this method is implemented,
createAggBuilderForTypeTest(MappedFieldType, String)should be implemented as well.- Returns:
- list of supported ValuesSourceTypes
-
createAggBuilderForTypeTest
protected org.opensearch.search.aggregations.AggregationBuilder createAggBuilderForTypeTest(org.opensearch.index.mapper.MappedFieldType fieldType, String fieldName) This method is invoked each time a field type is tested intestSupportedFieldTypes(). The field type and name are provided, and the implementor is expected to return an AggBuilder accordingly. The AggBuilder should be returned even if the aggregation does not support the field type, because the test will check if an exception is thrown in that case.The list of supported types are provided by
getSupportedValuesSourceTypes(), which must also be implemented.- Parameters:
fieldType- the type of the field that will be testedfieldName- the name of the field that will be test- Returns:
- an aggregation builder to test against the field
-
unsupportedMappedFieldTypes
A method that allows implementors to specifically denylist particular field types (based on their content_name). This is needed in some areas where the ValuesSourceType is not granular enough, for example integer values vs floating points, or `keyword` bytes vs `binary` bytes (which are not searchable)This is a denylist instead of an allowlist because there are vastly more field types than ValuesSourceTypes, and it's expected that these unsupported cases are exceptional rather than common
-
testSupportedFieldTypes
This test will validate that an aggregator succeeds or fails to run against all the field types that are registered inIndicesModule(e.g. all the core field types). An aggregator is provided by the implementor class, and it is executed against each field type in turn. If an exception is thrown when the field is supported, that will fail the test. Similarly, if an exception _is not_ thrown when a field is unsupported, that will also fail the test.Exception types/messages are not currently checked, just presence/absence of an exception.
- Throws:
IOException
-
afterClose
protected void afterClose()Hook for checking things after allAggregators have been closed. -
dateField
protected org.opensearch.index.mapper.DateFieldMapper.DateFieldType dateField(String name, org.opensearch.index.mapper.DateFieldMapper.Resolution resolution) Make a DateFieldMapper.DateFieldType for adate. -
doubleField
Make a NumberFieldMapper.NumberFieldType for adouble. -
geoPointField
protected org.opensearch.index.mapper.GeoPointFieldMapper.GeoPointFieldType geoPointField(String name) Make a GeoPointFieldMapper.GeoPointFieldType for ageo_point. -
keywordField
Make a DateFieldMapper.DateFieldType for adate. -
longField
Make a NumberFieldMapper.NumberFieldType for along. -
rangeField
protected org.opensearch.index.mapper.RangeFieldMapper.RangeFieldType rangeField(String name, org.opensearch.index.mapper.RangeType rangeType) Make a NumberFieldMapper.NumberFieldType for arange. -
aggCardinality
Request an aggregation that returns theCardinalityUpperBoundthat was passed to its ctor.
-