Class AggregatorTestCase

    • Constructor Detail

      • AggregatorTestCase

        public AggregatorTestCase()
    • Method Detail

      • createAggregatorFactory

        protected AggregatorFactory<?> createAggregatorFactory​(AggregationBuilder aggregationBuilder,
                                                               org.apache.lucene.search.IndexSearcher indexSearcher,
                                                               MappedFieldType... fieldTypes)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • getFieldAliases

        protected java.util.Map<java.lang.String,​MappedFieldType> getFieldAliases​(MappedFieldType... fieldTypes)
        Allows subclasses to provide alternate names for the provided field type, which can be useful when testing aggregations on field aliases.
      • createAggregator

        protected <A extends Aggregator> A createAggregator​(AggregationBuilder aggregationBuilder,
                                                            org.apache.lucene.search.IndexSearcher indexSearcher,
                                                            MappedFieldType... fieldTypes)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • createAggregator

        protected <A extends Aggregator> A createAggregator​(org.apache.lucene.search.Query query,
                                                            AggregationBuilder aggregationBuilder,
                                                            org.apache.lucene.search.IndexSearcher indexSearcher,
                                                            IndexSettings indexSettings,
                                                            MappedFieldType... fieldTypes)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • createSearchContext

        protected SearchContext createSearchContext​(org.apache.lucene.search.IndexSearcher indexSearcher,
                                                    IndexSettings indexSettings)
      • createIndexSettings

        protected IndexSettings createIndexSettings()
      • mapperServiceMock

        protected MapperService mapperServiceMock()
        sub-tests that need a more complex mock can overwrite this
      • queryShardContextMock

        protected QueryShardContext queryShardContextMock​(MapperService mapperService)
        sub-tests that need a more complex mock can overwrite this
      • search

        protected <A extends InternalAggregation,​C extends Aggregator> A search​(org.apache.lucene.search.IndexSearcher searcher,
                                                                                      org.apache.lucene.search.Query query,
                                                                                      AggregationBuilder builder,
                                                                                      int maxBucket,
                                                                                      MappedFieldType... fieldTypes)
                                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • searchAndReduce

        protected <A extends InternalAggregation,​C extends Aggregator> A searchAndReduce​(org.apache.lucene.search.IndexSearcher searcher,
                                                                                               org.apache.lucene.search.Query query,
                                                                                               AggregationBuilder builder,
                                                                                               MappedFieldType... fieldTypes)
                                                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • searchAndReduce

        protected <A extends InternalAggregation,​C extends Aggregator> A searchAndReduce​(org.apache.lucene.search.IndexSearcher searcher,
                                                                                               org.apache.lucene.search.Query query,
                                                                                               AggregationBuilder builder,
                                                                                               int maxBucket,
                                                                                               ScriptService scriptService,
                                                                                               MappedFieldType... fieldTypes)
                                                                                        throws java.io.IOException
        Divides the provided IndexSearcher in sub-searcher, one for each segment, builds an aggregator for each sub-searcher filtered by the provided Query and returns the reduced InternalAggregation.
        Throws:
        java.io.IOException
      • newIndexSearcher

        protected static org.apache.lucene.search.IndexSearcher newIndexSearcher​(IndexReader indexReader)
        Added to randomly run with more assertions on the index searcher level, like LuceneTestCase.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 IndexReader maybeWrapReaderEs​(DirectoryReader reader)
                                                throws java.io.IOException
        Added to randomly run with more assertions on the index reader level, like LuceneTestCase.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:
        java.io.IOException