Class BaseCompositeAggregatorTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.opensearch.test.OpenSearchTestCase
org.opensearch.search.aggregations.AggregatorTestCase
org.opensearch.search.aggregations.composite.BaseCompositeAggregatorTestCase

public class BaseCompositeAggregatorTestCase extends AggregatorTestCase
Base class for the Aggregator Tests which are registered under Composite Aggregation.
  • Field Details

    • FIELD_TYPES

      protected static List<org.opensearch.index.mapper.MappedFieldType> FIELD_TYPES
  • Constructor Details

    • BaseCompositeAggregatorTestCase

      public BaseCompositeAggregatorTestCase()
  • Method Details

    • setUp

      public void setUp() throws Exception
      Overrides:
      setUp in class org.apache.lucene.tests.util.LuceneTestCase
      Throws:
      Exception
    • tearDown

      public void tearDown() throws Exception
      Overrides:
      tearDown in class OpenSearchTestCase
      Throws:
      Exception
    • mapperServiceMock

      protected org.opensearch.index.mapper.MapperService mapperServiceMock()
      Description copied from class: AggregatorTestCase
      sub-tests that need a more complex mock can overwrite this
      Overrides:
      mapperServiceMock in class AggregatorTestCase
    • createDocument

      protected static Map<String, List<Object>> createDocument(Object... fields)
    • testSearchCase

      protected void testSearchCase(List<org.apache.lucene.search.Query> queries, List<Map<String, List<Object>>> dataset, Supplier<org.opensearch.search.aggregations.bucket.composite.CompositeAggregationBuilder> create, Consumer<org.opensearch.search.aggregations.bucket.composite.InternalComposite> verify) throws IOException
      Throws:
      IOException
    • executeTestCase

      protected void executeTestCase(boolean forceMerge, boolean useIndexSort, org.apache.lucene.search.Query query, List<Map<String, List<Object>>> dataset, Supplier<? extends org.opensearch.search.aggregations.AggregationBuilder> create, Consumer<org.opensearch.search.aggregations.bucket.composite.InternalComposite> verify) throws IOException
      Throws:
      IOException
    • addToDocument

      protected void addToDocument(int id, org.apache.lucene.document.Document doc, Map<String, List<Object>> keys)
    • addValueToDocument

      protected boolean addValueToDocument(org.apache.lucene.document.Document doc, String name, Object value)
      Override this function to handle any specific type of value you want to add in the document for doing the composite aggregation. If you have added another Composite Aggregation Type then you must override this function so that your field value can be added in the document correctly.
      Parameters:
      doc - Document
      name - String Field Name
      value - Object Field value
      Returns:
      boolean true or false, based on if value is added or not
    • buildIndexSort

      protected static org.apache.lucene.search.Sort buildIndexSort(List<org.opensearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder<?>> sources, Map<String, org.opensearch.index.mapper.MappedFieldType> fieldTypes)
    • sortFieldFrom

      protected static org.apache.lucene.search.SortField sortFieldFrom(org.opensearch.index.mapper.MappedFieldType type)
    • createIndexSettings

      protected static org.opensearch.index.IndexSettings createIndexSettings(org.apache.lucene.search.Sort sort)
    • createAfterKey

      protected static Map<String,Object> createAfterKey(Object... fields)
    • asLong

      protected static long asLong(String dateTime)