|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FilteredQuery | Line # 41 | 61 | 30 | 82.2% |
0.8217822
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (21) | |||
| Result | |||
|
0.7029703
|
org.apache.lucene.search.TestSimpleExplanations.testFQ7
org.apache.lucene.search.TestSimpleExplanations.testFQ7
|
1 PASS | |
|
0.7029703
|
org.apache.lucene.search.TestSimpleExplanations.testFQ3
org.apache.lucene.search.TestSimpleExplanations.testFQ3
|
1 PASS | |
|
0.7029703
|
org.apache.lucene.search.TestSimpleExplanations.testFQ6
org.apache.lucene.search.TestSimpleExplanations.testFQ6
|
1 PASS | |
|
0.7029703
|
org.apache.lucene.search.TestSimpleExplanations.testFQ4
org.apache.lucene.search.TestSimpleExplanations.testFQ4
|
1 PASS | |
|
0.6831683
|
org.apache.lucene.search.TestComplexExplanations.testFQ5
org.apache.lucene.search.TestComplexExplanations.testFQ5
|
1 PASS | |
|
0.6831683
|
org.apache.lucene.search.TestSimpleExplanations.testFQ2
org.apache.lucene.search.TestSimpleExplanations.testFQ2
|
1 PASS | |
|
0.63366336
|
org.apache.lucene.search.TestSimpleExplanations.testFQ1
org.apache.lucene.search.TestSimpleExplanations.testFQ1
|
1 PASS | |
|
0.57425743
|
org.apache.lucene.search.TestFilteredQuery.testFilteredQuery
org.apache.lucene.search.TestFilteredQuery.testFilteredQuery
|
1 PASS | |
|
0.57425743
|
org.apache.lucene.search.TestFilteredQuery.testRangeQuery
org.apache.lucene.search.TestFilteredQuery.testRangeQuery
|
1 PASS | |
|
0.55445546
|
org.apache.lucene.search.TestFilteredQuery.testBoolean
org.apache.lucene.search.TestFilteredQuery.testBoolean
|
1 PASS | |
|
0.5445545
|
org.apache.lucene.search.TestComplexExplanations.test1
org.apache.lucene.search.TestComplexExplanations.test1
|
1 PASS | |
|
0.5445545
|
org.apache.lucene.search.TestComplexExplanations.test2
org.apache.lucene.search.TestComplexExplanations.test2
|
1 PASS | |
|
0.34653464
|
org.apache.lucene.search.TestSimpleExplanations.testFQ3
org.apache.lucene.search.TestSimpleExplanations.testFQ3
|
1 PASS | |
|
0.34653464
|
org.apache.lucene.search.TestComplexExplanations.testFQ5
org.apache.lucene.search.TestComplexExplanations.testFQ5
|
1 PASS | |
|
0.34653464
|
org.apache.lucene.search.TestSimpleExplanations.testFQ4
org.apache.lucene.search.TestSimpleExplanations.testFQ4
|
1 PASS | |
|
0.34653464
|
org.apache.lucene.search.TestSimpleExplanations.testFQ6
org.apache.lucene.search.TestSimpleExplanations.testFQ6
|
1 PASS | |
|
0.34653464
|
org.apache.lucene.search.TestSimpleExplanations.testFQ7
org.apache.lucene.search.TestSimpleExplanations.testFQ7
|
1 PASS | |
|
0.32673267
|
org.apache.lucene.search.TestSimpleExplanations.testFQ2
org.apache.lucene.search.TestSimpleExplanations.testFQ2
|
1 PASS | |
|
0.3069307
|
org.apache.lucene.search.TestComplexExplanations.test2
org.apache.lucene.search.TestComplexExplanations.test2
|
1 PASS | |
|
0.3069307
|
org.apache.lucene.search.TestComplexExplanations.test1
org.apache.lucene.search.TestComplexExplanations.test1
|
1 PASS | |
|
0.10891089
|
org.apache.lucene.search.TestSimpleExplanations.testFQ1
org.apache.lucene.search.TestSimpleExplanations.testFQ1
|
1 PASS | |
| 1 | package org.apache.lucene.search; | |
| 2 | ||
| 3 | /** | |
| 4 | * Copyright 2004,2006 The Apache Software Foundation | |
| 5 | * | |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 7 | * you may not use this file except in compliance with the License. | |
| 8 | * You may obtain a copy of the License at | |
| 9 | * | |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | * | |
| 12 | * Unless required by applicable law or agreed to in writing, software | |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 15 | * See the License for the specific language governing permissions and | |
| 16 | * limitations under the License. | |
| 17 | */ | |
| 18 | ||
| 19 | import org.apache.lucene.index.IndexReader; | |
| 20 | import org.apache.lucene.util.ToStringUtils; | |
| 21 | ||
| 22 | import java.io.IOException; | |
| 23 | import java.util.BitSet; | |
| 24 | import java.util.Set; | |
| 25 | ||
| 26 | ||
| 27 | /** | |
| 28 | * A query that applies a filter to the results of another query. | |
| 29 | * | |
| 30 | * <p>Note: the bits are retrieved from the filter each time this | |
| 31 | * query is used in a search - use a CachingWrapperFilter to avoid | |
| 32 | * regenerating the bits every time. | |
| 33 | * | |
| 34 | * <p>Created: Apr 20, 2004 8:58:29 AM | |
| 35 | * | |
| 36 | * @author Tim Jones | |
| 37 | * @since 1.4 | |
| 38 | * @version $Id: FilteredQuery.java 467559 2006-10-25 04:24:10Z yonik $ | |
| 39 | * @see CachingWrapperFilter | |
| 40 | */ | |
| 41 | public class FilteredQuery | |
| 42 | extends Query { | |
| 43 | ||
| 44 | Query query; | |
| 45 | Filter filter; | |
| 46 | ||
| 47 | /** | |
| 48 | * Constructs a new query which applies a filter to the results of the original query. | |
| 49 | * Filter.bits() will be called every time this query is used in a search. | |
| 50 | * @param query Query to be filtered, cannot be <code>null</code>. | |
| 51 | * @param filter Filter to apply to query results, cannot be <code>null</code>. | |
| 52 | */ | |
| 53 | 25 |
public FilteredQuery (Query query, Filter filter) { |
| 54 | 25 | this.query = query; |
| 55 | 25 | this.filter = filter; |
| 56 | } | |
| 57 | ||
| 58 | ||
| 59 | ||
| 60 | /** | |
| 61 | * Returns a Weight that applies the filter to the enclosed query's Weight. | |
| 62 | * This is accomplished by overriding the Scorer returned by the Weight. | |
| 63 | */ | |
| 64 | 100 |
protected Weight createWeight (final Searcher searcher) throws IOException { |
| 65 | 100 | final Weight weight = query.createWeight (searcher); |
| 66 | 100 | final Similarity similarity = query.getSimilarity(searcher); |
| 67 | 100 | return new Weight() { |
| 68 | ||
| 69 | // pass these methods through to enclosed query's weight | |
| 70 | 0 |
public float getValue() { return weight.getValue(); } |
| 71 | 100 |
public float sumOfSquaredWeights() throws IOException { return weight.sumOfSquaredWeights(); } |
| 72 | 100 |
public void normalize (float v) { weight.normalize(v); } |
| 73 | 40 |
public Explanation explain (IndexReader ir, int i) throws IOException { |
| 74 | 40 | Explanation inner = weight.explain (ir, i); |
| 75 | 40 | Filter f = FilteredQuery.this.filter; |
| 76 | 40 | BitSet matches = f.bits(ir); |
| 77 | 40 | if (matches.get(i)) |
| 78 | 23 | return inner; |
| 79 | 17 | Explanation result = new Explanation |
| 80 | (0.0f, "failure to match filter: " + f.toString()); | |
| 81 | 17 | result.addDetail(inner); |
| 82 | 17 | return result; |
| 83 | } | |
| 84 | ||
| 85 | // return this query | |
| 86 | 0 |
public Query getQuery() { return FilteredQuery.this; } |
| 87 | ||
| 88 | // return a filtering scorer | |
| 89 | ||