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
Modifier and TypeClassDescriptionprotected static class
Encapsulates a term position, start and end offsetNested classes/interfaces inherited from class org.apache.lucene.tests.util.LuceneTestCase
LuceneTestCase.AwaitsFix, LuceneTestCase.BadApple, 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
Modifier and TypeFieldDescriptionprotected Directory
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected IndexReader
protected IndexSearcher
Fields 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_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_BADAPPLES, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
assertIsLeafMatch
(Query q, String field) Assert that query matches from a field are all leaf matches and do not contain sub matchesprotected void
checkFieldMatches
(MatchesIterator it, int[] expected) Given a MatchesIterator, check that it has the expected set of start and end positionsprotected void
checkLabelCount
(Query q, String field, int[] expected) For a given query and field, check that the expected numbers of query labels were foundprotected void
checkMatches
(Query q, String field, int[][] expected) For a given query and field, check that expected matches are retrievedprotected void
checkNoPositionsMatches
(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 void
checkSubMatches
(Query q, String[][] expectedNames) Given a query, check that matches contain the expected NamedQuery wrapper namesprotected void
checkTermMatches
(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[]
void
setUp()
For subclasses to override.void
tearDown()
For subclasses to override.Methods inherited from class org.apache.lucene.tests.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, assumeWorkingMMapOnWindows, 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, hasWorkingMMapOnWindows, 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, newSnapshotIndexWriterConfig, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setUpExecutorService, shutdownExecutorService, slowFileExists, usually, usually, wrapReader
Methods 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:LuceneTestCase
For subclasses to override. Overrides must callsuper.tearDown()
.- Overrides:
tearDown
in classLuceneTestCase
- Throws:
Exception
-
setUp
Description copied from class:LuceneTestCase
For subclasses to override. Overrides must callsuper.setUp()
.- Overrides:
setUp
in 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
-