Package org.apache.lucene.tests.search
Class MatchesTestBase
java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.apache.lucene.tests.search.MatchesTestBase
Base class for tests checking the
Weight.matches(LeafReaderContext, int) implementations-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classEncapsulates a term position, start and end offsetNested classes/interfaces inherited from class org.apache.lucene.tests.util.LuceneTestCase
LuceneTestCase.AwaitsFix, LuceneTestCase.Concurrency, LuceneTestCase.Monster, LuceneTestCase.Nightly, LuceneTestCase.SuppressCodecs, LuceneTestCase.SuppressFileSystems, LuceneTestCase.SuppressFsync, LuceneTestCase.SuppressReproduceLine, LuceneTestCase.SuppressSysoutChecks, LuceneTestCase.SuppressTempFileChecks, LuceneTestCase.ThrowingConsumer<T>, LuceneTestCase.ThrowingRunnable, LuceneTestCase.Weekly -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Directoryprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected IndexReaderprotected IndexSearcherFields 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 voidassertIsLeafMatch(Query q, String field) Assert that query matches from a field are all leaf matches and do not contain sub matchesprotected voidcheckFieldMatches(MatchesIterator it, int[] expected) Given a MatchesIterator, check that it has the expected set of start and end positionsprotected voidcheckLabelCount(Query q, String field, int[] expected) For a given query and field, check that the expected numbers of query labels were foundprotected voidcheckMatches(Query q, String field, int[][] expected) For a given query and field, check that expected matches are retrievedprotected voidcheckNoPositionsMatches(Query q, String field, boolean[] expected) Given a query and field, check that matches are returned from expected documents and that they return -1 for start and end positionsprotected voidcheckSubMatches(Query q, String[][] expectedNames) Given a query, check that matches contain the expected NamedQuery wrapper namesprotected voidcheckTermMatches(Query q, String field, MatchesTestBase.TermMatch[][][] expected) For a query and field, check that each document's submatches conform to an expected TermMatchprotected abstract String[]voidsetUp()For subclasses to override.voidtearDown()For subclasses to override.Methods 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, getDataPath, 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, newSearcher, newSearcher, newSearcher, newSearcher, newSnapshotIndexWriterConfig, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, randomVectorFormat, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setUpExecutorService, shutdownExecutorService, slowFileExists, 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, assertThat, assertThat, assertThrows, assertThrows, assertTrue, assertTrue, fail, fail
-
Field Details
-
searcher
-
directory
-
reader
-
FIELD_WITH_OFFSETS
- See Also:
-
FIELD_NO_OFFSETS
- See Also:
-
FIELD_DOCS_ONLY
- See Also:
-
FIELD_FREQS
- See Also:
-
FIELD_POINT
- See Also:
-
-
Constructor Details
-
MatchesTestBase
public MatchesTestBase()
-
-
Method Details
-
getDocuments
- Returns:
- an array of documents to be indexed
-
tearDown
Description copied from class:LuceneTestCaseFor subclasses to override. Overrides must callsuper.tearDown().- Overrides:
tearDownin classLuceneTestCase- Throws:
Exception
-
setUp
Description copied from class:LuceneTestCaseFor subclasses to override. Overrides must callsuper.setUp().- Overrides:
setUpin classLuceneTestCase- Throws:
Exception
-
checkMatches
For a given query and field, check that expected matches are retrieved- Parameters:
q- the queryfield- the field to pull matches fromexpected- an array of arrays of ints; for each entry, the first int is the expected docid, followed by pairs of start and end positions- Throws:
IOException
-
checkLabelCount
For a given query and field, check that the expected numbers of query labels were found- Parameters:
q- the queryfield- the field to pull matches fromexpected- an array of expected label counts, one entry per document- Throws:
IOException
-
checkFieldMatches
Given a MatchesIterator, check that it has the expected set of start and end positions- Parameters:
it- an iteratorexpected- an array of expected start and end pairs and start and end offsets; the entry at position 0 is ignored- Throws:
IOException
-
checkNoPositionsMatches
protected void checkNoPositionsMatches(Query q, String field, boolean[] expected) throws IOException Given a query and field, check that matches are returned from expected documents and that they return -1 for start and end positions- Parameters:
q- the queryfield- the field to pull matches fromexpected- an array of booleans indicating if matches are expected from each document- Throws:
IOException
-
checkSubMatches
Given a query, check that matches contain the expected NamedQuery wrapper names- Parameters:
q- the queryexpectedNames- an array of arrays of Strings; for each document, an array of expected query names that match- Throws:
IOException
-
assertIsLeafMatch
Assert that query matches from a field are all leaf matches and do not contain sub matches- Parameters:
q- the queryfield- the field- Throws:
IOException
-
checkTermMatches
protected void checkTermMatches(Query q, String field, MatchesTestBase.TermMatch[][][] expected) throws IOException For a query and field, check that each document's submatches conform to an expected TermMatch- Parameters:
q- the queryfield- the field to pull matches forexpected- an array per doc of arrays per match of an array of expected submatches- Throws:
IOException
-