|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.CheckHits
public class CheckHits
Utility class for asserting expected hits in tests.
Nested Class Summary | |
---|---|
static class |
CheckHits.ExplanationAsserter
Asserts that the score explanation for every document matching a query corresponds with the true score. |
static class |
CheckHits.ExplanationAssertingSearcher
an IndexSearcher that implicitly checks hte explanation of every match whenever it executes a search. |
static class |
CheckHits.SetCollector
Just collects document ids into a set. |
Field Summary | |
---|---|
static float |
EXPLAIN_SCORE_TOLERANCE_DELTA
Some explains methods calculate their values though a slightly different order of operations from the actual scoring method ... |
Constructor Summary | |
---|---|
CheckHits()
|
Method Summary | |
---|---|
static void |
checkDocIds(String mes,
int[] results,
ScoreDoc[] hits)
Tests that a Hits has an expected order of documents |
static void |
checkEqual(Query query,
ScoreDoc[] hits1,
ScoreDoc[] hits2)
|
static void |
checkExplanations(Query query,
String defaultFieldName,
Searcher searcher)
Asserts that the explanation value for every document matching a query corresponds with the true score. |
static void |
checkExplanations(Query query,
String defaultFieldName,
Searcher searcher,
boolean deep)
Asserts that the explanation value for every document matching a query corresponds with the true score. |
static void |
checkHitCollector(Random random,
Query query,
String defaultFieldName,
Searcher searcher,
int[] results)
Tests that a query matches the an expected set of documents using a HitCollector. |
static void |
checkHits(Random random,
Query query,
String defaultFieldName,
Searcher searcher,
int[] results)
Tests that a query matches the an expected set of documents using Hits. |
static void |
checkHitsQuery(Query query,
ScoreDoc[] hits1,
ScoreDoc[] hits2,
int[] results)
Tests that two queries have an expected order of documents, and that the two queries have the same score values. |
static void |
checkNoMatchExplanations(Query q,
String defaultFieldName,
Searcher searcher,
int[] results)
Tests that all documents up to maxDoc which are *not* in the expected result set, have an explanation which indicates that the document does not match |
static String |
hits2str(ScoreDoc[] hits1,
ScoreDoc[] hits2,
int start,
int end)
|
static String |
topdocsString(TopDocs docs,
int start,
int end)
|
static void |
verifyExplanation(String q,
int doc,
float score,
boolean deep,
Explanation expl)
Assert that an explanation has the expected score, and optionally that its sub-details max/sum/factor match to that score. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static float EXPLAIN_SCORE_TOLERANCE_DELTA
Constructor Detail |
---|
public CheckHits()
Method Detail |
---|
public static void checkNoMatchExplanations(Query q, String defaultFieldName, Searcher searcher, int[] results) throws IOException
IOException
public static void checkHitCollector(Random random, Query query, String defaultFieldName, Searcher searcher, int[] results) throws IOException
Note that when using the HitCollector API, documents will be collected if they "match" regardless of what their score is.
query
- the query to testsearcher
- the searcher to test the query againstdefaultFieldName
- used for displaying the query in assertion messagesresults
- a list of documentIds that must match the query
IOException
checkHits(java.util.Random, org.apache.lucene.search.Query, java.lang.String, org.apache.lucene.search.Searcher, int[])
public static void checkHits(Random random, Query query, String defaultFieldName, Searcher searcher, int[] results) throws IOException
Note that when using the Hits API, documents will only be returned if they have a positive normalized score.
query
- the query to testsearcher
- the searcher to test the query againstdefaultFieldName
- used for displaing the query in assertion messagesresults
- a list of documentIds that must match the query
IOException
checkHitCollector(java.util.Random, org.apache.lucene.search.Query, java.lang.String, org.apache.lucene.search.Searcher, int[])
public static void checkDocIds(String mes, int[] results, ScoreDoc[] hits) throws IOException
IOException
public static void checkHitsQuery(Query query, ScoreDoc[] hits1, ScoreDoc[] hits2, int[] results) throws IOException
IOException
public static void checkEqual(Query query, ScoreDoc[] hits1, ScoreDoc[] hits2) throws IOException
IOException
public static String hits2str(ScoreDoc[] hits1, ScoreDoc[] hits2, int start, int end) throws IOException
IOException
public static String topdocsString(TopDocs docs, int start, int end)
public static void checkExplanations(Query query, String defaultFieldName, Searcher searcher) throws IOException
query
- the query to testsearcher
- the searcher to test the query againstdefaultFieldName
- used for displaing the query in assertion messages
IOException
CheckHits.ExplanationAsserter
,
for a
"deep" testing of the explanation details.
public static void checkExplanations(Query query, String defaultFieldName, Searcher searcher, boolean deep) throws IOException
query
- the query to testsearcher
- the searcher to test the query againstdefaultFieldName
- used for displaing the query in assertion messagesdeep
- indicates whether a deep comparison of sub-Explanation details should be executed
IOException
CheckHits.ExplanationAsserter
public static void verifyExplanation(String q, int doc, float score, boolean deep, Explanation expl)
q
- String representation of the query for assertion messagesdoc
- Document ID for assertion messagesscore
- Real score value of doc with query qdeep
- indicates whether a deep comparison of sub-Explanation details should be executedexpl
- The Explanation to match against score
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |