|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DisjunctionMaxQuery | Line # 42 | 55 | 26 | 66.3% |
0.6631579
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DisjunctionMaxQuery.DisjunctionMaxWeight | Line # 90 | 36 | 15 | 86.9% |
0.86885244
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (32) | |||
| Result | |||
|
0.71153843
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ9
org.apache.lucene.search.TestSimpleExplanations.testDMQ9
|
1 PASS | |
|
0.71153843
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ7
org.apache.lucene.search.TestSimpleExplanations.testDMQ7
|
1 PASS | |
|
0.71153843
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ8
org.apache.lucene.search.TestSimpleExplanations.testDMQ8
|
1 PASS | |
|
0.71153843
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ6
org.apache.lucene.search.TestSimpleExplanations.testDMQ6
|
1 PASS | |
|
0.7051282
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ5
org.apache.lucene.search.TestSimpleExplanations.testDMQ5
|
1 PASS | |
|
0.6858974
|
org.apache.lucene.search.TestComplexExplanations.testDMQ10
org.apache.lucene.search.TestComplexExplanations.testDMQ10
|
1 PASS | |
|
0.6858974
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ4
org.apache.lucene.search.TestSimpleExplanations.testDMQ4
|
1 PASS | |
|
0.6858974
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ3
org.apache.lucene.search.TestSimpleExplanations.testDMQ3
|
1 PASS | |
|
0.6858974
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ2
org.apache.lucene.search.TestSimpleExplanations.testDMQ2
|
1 PASS | |
|
0.6730769
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ1
org.apache.lucene.search.TestSimpleExplanations.testDMQ1
|
1 PASS | |
|
0.6730769
|
org.apache.lucene.search.TestComplexExplanations.test2
org.apache.lucene.search.TestComplexExplanations.test2
|
1 PASS | |
|
0.6730769
|
org.apache.lucene.search.TestComplexExplanations.test1
org.apache.lucene.search.TestComplexExplanations.test1
|
1 PASS | |
|
0.5576923
|
org.apache.lucene.search.TestComplexExplanations.test2
org.apache.lucene.search.TestComplexExplanations.test2
|
1 PASS | |
|
0.5576923
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleTiebreaker
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleTiebreaker
|
1 PASS | |
|
0.5576923
|
org.apache.lucene.search.TestComplexExplanations.test1
org.apache.lucene.search.TestComplexExplanations.test1
|
1 PASS | |
|
0.5448718
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanRequiredEqualScores
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanRequiredEqualScores
|
1 PASS | |
|
0.5448718
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleEqualScores1
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleEqualScores1
|
1 PASS | |
|
0.5448718
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleEqualScores2
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleEqualScores2
|
1 PASS | |
|
0.5448718
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleEqualScores3
org.apache.lucene.search.TestDisjunctionMaxQuery.testSimpleEqualScores3
|
1 PASS | |
|
0.53846157
|
org.apache.lucene.search.TestComplexExplanations.testDMQ10
org.apache.lucene.search.TestComplexExplanations.testDMQ10
|
1 PASS | |
|
0.525641
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ8
org.apache.lucene.search.TestSimpleExplanations.testDMQ8
|
1 PASS | |
|
0.525641
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ5
org.apache.lucene.search.TestSimpleExplanations.testDMQ5
|
1 PASS | |
|
0.525641
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ9
org.apache.lucene.search.TestSimpleExplanations.testDMQ9
|
1 PASS | |
|
0.5192308
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanOptionalWithTiebreaker
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanOptionalWithTiebreaker
|
1 PASS | |
|
0.5192308
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanOptionalWithTiebreakerAndBoost
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanOptionalWithTiebreakerAndBoost
|
1 PASS | |
|
0.50641024
|
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanOptionalNoTiebreaker
org.apache.lucene.search.TestDisjunctionMaxQuery.testBooleanOptionalNoTiebreaker
|
1 PASS | |
|
0.5
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ4
org.apache.lucene.search.TestSimpleExplanations.testDMQ4
|
1 PASS | |
|
0.5
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ3
org.apache.lucene.search.TestSimpleExplanations.testDMQ3
|
1 PASS | |
|
0.1923077
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ6
org.apache.lucene.search.TestSimpleExplanations.testDMQ6
|
1 PASS | |
|
0.1923077
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ7
org.apache.lucene.search.TestSimpleExplanations.testDMQ7
|
1 PASS | |
|
0.16666667
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ2
org.apache.lucene.search.TestSimpleExplanations.testDMQ2
|
1 PASS | |
|
0.15384616
|
org.apache.lucene.search.TestSimpleExplanations.testDMQ1
org.apache.lucene.search.TestSimpleExplanations.testDMQ1
|
1 PASS | |
| 1 | package org.apache.lucene.search; | |
| 2 | ||
| 3 | /** | |
| 4 | * Copyright 2004 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 | ||
| 21 | import java.io.IOException; | |
| 22 | import java.util.ArrayList; | |
| 23 | import java.util.Iterator; | |
| 24 | import java.util.Collection; | |
| 25 | import java.util.Set; | |
| 26 | ||
| 27 | /** | |
| 28 | * A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum | |
| 29 | * score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries. | |
| 30 | * This is useful when searching for a word in multiple fields with different boost factors (so that the fields cannot be | |
| 31 | * combined equivalently into a single search field). We want the primary score to be the one associated with the highest boost, | |
| 32 | * not the sum of the field scores (as BooleanQuery would give). | |
| 33 | * If the query is "albino elephant" this ensures that "albino" matching one field and "elephant" matching | |
| 34 | * another gets a higher score than "albino" matching both fields. | |
| 35 | * To get this result, use both BooleanQuery and DisjunctionMaxQuery: for each term a DisjunctionMaxQuery searches for it in | |
| 36 | * each field, while the set of these DisjunctionMaxQuery's is combined into a BooleanQuery. | |
| 37 | * The tie breaker capability allows results that include the same term in multiple fields to be judged better than results that | |
| 38 | * include this term in only the best of those multiple fields, without confusing this with the better case of two different terms | |
| 39 | * in the multiple fields. | |
| 40 | * @author Chuck Williams | |
| 41 | */ | |
| 42 | public class DisjunctionMaxQuery extends Query { | |
| 43 | ||
| 44 | /* The subqueries */ | |
| 45 | private ArrayList disjuncts = new ArrayList(); | |
| 46 | ||
| 47 | /* Multiple of the non-max disjunct scores added into our final score. Non-zero values support tie-breaking. */ | |
| 48 | private float tieBreakerMultiplier = 0.0f; | |
| 49 | ||
| 50 | /** Creates a new empty DisjunctionMaxQuery. Use add() to add the subqueries. | |
| 51 | * @param tieBreakerMultiplier this score of each non-maximum disjunct for a document is multiplied by this weight | |
| 52 | * and added into the final score. If non-zero, the value should be small, on the order of 0.1, which says that | |
| 53 | * 10 occurrences of word in a lower-scored field that is also in a higher scored field is just as good as a unique | |
| 54 | * word in the lower scored field (i.e., one that is not in any higher scored field. | |
| 55 | */ | |
| 56 | 40 |
public DisjunctionMaxQuery(float tieBreakerMultiplier) { |
| 57 | 40 | this.tieBreakerMultiplier = tieBreakerMultiplier; |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * Creates a new DisjunctionMaxQuery | |
| 62 | * @param disjuncts a Collection<Query> of all the disjuncts to add | |
| 63 | * @param tieBreakerMultiplier the weight to give to each matching non-maximum disjunct | |
| 64 | */ | |
| 65 | 0 |
public DisjunctionMaxQuery(Collection disjuncts, float tieBreakerMultiplier) { |
| 66 | 0 | this.tieBreakerMultiplier = tieBreakerMultiplier; |
| 67 | 0 | add(disjuncts); |
| 68 | } | |
| 69 | ||
| 70 | /** Add a subquery to this disjunction | |
| 71 | * @param query the disjunct added | |
| 72 | */ | |