querqy.lucene.rewrite.TermQueryFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of querqy-lucene Show documentation
Show all versions of querqy-lucene Show documentation
Querqy library for query rewriting for Lucene
/**
*
*/
package querqy.lucene.rewrite;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
/**
* @author rene
*
*/
public class TermQueryFactory implements LuceneQueryFactory {
protected final Term term;
protected final querqy.model.Term sourceTerm;
public TermQueryFactory(final Term term, final querqy.model.Term sourceTerm) {
this.term = term;
this.sourceTerm = sourceTerm;
}
@Override
public void prepareDocumentFrequencyCorrection(final DocumentFrequencyCorrection dfc, final boolean isBelowDMQ) {
if (!isBelowDMQ) {
// a TQ might end up directly under a BQ as an optimisation
// make sure, we start a new clause in df correction
dfc.newClause();
}
dfc.prepareTerm(term);
}
@Override
public TermQuery createQuery(final FieldBoost boost, final TermQueryBuilder termQueryBuilder) {
return termQueryBuilder.createTermQuery(term, boost);
}
@Override
public R accept(final LuceneQueryFactoryVisitor visitor) {
return visitor.visit(this);
}
public String getFieldname() {
return term.field();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy