org.apache.lucene.search.Query.setBoost()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中org.apache.lucene.search.Query.setBoost方法的一些代码示例,展示了Query.setBoost的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setBoost方法的具体详情如下:
包路径:org.apache.lucene.search.Query
类名称:Query
方法名:setBoost

Query.setBoost介绍

[英]Sets the boost for this query clause to b.
[中]将此查询子句的boost设置为[$0$]。

代码示例

代码示例来源:origin: larsga/Duke

termQuery.setBoost(boost);
parent.add(termQuery, required ? Occur.MUST : Occur.SHOULD);

代码示例来源:origin: org.compass-project/compass

public SearchEngineQuery setBoost(float boost) {
  query.setBoost(boost);
  return this;
}

代码示例来源:origin: SciGraph/SciGraph

public static Query getBoostedQuery(QueryParser parser, String queryString, float boost)
  throws ParseException {
 Query query = parser.parse(queryString);
 query.setBoost(boost);
 return query;
}

代码示例来源:origin: stackoverflow.com

new PrefixQuery(prefix) {
 public Query rewrite(final IndexReader reader) throws IOException {
  try {
   return super.rewrite(reader);
  } catch (final TooManyClauses e) {
   log.debug("falling back to ConstantScoreQuery for prefix " + prefix + " (" + e + ")");
   final Query q = new ConstantScoreQuery(new PrefixFilter(prefix));
   q.setBoost(getBoost());
   return q;
  }
 }
};

代码示例来源:origin: org.apache.lucene/lucene-spellchecker

/**
 * Add a clause to a boolean query.
 */
private static void add(BooleanQuery q, String name, String value, float boost) {
 Query tq = new TermQuery(new Term(name, value));
 tq.setBoost(boost);
 q.add(new BooleanClause(tq, BooleanClause.Occur.SHOULD));
}

代码示例来源:origin: org.compass-project/compass

/**
 * Add a clause to a boolean query.
 */
