Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Classes | Public Member Functions | List of all members
Lucene.Net.Search.DisjunctionMaxQuery Class Reference

A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries. This is useful when searching for a word in multiple fields with different boost factors (so that the fields cannot be combined equivalently into a single search field). We want the primary score to be the one associated with the highest boost, not the sum of the field scores (as BooleanQuery would give). If the query is "albino elephant" this ensures that "albino" matching one field and "elephant" matching another gets a higher score than "albino" matching both fields. To get this result, use both BooleanQuery and DisjunctionMaxQuery: for each term a DisjunctionMaxQuery searches for it in each field, while the set of these DisjunctionMaxQuery's is combined into a BooleanQuery. The tie breaker capability allows results that include the same term in multiple fields to be judged better than results that include this term in only the best of those multiple fields, without confusing this with the better case of two different terms in the multiple fields. More...

Inherits Lucene.Net.Search.Query, IEnumerable< Query >, and ICloneable.

Classes

class  DisjunctionMaxWeight
 Expert: the Weight for DisjunctionMaxQuery, used to normalize, score and explain these queries.
 

Public Member Functions

 DisjunctionMaxQuery (float tieBreakerMultiplier)
 Creates a new empty DisjunctionMaxQuery. Use add() to add the subqueries.
 
 DisjunctionMaxQuery (System.Collections.Generic.ICollection< Query > disjuncts, float tieBreakerMultiplier)
 Creates a new DisjunctionMaxQuery
 
virtual void Add (Query query)
 Add a subquery to this disjunction
 
virtual void Add (System.Collections.Generic.ICollection< Query > disjuncts)
 Add a collection of disjuncts to this disjunction via Iterable
 
virtual
System.Collections.Generic.IEnumerator
< Query
GetEnumerator ()
 An Iterator<Query> over the disjuncts
 
override Weight CreateWeight (Searcher searcher)
 Expert: Constructs an appropriate Weight implementation for this query.
 
override Query Rewrite (IndexReader reader)
 Optimize our representation and our subqueries representations
 
override System.Object Clone ()
 Create a shallow copy of us – used in rewriting if necessary
 
override void ExtractTerms (System.Collections.Generic.ISet< Term > terms)
 Expert: adds all terms occuring in this query to the terms set. Only works if this query is in its rewritten form.
 
override System.String ToString (System.String field)
 Prettyprint us.
 
override bool Equals (System.Object o)
 Return true iff we represent the same query as o
 
override int GetHashCode ()
 Compute a hash code for hashing us
 
- Public Member Functions inherited from Lucene.Net.Search.Query
override System.String ToString ()
 Prints a query to a string.
 
virtual Weight Weight (Searcher searcher)
 Expert: Constructs and initializes a Weight for a top-level query.
 
virtual Query Combine (Query[] queries)
 Expert: called when re-writing queries under MultiSearcher.
 
virtual Similarity GetSimilarity (Searcher searcher)
 Expert: Returns the Similarity implementation to be used for this query. Subclasses may override this method to specify their own Similarity implementation, perhaps one that delegates through that of the Searcher. By default the Searcher's Similarity implementation is returned.
 
override int GetHashCode ()
 
override bool Equals (System.Object obj)
 

Additional Inherited Members

- Static Public Member Functions inherited from Lucene.Net.Search.Query
static Query MergeBooleanQueries (params BooleanQuery[] queries)
 Expert: merges the clauses of a set of BooleanQuery's into a single BooleanQuery.
 
- Properties inherited from Lucene.Net.Search.Query
virtual float Boost [get, set]
 Gets or sets the boost for this query clause to b. Documents matching this clause will (in addition to the normal weightings) have their score multiplied by b. The boost is 1.0 by default.
 

Detailed Description

A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries. This is useful when searching for a word in multiple fields with different boost factors (so that the fields cannot be combined equivalently into a single search field). We want the primary score to be the one associated with the highest boost, not the sum of the field scores (as BooleanQuery would give). If the query is "albino elephant" this ensures that "albino" matching one field and "elephant" matching another gets a higher score than "albino" matching both fields. To get this result, use both BooleanQuery and DisjunctionMaxQuery: for each term a DisjunctionMaxQuery searches for it in each field, while the set of these DisjunctionMaxQuery's is combined into a BooleanQuery. The tie breaker capability allows results that include the same term in multiple fields to be judged better than results that include this term in only the best of those multiple fields, without confusing this with the better case of two different terms in the multiple fields.

Definition at line 40 of file DisjunctionMaxQuery.cs.

