Package org.elasticsearch.index.mapper
Class AbstractScriptFieldTypeTestCase
java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
org.elasticsearch.index.mapper.FieldTypeTestCase
org.elasticsearch.index.mapper.MapperServiceTestCase
org.elasticsearch.index.mapper.AbstractScriptFieldTypeTestCase
- Direct Known Subclasses:
AbstractNonTextScriptFieldTypeTestCase
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.index.mapper.MapperServiceTestCase
MapperServiceTestCase.TestMapperServiceBuilderNested classes/interfaces inherited from class org.elasticsearch.test.ESTestCase
ESTestCase.DeprecationWarning, ESTestCase.EntitledTestPackages, ESTestCase.GeohashGenerator, ESTestCase.TestAnalysis, ESTestCase.WithEntitlementsOnTestCode, ESTestCase.WithoutEntitlementsNested 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
Fields inherited from class org.elasticsearch.index.mapper.MapperServiceTestCase
SETTINGSFields inherited from class org.elasticsearch.index.mapper.FieldTypeTestCase
MOCK_CONTEXT, MOCK_CONTEXT_DISALLOW_EXPENSIVEFields inherited from class org.elasticsearch.test.ESTestCase
checkIndexFailures, DEFAULT_TEST_WORKER_ID, failureAndSuccessEvents, FIPS_SYSPROP, JAVA_TIMEZONE_IDS, JAVA_ZONE_IDS, logger, MIN_PRIVATE_PORT, SAFE_AWAIT_TIMEOUT, TEST_ENTITLEMENTS, TEST_REQUEST_TIMEOUT, TEST_WORKER_SYS_PROPERTY, TEST_WORKER_VM_ID, UNSIGNED_LONG_MAXFields 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 static <T extends org.apache.lucene.index.IndexableField>
voidaddDocument(org.apache.lucene.tests.index.RandomIndexWriter iw, Iterable<T> indexableFields) Add the provided document to the provided writer, and randomly flush.blockLoaderReadValuesFromColumnAtATimeReader(org.apache.lucene.index.DirectoryReader reader, MappedFieldType fieldType, int offset) blockLoaderReadValuesFromRowStrideReader(org.apache.lucene.index.DirectoryReader reader, MappedFieldType fieldType) protected abstract AbstractScriptFieldType<?> protected final voidcheckExpensiveQuery(BiConsumer<MappedFieldType, SearchExecutionContext> queryBuilder) protected final voidcheckLoop(BiConsumer<MappedFieldType, SearchExecutionContext> queryBuilder) protected <T> TcompileScript(Script script, ScriptContext<T> context) This is the injection point for tests that require mock scripts.protected abstract ScriptFactoryprotected abstract MappedFieldTypeprotected final voidminimalMapping(org.elasticsearch.xcontent.XContentBuilder b) protected static SearchExecutionContextprotected static SearchExecutionContextmockContext(boolean allowExpensiveQueries) protected static SearchExecutionContextmockContext(boolean allowExpensiveQueries, MappedFieldType mappedFieldType) protected static SearchExecutionContextmockContext(boolean allowExpensiveQueries, MappedFieldType mappedFieldType, SourceProvider sourceProvider) protected static FieldDataContextprotected abstract ScriptFactoryprotected abstract org.apache.lucene.search.Queryprotected abstract org.apache.lucene.search.Queryprotected abstract org.apache.lucene.search.Queryprotected final StringreadSource(org.apache.lucene.index.IndexReader reader, int docId) protected abstract MappedFieldTypeprotected booleanprotected booleanfinal voidvoidabstract voidabstract voidvoidvoidvoidvoidvoidfinal voidtestMeta()final voidfinal voidvoidvoidfinal voidCheck that running query on a runtime field script that fails has the expected behaviour according to its configurationfinal voidvoidvoidabstract voidvoidvoidvoidabstract voidtestSort()voidvoidabstract voidvoidvoidabstract voidvoidvoidabstract voidprotected abstract StringtypeName()Methods inherited from class org.elasticsearch.index.mapper.MapperServiceTestCase
createDocumentMapper, createDocumentMapper, createDocumentMapper, createDocumentMapper, createIndexAnalyzers, createIndexAnalyzers, createIndexSettings, createLogsModeDocumentMapper, createMapperService, createMapperService, createMapperService, createMapperService, createMapperService, createMapperService, createMapperService, createMapperService, createMapperService, createSearchExecutionContext, createSearchExecutionContext, createSearchExecutionContext, createSytheticSourceMapperService, createTestMapperMetrics, createTimeSeriesModeDocumentMapper, dynamicMapping, fieldDataLookup, fieldDataLookup, fieldMapping, getIndexSettings, getIndexSettingsBuilder, getPlugins, getVersion, indexWriterForSyntheticSource, mapping, mappingNoSubobjects, mappingWithSubobjects, merge, merge, merge, merge, randomIndexOptions, runtimeFieldMapping, runtimeMapping, source, source, source, source, syntheticSource, syntheticSource, syntheticSource, syntheticSource, topMapping, validateRoundTripReader, withAggregationContext, withAggregationContext, withAggregationContext, withAggregationContext, withLuceneIndex, withMapping, wrapInMockESDirectoryReaderMethods inherited from class org.elasticsearch.index.mapper.FieldTypeTestCase
fetchSourceValue, fetchSourceValue, fetchSourceValues, fetchStoredValue, getFieldInfoWithName, randomMockContextMethods inherited from class org.elasticsearch.test.ESTestCase
after, afterIfFailed, afterIfSuccessful, allBreakersMemoryReleased, asInstanceOf, assertArrayEquals, assertBusy, assertBusy, assertCriticalWarnings, assertEquals, assertLeakDetected, assertSettingDeprecationsAndWarnings, assertThat, assertThat, assertWarnings, assertWarnings, before, between, buildEnvSettings, buildNewFakeTransportAddress, captureLoggingLevel, checkStaticState, compatibleMediaType, copyInstance, copyNamedWriteable, copyNamedWriteable, copyWriteable, copyWriteable, createDefaultIndexAnalyzers, createParser, createParser, createParser, createParser, createParser, createParser, createParserWithCompatibilityFor, createTestAnalysis, createTestAnalysis, createTestAnalysis, createThreadPool, enableBigArraysReleasedCheck, enableWarningsCheck, ensureAllContextsReleased, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureNoWarnings, ensureSupportedLocale, expectThrows, expectThrows, expectThrows, expectThrows, fail, fail, filteredWarnings, flushThreadPoolExecutor, frequently, generateRandomStringArray, generateRandomStringArray, getDataPath, getPortRange, getResourceDataPath, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, getWorkerBasePort, indexSettings, indexSettings, indexSettings, inFipsJvm, initTestSeed, isTurkishLocale, iterations, maybeSet, mockScript, newEnvironment, newEnvironment, newLimitedBreaker, newNodeEnvironment, newNodeEnvironment, newSearcher, newSearcher, newSearcher, newSearcher, parserConfig, projectStateFromProject, projectStateWithEmptyProject, randomAlphanumericOfLength, randomAlphaOfLength, randomAlphaOfLengthBetween, randomAlphaOfLengthOrNull, randomArray, randomArray, randomBigInteger, randomBoolean, randomByte, randomByteArrayOfLength, randomByteBetween, randomBytesBetween, randomByteSizeValue, randomBytesReference, randomCompatibleMediaType, randomDateFormatterPattern, randomDouble, randomDoubleBetween, randomDoubles, randomDoubles, randomExecutor, randomFloat, randomFloatBetween, randomFloatOrNull, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomIdentifier, randomInstantBetween, randomInt, randomInt, randomIntBetween, randomIntOrNull, randomInts, randomInts, randomIp, randomList, randomList, randomLong, randomLongBetween, randomLongOrNull, randomLongs, randomLongs, randomMap, randomMillisUpToYear9999, randomNegativeInt, randomNegativeLong, randomNonEmptySubsetOf, randomNonNegativeByte, randomNonNegativeInt, randomNonNegativeIntOrNull, randomNonNegativeLong, randomNonNegativeLongOrNull, randomOptionalBoolean, randomPositiveTimeValue, randomProjectIdOrDefault, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomReleasableBytesReference, randomSecretKey, randomSecureStringOfLength, randomSet, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomUniqueProjectId, randomUnsignedLongBetween, randomUUID, randomValueOtherThan, randomValueOtherThanMany, randomVendorType, randomZone, removeHeaderWarningAppender, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, restoreLoggingLevel, runInParallel, safeAcquire, safeAcquire, safeAwait, safeAwait, safeAwait, safeAwait, safeAwait, safeAwait, safeAwaitAndUnwrapFailure, safeAwaitFailure, safeAwaitFailure, safeAwaitFailure, safeAwaitFailure, safeExecute, safeGet, safeGet, safeSleep, safeSleep, scaledRandomIntBetween, secureRandom, secureRandom, secureRandomFips, secureRandomFips, secureRandomNonFips, secureRandomNonFips, setContentType, setFileSystem, setHeaderWarningAppender, settings, shuffledList, shuffleMap, shuffleXContent, shuffleXContent, skipTestWaitingForLuceneFix, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, startInParallel, terminate, terminate, tmpPaths, toShuffledXContent, toShuffledXContent, waitUntil, waitUntil, 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, 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, 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, tearDown, 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
-
Constructor Details
-
AbstractScriptFieldTypeTestCase
public AbstractScriptFieldTypeTestCase()
-
-
Method Details
-
simpleMappedFieldType
-
loopFieldType
-
typeName
-
addDocument
protected static <T extends org.apache.lucene.index.IndexableField> void addDocument(org.apache.lucene.tests.index.RandomIndexWriter iw, Iterable<T> indexableFields) throws IOException Add the provided document to the provided writer, and randomly flush. This is useful for situations where there are not enough documents indexed to trigger random flush and commit performed byRandomIndexWriter. Flushing is important to obtain multiple slices and inter-segment concurrency.- Throws:
IOException
-
testMinimalSerializesToItself
- Throws:
IOException
-
testMeta
- Throws:
IOException
-
testMinimalMappingToMaximal
- Throws:
IOException
-
testCopyToIsNotSupported
- Throws:
IOException
-
testMultiFieldsIsNotSupported
- Throws:
IOException
-
testStoredScriptsAreNotSupported
- Throws:
Exception
-
testFieldCaps
- Throws:
Exception
-
testOnScriptError
Check that running query on a runtime field script that fails has the expected behaviour according to its configuration- Throws:
IOException
-
testOnScriptErrorFail
- Throws:
IOException
-
testFieldHasValue
public void testFieldHasValue()- Overrides:
testFieldHasValuein classFieldTypeTestCase
-
testFieldHasValueWithEmptyFieldInfos
public void testFieldHasValueWithEmptyFieldInfos()- Overrides:
testFieldHasValueWithEmptyFieldInfosin classFieldTypeTestCase
-
getMappedFieldType
- Overrides:
getMappedFieldTypein classFieldTypeTestCase
-
build
protected abstract AbstractScriptFieldType<?> build(String error, Map<String, Object> emptyMap, OnScriptError onScriptError) -
testDocValues
- Throws:
IOException
-
testSort
- Throws:
IOException
-
testUsedInScript
- Throws:
IOException
-
testExistsQuery
- Throws:
IOException
-
testRangeQuery
- Throws:
IOException
-
randomRangeQuery
protected abstract org.apache.lucene.search.Query randomRangeQuery(MappedFieldType ft, SearchExecutionContext ctx) -
testTermQuery
- Throws:
IOException
-
randomTermQuery
protected abstract org.apache.lucene.search.Query randomTermQuery(MappedFieldType ft, SearchExecutionContext ctx) -
testTermsQuery
- Throws:
IOException
-
randomTermsQuery
protected abstract org.apache.lucene.search.Query randomTermsQuery(MappedFieldType ft, SearchExecutionContext ctx) -
mockContext
-
mockFielddataContext
-
mockContext
-
supportsTermQueries
protected boolean supportsTermQueries() -
supportsRangeQueries
protected boolean supportsRangeQueries() -
mockContext
protected static SearchExecutionContext mockContext(boolean allowExpensiveQueries, MappedFieldType mappedFieldType) -
mockContext
protected static SearchExecutionContext mockContext(boolean allowExpensiveQueries, MappedFieldType mappedFieldType, SourceProvider sourceProvider) -
testExistsQueryIsExpensive
public void testExistsQueryIsExpensive() -
testExistsQueryInLoop
public void testExistsQueryInLoop() -
testRangeQueryWithShapeRelationIsError
public void testRangeQueryWithShapeRelationIsError() -
testRangeQueryIsExpensive
public void testRangeQueryIsExpensive() -
testRangeQueryInLoop
public void testRangeQueryInLoop() -
testTermQueryIsExpensive
public void testTermQueryIsExpensive() -
testTermQueryInLoop
public void testTermQueryInLoop() -
testTermsQueryIsExpensive
public void testTermsQueryIsExpensive() -
testTermsQueryInLoop
public void testTermsQueryInLoop() -
testPhraseQueryIsError
public void testPhraseQueryIsError() -
testPhrasePrefixQueryIsError
public void testPhrasePrefixQueryIsError() -
testMultiPhraseQueryIsError
public void testMultiPhraseQueryIsError() -
testSpanPrefixQueryIsError
public void testSpanPrefixQueryIsError() -
testCacheable
- Throws:
IOException
-
blockLoaderReadValuesFromColumnAtATimeReader
protected final List<Object> blockLoaderReadValuesFromColumnAtATimeReader(org.apache.lucene.index.DirectoryReader reader, MappedFieldType fieldType, int offset) throws IOException - Throws:
IOException
-
blockLoaderReadValuesFromRowStrideReader
protected final List<Object> blockLoaderReadValuesFromRowStrideReader(org.apache.lucene.index.DirectoryReader reader, MappedFieldType fieldType) throws IOException - Throws:
IOException
-
readSource
protected final String readSource(org.apache.lucene.index.IndexReader reader, int docId) throws IOException - Throws:
IOException
-
checkExpensiveQuery
protected final void checkExpensiveQuery(BiConsumer<MappedFieldType, SearchExecutionContext> queryBuilder) -
checkLoop
-
minimalMapping
protected final void minimalMapping(org.elasticsearch.xcontent.XContentBuilder b) throws IOException - Throws:
IOException
-
parseFromSource
-
dummyScript
-
compileScript
Description copied from class:MapperServiceTestCaseThis is the injection point for tests that require mock scripts. Test cases should override this to return the mock script factory of their choice.- Overrides:
compileScriptin classMapperServiceTestCase
-