private static void add(BooleanQuery q, String name, String value, float boost) {
 Query tq = new TermQuery(new Term(name, value));
 tq.setBoost(boost);
 q.add(new BooleanClause(tq, BooleanClause.Occur.SHOULD));
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

protected Weight createWeight(Searcher searcher) throws IOException {
 if (terms.size() == 1) {			  // optimize one-term case
  Term term = (Term)terms.get(0);
  Query termQuery = new TermQuery(term);
  termQuery.setBoost(getBoost());
  return termQuery.createWeight(searcher);
 }
 return new PhraseWeight(searcher);
}

代码示例来源:origin: lucene/lucene

protected Weight createWeight(Searcher searcher) {
 if (terms.size() == 1) {			  // optimize one-term case
  Term term = (Term)terms.elementAt(0);
  Query termQuery = new TermQuery(term);
  termQuery.setBoost(getBoost());
  return termQuery.createWeight(searcher);
 }
 return new PhraseWeight(searcher);
}

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

protected Weight createWeight(Searcher searcher) throws IOException {
 if (terms.size() == 1) {			  // optimize one-term case
  Term term = (Term)terms.get(0);
  Query termQuery = new TermQuery(term);
  termQuery.setBoost(getBoost());
  return termQuery.createWeight(searcher);
 }
 return new PhraseWeight(searcher);
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

/** Expert: called to re-write queries into primitive queries. For example,
 * a PrefixQuery will be rewritten into a BooleanQuery that consists
 * of TermQuerys.
 */
public Query rewrite(IndexReader reader) throws IOException {
 if (boost != 1f) {
  Query rewritten = clone();
  rewritten.setBoost(1f);
  return new BoostQuery(rewritten, boost);
 }
 return this;
}

代码示例来源:origin: org.apache.lucene/lucene-core-jfrog

public Query rewrite(IndexReader reader) throws IOException {
 // Map to RangeFilter semantics which are slightly different...
 RangeFilter rangeFilt = new RangeFilter
   (fieldName, lowerVal != null?lowerVal:"", upperVal,
    lowerVal==""?false:includeLower, upperVal==null?false:includeUpper,
    collator);
 Query q = new ConstantScoreQuery(rangeFilt);
 q.setBoost(getBoost());
 return q;
}

代码示例来源:origin: com.atlassian.jira/jira-core

public QueryFactoryResult getQuery(final QueryCreationContext queryCreationContext, final TerminalClause terminalClause)
{
  final QueryFactoryResult queryFactoryResult = delegateClauseQueryFactory.getQuery(queryCreationContext, terminalClause);
  if (queryFactoryResult != null && queryFactoryResult.getLuceneQuery() != null)
  {
    // Summary always gets a boost of 9
    queryFactoryResult.getLuceneQuery().setBoost(SUMMARY_BOOST_FACTOR);
  }
  return queryFactoryResult;
}

代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene

public Query rewrite(IndexReader reader) throws IOException {
 // Map to RangeFilter semantics which are slightly different...
 RangeFilter rangeFilt = new RangeFilter
   (fieldName, lowerVal != null?lowerVal:"", upperVal,
    lowerVal==""?false:includeLower, upperVal==null?false:includeUpper,
    collator);
 Query q = new ConstantScoreQuery(rangeFilt);
 q.setBoost(getBoost());
 return q;
}

代码示例来源:origin: rdelbru/SIREn

public Query build(final QueryNode queryNode) throws QueryNodeException {
 final BoostQueryNode boostNode = (BoostQueryNode) queryNode;
 final QueryNode child = boostNode.getChild();
 if (child == null) {
  return null;
 }
 final Query query = (Query) child
   .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
 query.setBoost(boostNode.getValue());
 return query;
}

代码示例来源:origin: rdelbru/SIREn

@Override
public Query rewrite(final IndexReader reader, final MultiNodeTermQuery query) throws IOException {
 final NodeBooleanQuery bq = SCORING_BOOLEAN_QUERY_REWRITE.rewrite(reader, query);
 // TODO: if empty boolean query return NullQuery?
 if (bq.clauses().isEmpty()) {
  return bq;
 }
 // strip the scores off
 final Query result = new NodeConstantScoreQuery(bq);
 result.setBoost(query.getBoost());
 return result;
}

代码示例来源:origin: sirensolutions/siren

public Query build(final QueryNode queryNode) throws QueryNodeException {
 final BoostQueryNode boostNode = (BoostQueryNode) queryNode;
 final QueryNode child = boostNode.getChild();
 if (child == null) {
  return null;
 }
 final Query query = (Query) child.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
 query.setBoost(boostNode.getValue());
 return query;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public Query rewrite(IndexReader reader) throws IOException {
  Query parentRewritten = parentQuery.rewrite(reader);
  if (parentRewritten != parentQuery) {
    Query rewritten = new ParentConstantScoreQuery(parentChildIndexFieldData, parentRewritten, parentType, childrenFilter);
    rewritten.setBoost(getBoost());
    return rewritten;
  }
  return super.rewrite(reader);
}

代码示例来源:origin: org.compass-project/compass

public Query rewrite(IndexReader reader) throws IOException {
  // TODO: if number of terms are low enough, rewrite to a BooleanQuery
  // for potentially faster execution.
  // TODO: cache the bitset somewhere instead of regenerating it
  Query q = new ConstantScoreQuery(new PrefixFilter(prefix));
  q.setBoost(getBoost());
  return q;
}

代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core

public Query rewrite(IndexReader reader) throws IOException {
 // TODO: if number of terms are low enough, rewrite to a BooleanQuery
 // for potentially faster execution.
 // TODO: cache the bitset somewhere instead of regenerating it
 Query q = new ConstantScoreQuery(new PrefixFilter(prefix));
 q.setBoost(getBoost());
 return q;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public Query rewrite(IndexReader reader) throws IOException {
  Query parentRewritten = parentQuery.rewrite(reader);
  if (parentRewritten != parentQuery) {
    Query rewritten = new ParentQuery(parentChildIndexFieldData, parentRewritten, parentType, childrenFilter);
    rewritten.setBoost(getBoost());
    return rewritten;
  }
  return super.rewrite(reader);
}

相关文章