public static CheckNoMatchExplanations ( |
||
q | ||
defaultFieldName | string | |
searcher | ||
results | int | |
return | void |
public static void CheckNoMatchExplanations(Query q, string defaultFieldName, IndexSearcher searcher, int[] results)
{
string d = q.ToString(defaultFieldName);
SortedSet<int?> ignore = new SortedSet<int?>();
for (int i = 0; i < results.Length; i++)
{
ignore.Add(Convert.ToInt32(results[i]));
}
int maxDoc = searcher.IndexReader.MaxDoc;
for (int doc = 0; doc < maxDoc; doc++)
{
if (ignore.Contains(Convert.ToInt32(doc)))
{
continue;
}
Explanation exp = searcher.Explain(q, doc);
Assert.IsNotNull(exp, "Explanation of [[" + d + "]] for #" + doc + " is null");
Assert.IsFalse(exp.IsMatch, "Explanation of [[" + d + "]] for #" + doc + " doesn't indicate non-match: " + exp.ToString());
}
}
/// <summary> Overrides superclass to ignore matches and focus on non-matches /// /// </summary> /// <seealso cref="CheckHits.checkNoMatchExplanations"> /// </seealso> public override void Qtest(Query q, int[] expDocNrs) { CheckHits.CheckNoMatchExplanations(q, FIELD, searcher, expDocNrs); }