Class MapperServiceTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.index.mapper.MapperServiceTestCase
Direct Known Subclasses:
MapperScriptTestCase, MapperTestCase, MetadataMapperTestCase

public abstract class MapperServiceTestCase extends ESTestCase
Test case that lets you easilly build MapperService based on some mapping. Useful when you don't need to spin up an entire index but do need most of the trapping of the mapping.
  • Field Details

    • SETTINGS

      protected static final org.elasticsearch.common.settings.Settings SETTINGS
    • INCLUDE_DEFAULTS

      protected static final org.elasticsearch.xcontent.ToXContent.Params INCLUDE_DEFAULTS
  • Constructor Details

    • MapperServiceTestCase

      public MapperServiceTestCase()
  • Method Details

    • getPlugins

      protected Collection<? extends org.elasticsearch.plugins.Plugin> getPlugins()
    • getIndexSettings

      protected org.elasticsearch.common.settings.Settings getIndexSettings()
    • getIndexSettingsBuilder

      protected final org.elasticsearch.common.settings.Settings.Builder getIndexSettingsBuilder()
    • createIndexAnalyzers

      protected org.elasticsearch.index.analysis.IndexAnalyzers createIndexAnalyzers(org.elasticsearch.index.IndexSettings indexSettings)
    • createIndexAnalyzers

      protected static org.elasticsearch.index.analysis.IndexAnalyzers createIndexAnalyzers()
    • randomIndexOptions

      protected final String randomIndexOptions()
    • createDocumentMapper

      protected final org.elasticsearch.index.mapper.DocumentMapper createDocumentMapper(org.elasticsearch.xcontent.XContentBuilder mappings) throws IOException
      Throws:
      IOException
    • createDocumentMapper

      protected final org.elasticsearch.index.mapper.DocumentMapper createDocumentMapper(org.elasticsearch.Version version, org.elasticsearch.xcontent.XContentBuilder mappings) throws IOException
      Throws:
      IOException
    • createDocumentMapper

      protected final org.elasticsearch.index.mapper.DocumentMapper createDocumentMapper(String mappings) throws IOException
      Throws:
      IOException
    • createMapperService

      protected org.elasticsearch.index.mapper.MapperService createMapperService(org.elasticsearch.xcontent.XContentBuilder mappings) throws IOException
      Throws:
      IOException
    • createMapperService

      protected org.elasticsearch.index.mapper.MapperService createMapperService(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.xcontent.XContentBuilder mappings) throws IOException
      Throws:
      IOException
    • createMapperService

      protected org.elasticsearch.index.mapper.MapperService createMapperService(BooleanSupplier idFieldEnabled, org.elasticsearch.xcontent.XContentBuilder mappings) throws IOException
      Throws:
      IOException
    • createMapperService

      protected final org.elasticsearch.index.mapper.MapperService createMapperService(String mappings) throws IOException
      Throws:
      IOException
    • createMapperService

      protected final org.elasticsearch.index.mapper.MapperService createMapperService(org.elasticsearch.common.settings.Settings settings, String mappings) throws IOException
      Throws:
      IOException
    • createMapperService

      protected org.elasticsearch.index.mapper.MapperService createMapperService(org.elasticsearch.Version version, org.elasticsearch.xcontent.XContentBuilder mapping) throws IOException
      Throws:
      IOException
    • createMapperService

      protected final org.elasticsearch.index.mapper.MapperService createMapperService(org.elasticsearch.Version version, org.elasticsearch.common.settings.Settings settings, BooleanSupplier idFieldDataEnabled, org.elasticsearch.xcontent.XContentBuilder mapping) throws IOException
      Create a MapperService like we would for an index.
      Throws:
      IOException
    • createMapperService

      protected final org.elasticsearch.index.mapper.MapperService createMapperService(org.elasticsearch.Version version, org.elasticsearch.common.settings.Settings settings, BooleanSupplier idFieldDataEnabled)
    • compileScript

      protected <T> T compileScript(org.elasticsearch.script.Script script, org.elasticsearch.script.ScriptContext<T> context)
      This is the injection point for tests that require mock scripts. Test cases should override this to return the mock script factory of their choice.
    • createIndexSettings

      protected static org.elasticsearch.index.IndexSettings createIndexSettings(org.elasticsearch.Version version, org.elasticsearch.common.settings.Settings settings)
    • withLuceneIndex

      protected final void withLuceneIndex(org.elasticsearch.index.mapper.MapperService mapperService, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.index.RandomIndexWriter,IOException> builder, org.elasticsearch.core.CheckedConsumer<org.apache.lucene.index.IndexReader,IOException> test) throws IOException
      Throws:
      IOException
    • source

      protected final org.elasticsearch.index.mapper.SourceToParse source(org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> build) throws IOException
      Throws:
      IOException
    • source

      protected final org.elasticsearch.index.mapper.SourceToParse source(String id, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> build, @Nullable String routing) throws IOException
      Throws:
      IOException
    • source

      protected final org.elasticsearch.index.mapper.SourceToParse source(String id, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> build, @Nullable String routing, Map<String,String> dynamicTemplates) throws IOException
      Throws:
      IOException
    • source

      protected final org.elasticsearch.index.mapper.SourceToParse source(String index, String id, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> build, @Nullable String routing, Map<String,String> dynamicTemplates) throws IOException
      Throws:
      IOException
    • source

      protected final org.elasticsearch.index.mapper.SourceToParse source(String source)
    • merge

      protected final void merge(org.elasticsearch.index.mapper.MapperService mapperService, org.elasticsearch.xcontent.XContentBuilder mapping) throws IOException
      Merge a new mapping into the one in the provided MapperService.
      Throws:
      IOException
    • merge

      protected final void merge(org.elasticsearch.index.mapper.MapperService mapperService, String mapping) throws IOException
      Merge a new mapping into the one in the provided MapperService.
      Throws:
      IOException
    • merge

      protected final void merge(org.elasticsearch.index.mapper.MapperService mapperService, org.elasticsearch.index.mapper.MapperService.MergeReason reason, String mapping) throws IOException
      Throws:
      IOException
    • merge

      protected final void merge(org.elasticsearch.index.mapper.MapperService mapperService, org.elasticsearch.index.mapper.MapperService.MergeReason reason, org.elasticsearch.xcontent.XContentBuilder mapping) throws IOException
      Merge a new mapping into the one in the provided MapperService with a specific MergeReason
      Throws:
      IOException
    • topMapping

      protected final org.elasticsearch.xcontent.XContentBuilder topMapping(org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> buildFields) throws IOException
      Throws:
      IOException
    • mapping

      protected final org.elasticsearch.xcontent.XContentBuilder mapping(org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> buildFields) throws IOException
      Throws:
      IOException
    • dynamicMapping

      protected final org.elasticsearch.xcontent.XContentBuilder dynamicMapping(org.elasticsearch.index.mapper.Mapping dynamicMapping) throws IOException
      Throws:
      IOException
    • fieldMapping

      protected final org.elasticsearch.xcontent.XContentBuilder fieldMapping(org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> buildField) throws IOException
      Throws:
      IOException
    • runtimeFieldMapping

      protected final org.elasticsearch.xcontent.XContentBuilder runtimeFieldMapping(org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> buildField) throws IOException
      Throws:
      IOException
    • runtimeMapping

      protected final org.elasticsearch.xcontent.XContentBuilder runtimeMapping(org.elasticsearch.core.CheckedConsumer<org.elasticsearch.xcontent.XContentBuilder,IOException> buildFields) throws IOException
      Throws:
      IOException
    • withAggregationContext

      protected final void withAggregationContext(org.elasticsearch.index.mapper.MapperService mapperService, List<org.elasticsearch.index.mapper.SourceToParse> docs, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.search.aggregations.support.AggregationContext,IOException> test) throws IOException
      Throws:
      IOException
    • withAggregationContext

      protected final void withAggregationContext(org.elasticsearch.index.mapper.MapperService mapperService, List<org.elasticsearch.index.mapper.SourceToParse> docs, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.search.aggregations.support.AggregationContext,IOException> test, Supplier<org.elasticsearch.search.lookup.SearchLookup> lookupSupplier) throws IOException
      Throws:
      IOException
    • withAggregationContext

      protected final void withAggregationContext(org.elasticsearch.search.aggregations.support.ValuesSourceRegistry valuesSourceRegistry, org.elasticsearch.index.mapper.MapperService mapperService, List<org.elasticsearch.index.mapper.SourceToParse> docs, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.search.aggregations.support.AggregationContext,IOException> test) throws IOException
      Throws:
      IOException
    • withAggregationContext

      protected final void withAggregationContext(org.elasticsearch.search.aggregations.support.ValuesSourceRegistry valuesSourceRegistry, org.elasticsearch.index.mapper.MapperService mapperService, List<org.elasticsearch.index.mapper.SourceToParse> docs, org.apache.lucene.search.Query query, org.elasticsearch.core.CheckedConsumer<org.elasticsearch.search.aggregations.support.AggregationContext,IOException> test, Supplier<org.elasticsearch.search.lookup.SearchLookup> lookupSupplier) throws IOException
      Throws:
      IOException
    • createSearchExecutionContext

      protected org.elasticsearch.index.query.SearchExecutionContext createSearchExecutionContext(org.elasticsearch.index.mapper.MapperService mapperService)
    • createSearchExecutionContext

      protected org.elasticsearch.index.query.SearchExecutionContext createSearchExecutionContext(org.elasticsearch.index.mapper.MapperService mapperService, org.apache.lucene.search.IndexSearcher searcher)
    • createSearchExecutionContext

      protected org.elasticsearch.index.query.SearchExecutionContext createSearchExecutionContext(org.elasticsearch.index.mapper.MapperService mapperService, org.apache.lucene.search.IndexSearcher searcher, org.elasticsearch.common.settings.Settings settings)
    • fieldDataLookup

      protected BiFunction<org.elasticsearch.index.mapper.MappedFieldType,Supplier<org.elasticsearch.search.lookup.SearchLookup>,org.elasticsearch.index.fielddata.IndexFieldData<?>> fieldDataLookup()