Constructor & Destructor Documentation

Lucene.Net.Search.DisjunctionMaxQuery.DisjunctionMaxQuery ( float  tieBreakerMultiplier)

Creates a new empty DisjunctionMaxQuery. Use add() to add the subqueries.

Parameters
tieBreakerMultiplierthe score of each non-maximum disjunct for a document is multiplied by this weight and added into the final score. If non-zero, the value should be small, on the order of 0.1, which says that 10 occurrences of word in a lower-scored field that is also in a higher scored field is just as good as a unique word in the lower scored field (i.e., one that is not in any higher scored field.

Definition at line 55 of file DisjunctionMaxQuery.cs.

Lucene.Net.Search.DisjunctionMaxQuery.DisjunctionMaxQuery ( System.Collections.Generic.ICollection< Query disjuncts,
float  tieBreakerMultiplier 
)

Creates a new DisjunctionMaxQuery

Parameters
disjunctsa Collection<Query> of all the disjuncts to add
tieBreakerMultiplierthe weight to give to each matching non-maximum disjunct

Definition at line 65 of file DisjunctionMaxQuery.cs.

Member Function Documentation

virtual void Lucene.Net.Search.DisjunctionMaxQuery.Add ( Query  query)
virtual

Add a subquery to this disjunction

Parameters
querythe disjunct added

Definition at line 74 of file DisjunctionMaxQuery.cs.

virtual void Lucene.Net.Search.DisjunctionMaxQuery.Add ( System.Collections.Generic.ICollection< Query disjuncts)
virtual

Add a collection of disjuncts to this disjunction via Iterable

Definition at line 82 of file DisjunctionMaxQuery.cs.

override System.Object Lucene.Net.Search.DisjunctionMaxQuery.Clone ( )
virtual

Create a shallow copy of us – used in rewriting if necessary

Returns
a copy of us (but reuse, don't copy, our subqueries)

Reimplemented from Lucene.Net.Search.Query.

Definition at line 268 of file DisjunctionMaxQuery.cs.

override Weight Lucene.Net.Search.DisjunctionMaxQuery.CreateWeight ( Searcher  searcher)
virtual

Expert: Constructs an appropriate Weight implementation for this query.

Only implemented by primitive queries, which re-write to themselves.

Reimplemented from Lucene.Net.Search.Query.

Definition at line 222 of file DisjunctionMaxQuery.cs.

override bool Lucene.Net.Search.DisjunctionMaxQuery.Equals ( System.Object  o)

Return true iff we represent the same query as o

Parameters
oanother object
Returns
true iff o is a DisjunctionMaxQuery with the same boost and the same subqueries, in the same order, as us

Definition at line 328 of file DisjunctionMaxQuery.cs.

override void Lucene.Net.Search.DisjunctionMaxQuery.ExtractTerms ( System.Collections.Generic.ISet< Term terms)
virtual

Expert: adds all terms occuring in this query to the terms set. Only works if this query is in its rewritten form.

<throws> UnsupportedOperationException if this query is not yet rewritten </throws>

Reimplemented from Lucene.Net.Search.Query.

Definition at line 276 of file DisjunctionMaxQuery.cs.

virtual System.Collections.Generic.IEnumerator<Query> Lucene.Net.Search.DisjunctionMaxQuery.GetEnumerator ( )
virtual

An Iterator<Query> over the disjuncts

Definition at line 88 of file DisjunctionMaxQuery.cs.

override int Lucene.Net.Search.DisjunctionMaxQuery.GetHashCode ( )

Compute a hash code for hashing us

Returns
the hash code

Definition at line 339 of file DisjunctionMaxQuery.cs.

override Query Lucene.Net.Search.DisjunctionMaxQuery.Rewrite ( IndexReader  reader)
virtual

Optimize our representation and our subqueries representations

Parameters
readerthe IndexReader we query
Returns
an optimized copy of us (which may not be a copy if there is nothing to optimize)

Reimplemented from Lucene.Net.Search.Query.

Definition at line 232 of file DisjunctionMaxQuery.cs.

override System.String Lucene.Net.Search.DisjunctionMaxQuery.ToString ( System.String  field)
virtual

Prettyprint us.

Parameters
fieldthe field to which we are applied
Returns
a string that shows what we do, of the form "(disjunct1 | disjunct2 | ... | disjunctn)^boost"

Implements Lucene.Net.Search.Query.

Definition at line 289 of file DisjunctionMaxQuery.cs.


The documentation for this class was generated from the following file: