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.common.xcontent.ToXContent.Params INCLUDE_DEFAULTS
  • Constructor Details

    • MapperServiceTestCase

      public MapperServiceTestCase()
  • Method Details

    • getPlugins

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

      protected org.elasticsearch.common.settings.Settings getIndexSettings()
    • 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 java.lang.String randomIndexOptions()
    • createDocumentMapper

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

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

      protected final org.elasticsearch.index.mapper.DocumentMapper createDocumentMapper​(org.elasticsearch.Version version, java.lang.String mappings) throws java.io.IOException
      Throws:
      java.io.IOException
    • createDocumentMapper

      protected final org.elasticsearch.index.mapper.DocumentMapper createDocumentMapper​(java.lang.String type, java.lang.String mappings) throws java.io.IOException
      Throws:
      java.io.IOException
    • createMapperService

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

      protected final org.elasticsearch.index.mapper.MapperService createMapperService​(java.lang.String type, java.lang.String mappings) throws java.io.IOException
      Throws:
      java.io.IOException
    • createMapperService

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

      protected org.elasticsearch.index.mapper.MapperService createMapperService​(java.util.function.BooleanSupplier idFieldEnabled, org.elasticsearch.common.xcontent.XContentBuilder mappings) throws java.io.IOException
      Throws:
      java.io.IOException
    • createMapperService

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

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

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

      protected <T> T compileScript​(org.elasticsearch.script.Script script, org.elasticsearch.script.ScriptContext<T> context)
    • createMapperService

      protected final org.elasticsearch.index.mapper.MapperService createMapperService​(org.elasticsearch.Version version, org.elasticsearch.common.settings.Settings settings, java.util.function.BooleanSupplier idFieldDataEnabled)
    • 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.common.CheckedConsumer<org.apache.lucene.index.RandomIndexWriter,​java.io.IOException> builder, org.elasticsearch.common.CheckedConsumer<org.apache.lucene.index.IndexReader,​java.io.IOException> test) throws java.io.IOException
      Throws:
      java.io.IOException
    • source

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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