Index: BooleanQuery.java =================================================================== --- BooleanQuery.java (revision 154651) +++ BooleanQuery.java (working copy) @@ -200,6 +200,10 @@ else if (c.isRequired()) return null; } + + if (allowSkipTo14) { + result.allowSkipTo(); + } return result; } @@ -270,19 +274,31 @@ return result; } + + public Explanation explain(IndexReader reader, int doc) throws IOException { + return scorer(reader).explain(doc); + } } /** Indicates whether to use good old 1.4 BooleanScorer. */ private static boolean useScorer14 = false; + /** Indicates whether the 1.4 BooleanScorer should allow skipTo() */ + private static boolean allowSkipTo14 = false; - public static void setUseScorer14(boolean use14) { + public static void setUseScorer14(boolean use14, boolean allowSkipTo) { useScorer14 = use14; + allowSkipTo14 = allowSkipTo; } public static boolean getUseScorer14() { return useScorer14; } + public static boolean getAllowSkipTo14() { + return allowSkipTo14; + } + + protected Weight createWeight(Searcher searcher) { return getUseScorer14() ? (Weight) new BooleanWeight(searcher) : (Weight) new BooleanWeight2(searcher);