C# Класс Lucene.Net.Queries.CommonTermsQuery

A query that executes high-frequency terms in a optional sub-query to prevent slow queries due to "common" terms like stopwords. This query builds 2 queries off the #add(Term) added terms: low-frequency terms are added to a required boolean clause and high-frequency terms are added to an optional boolean clause. The optional clause is only executed if the required "low-frequency" clause matches. Scores produced by this query will be slightly different than plain BooleanQuery scorer mainly due to differences in the Similarity#coord(int,int) number of leaf queries in the required boolean clause. In most cases, high-frequency terms are unlikely to significantly contribute to the document score unless at least one of the low-frequency terms are matched. This query can improve query execution times significantly if applicable.

CommonTermsQuery has several advantages over stopword filtering at index or query time since a term can be "classified" based on the actual document frequency in the index and can prevent slow queries even across domains without specialized stopword files.

Note: if the query only contains high-frequency terms the query is rewritten into a plain conjunction query ie. all high-frequency terms need to match in order to match a document.

Наследование: Lucene.Net.Search.Query
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
disableCoord bool
highFreqBoost float
highFreqOccur Lucene.Net.Search.BooleanClause.Occur
lowFreqBoost float
lowFreqOccur Lucene.Net.Search.BooleanClause.Occur
maxTermFrequency float
terms IList

Открытые методы

Метод Описание
Add ( Lucene.Net.Index.Term term ) : void

Adds a term to the CommonTermsQuery

CollectTermContext ( IndexReader reader, IList leaves, TermContext contextArray, Lucene.Net.Index.Term queryTerms ) : void
CommonTermsQuery ( BooleanClause highFreqOccur, BooleanClause lowFreqOccur, float maxTermFrequency ) : System

Creates a new CommonTermsQuery

CommonTermsQuery ( BooleanClause highFreqOccur, BooleanClause lowFreqOccur, float maxTermFrequency, bool disableCoord ) : System

Creates a new CommonTermsQuery

Equals ( object obj ) : bool
ExtractTerms ( ISet terms ) : void
GetHashCode ( ) : int
Rewrite ( IndexReader reader ) : Query
ToString ( string field ) : string

Защищенные методы

Метод Описание
BuildQuery ( int maxDoc, TermContext contextArray, Lucene.Net.Index.Term queryTerms ) : Query
CalcHighFreqMinimumNumberShouldMatch ( int numOptional ) : int
CalcLowFreqMinimumNumberShouldMatch ( int numOptional ) : int
NewTermQuery ( Lucene.Net.Index.Term term, TermContext context ) : Query

Builds a new TermQuery instance.

This is intended for subclasses that wish to customize the generated queries.

Приватные методы

Метод Описание
MinNrShouldMatch ( float minNrShouldMatch, int numOptional ) : int

Описание методов

Add() публичный Метод

Adds a term to the CommonTermsQuery
public Add ( Lucene.Net.Index.Term term ) : void
term Lucene.Net.Index.Term /// the term to add
Результат void

BuildQuery() защищенный Метод

protected BuildQuery ( int maxDoc, TermContext contextArray, Lucene.Net.Index.Term queryTerms ) : Query
maxDoc int
contextArray Lucene.Net.Index.TermContext
queryTerms Lucene.Net.Index.Term
Результат Lucene.Net.Search.Query

CalcHighFreqMinimumNumberShouldMatch() защищенный Метод

protected CalcHighFreqMinimumNumberShouldMatch ( int numOptional ) : int
numOptional int
Результат int

CalcLowFreqMinimumNumberShouldMatch() защищенный Метод

protected CalcLowFreqMinimumNumberShouldMatch ( int numOptional ) : int
numOptional int
Результат int

CollectTermContext() публичный Метод

public CollectTermContext ( IndexReader reader, IList leaves, TermContext contextArray, Lucene.Net.Index.Term queryTerms ) : void
reader Lucene.Net.Index.IndexReader
leaves IList
contextArray Lucene.Net.Index.TermContext
queryTerms Lucene.Net.Index.Term
Результат void

CommonTermsQuery() публичный Метод

Creates a new CommonTermsQuery
/// if is pass as lowFreqOccur or /// highFreqOccur
public CommonTermsQuery ( BooleanClause highFreqOccur, BooleanClause lowFreqOccur, float maxTermFrequency ) : System
highFreqOccur Lucene.Net.Search.BooleanClause /// used for high frequency terms
lowFreqOccur Lucene.Net.Search.BooleanClause /// used for low frequency terms
maxTermFrequency float /// a value in [0..1) (or absolute number >=1) representing the /// maximum threshold of a terms document frequency to be considered a /// low frequency term.
Результат System

CommonTermsQuery() публичный Метод

Creates a new CommonTermsQuery
/// if is pass as lowFreqOccur or /// highFreqOccur
public CommonTermsQuery ( BooleanClause highFreqOccur, BooleanClause lowFreqOccur, float maxTermFrequency, bool disableCoord ) : System
highFreqOccur Lucene.Net.Search.BooleanClause /// used for high frequency terms
lowFreqOccur Lucene.Net.Search.BooleanClause /// used for low frequency terms
maxTermFrequency float /// a value in [0..1) (or absolute number >=1) representing the /// maximum threshold of a terms document frequency to be considered a /// low frequency term.
disableCoord bool /// disables in scoring for the low /// / high frequency sub-queries
Результат System

Equals() публичный Метод

public Equals ( object obj ) : bool
obj object
Результат bool

ExtractTerms() публичный Метод

public ExtractTerms ( ISet terms ) : void
terms ISet
Результат void

GetHashCode() публичный Метод

public GetHashCode ( ) : int
Результат int

NewTermQuery() защищенный Метод

Builds a new TermQuery instance.

This is intended for subclasses that wish to customize the generated queries.

protected NewTermQuery ( Lucene.Net.Index.Term term, TermContext context ) : Query
term Lucene.Net.Index.Term term
context Lucene.Net.Index.TermContext the TermContext to be used to create the low level term query. Can be null.
Результат Lucene.Net.Search.Query

Rewrite() публичный Метод

public Rewrite ( IndexReader reader ) : Query
reader Lucene.Net.Index.IndexReader
Результат Lucene.Net.Search.Query

ToString() публичный Метод

public ToString ( string field ) : string
field string
Результат string

Описание свойств

disableCoord защищенное свойство

protected bool disableCoord
Результат bool

highFreqBoost защищенное свойство

protected float highFreqBoost
Результат float

highFreqOccur защищенное свойство

protected BooleanClause.Occur,Lucene.Net.Search highFreqOccur
Результат Lucene.Net.Search.BooleanClause.Occur

lowFreqBoost защищенное свойство

protected float lowFreqBoost
Результат float

lowFreqOccur защищенное свойство

protected BooleanClause.Occur,Lucene.Net.Search lowFreqOccur
Результат Lucene.Net.Search.BooleanClause.Occur

maxTermFrequency защищенное свойство

protected float maxTermFrequency
Результат float

terms защищенное свойство

protected IList terms
Результат IList