当前位置: 首页>>代码示例>>Java>>正文


Java Query.setBoost方法代码示例

本文整理汇总了Java中org.apache.lucene.search.Query.setBoost方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setBoost方法的具体用法?Java Query.setBoost怎么用?Java Query.setBoost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.search.Query的用法示例。


在下文中一共展示了Query.setBoost方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public Query build(QueryNode queryNode) throws QueryNodeException {
  BoostQueryNode boostNode = (BoostQueryNode) queryNode;
  QueryNode child = boostNode.getChild();

  if (child == null) {
    return null;
  }

  Query query = (Query) child
      .getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID);
  query.setBoost(boostNode.getValue());

  return query;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:BoostQueryNodeBuilder.java

示例2: getQuery

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public Query getQuery(Element e) throws ParserException {
  String text = DOMUtils.getText(e);
  try {
    Query q = null;
    if (unSafeParser != null) {
      //synchronize on unsafe parser
      synchronized (unSafeParser) {
        q = unSafeParser.parse(text);
      }
    } else {
      String fieldName = DOMUtils.getAttribute(e, "fieldName", defaultField);
      //Create new parser
      QueryParser parser = createQueryParser(fieldName, analyzer);
      q = parser.parse(text);
    }
    q.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
    return q;
  } catch (ParseException e1) {
    throw new ParserException(e1.getMessage());
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:UserInputQueryBuilder.java

示例3: rewrite

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public Query rewrite(IndexReader reader) throws IOException {
    IndexReaderContext context = reader.getContext();
    TermContext[] ctx = new TermContext[terms.length];
    int[] docFreqs = new int[ctx.length];
    for (int i = 0; i < terms.length; i++) {
        ctx[i] = TermContext.build(context, terms[i]);
        docFreqs[i] = ctx[i].docFreq();
    }

    final int maxDoc = reader.maxDoc();
    blend(ctx, maxDoc, reader);
    Query query = topLevelQuery(terms, ctx, docFreqs, maxDoc);
    query.setBoost(getBoost());
    return query;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:BlendedTermQuery.java

示例4: rewrite

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public Query rewrite(IndexReader reader) throws IOException {
  final Query q = query.rewrite(reader);
  if (!(q instanceof SpanQuery))
    throw new UnsupportedOperationException("You can only use SpanMultiTermQueryWrapper with a suitable SpanRewriteMethod.");
  q.setBoost(q.getBoost() * getBoost()); // multiply boost
  return q;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:SpanMultiTermQueryWrapper.java

示例5: getQuery

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public Query getQuery(Element e) throws ParserException {
  Element filterElem = DOMUtils.getFirstChildOrFail(e);

  Query q = new ConstantScoreQuery(filterFactory.getFilter(filterElem));
  q.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
  return q;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ConstantScoreQueryBuilder.java

示例6: newDefaultQuery

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
/**
 * Factory method to generate a standard query (no phrase or prefix operators).
 */
protected Query newDefaultQuery(String text) {
  BooleanQuery bq = new BooleanQuery(true);
  for (Map.Entry<String,Float> entry : weights.entrySet()) {
    Query q = createBooleanQuery(entry.getKey(), text, defaultOperator);
    if (q != null) {
      q.setBoost(entry.getValue());
      bq.add(q, BooleanClause.Occur.SHOULD);
    }
  }
  return simplify(bq);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:SimpleQueryParser.java

示例7: newFuzzyQuery

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
/**
 * Factory method to generate a fuzzy query.
 */
protected Query newFuzzyQuery(String text, int fuzziness) {
  BooleanQuery bq = new BooleanQuery(true);
  for (Map.Entry<String,Float> entry : weights.entrySet()) {
    Query q = new FuzzyQuery(new Term(entry.getKey(), text), fuzziness);
    if (q != null) {
      q.setBoost(entry.getValue());
      bq.add(q, BooleanClause.Occur.SHOULD);
    }
  }
  return simplify(bq);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:SimpleQueryParser.java

示例8: newPhraseQuery

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
/**
 * Factory method to generate a phrase query with slop.
 */
protected Query newPhraseQuery(String text, int slop) {
  BooleanQuery bq = new BooleanQuery(true);
  for (Map.Entry<String,Float> entry : weights.entrySet()) {
    Query q = createPhraseQuery(entry.getKey(), text, slop);
    if (q != null) {
      q.setBoost(entry.getValue());
      bq.add(q, BooleanClause.Occur.SHOULD);
    }
  }
  return simplify(bq);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:SimpleQueryParser.java

示例9: makeLuceneQueryField

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
public Query makeLuceneQueryField(String fieldName, BasicQueryFactory qf){
  Query q = makeLuceneQueryFieldNoBoost(fieldName, qf);
  if (isWeighted()) {
    q.setBoost(getWeight() * q.getBoost()); /* weight may be at any level in a SrndQuery */
  }
  return q;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:SrndQuery.java

示例10: parseAndApply

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
private Query parseAndApply(Type type, String fieldName, Object value, String minimumShouldMatch, Float boostValue) throws IOException {
    Query query = parse(type, fieldName, value);
    // If the coordination factor is disabled on a boolean query we don't apply the minimum should match.
    // This is done to make sure that the minimum_should_match doesn't get applied when there is only one word
    // and multiple variations of the same word in the query (synonyms for instance).
    if (query instanceof BooleanQuery && !((BooleanQuery) query).isCoordDisabled()) {
        query = Queries.applyMinimumShouldMatch((BooleanQuery) query, minimumShouldMatch);
    }
    if (boostValue != null && query != null) {
        query.setBoost(boostValue);
    }
    return query;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:MultiMatchQuery.java

示例11: rewrite

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@Override
public Query rewrite(IndexReader reader) throws IOException {
    final Query childRewritten = childQuery.rewrite(reader);
    if (childRewritten != childQuery) {
        Query rewritten = new ChildrenQuery(ifd, parentType, childType, parentFilter, childRewritten, scoreType, minChildren, maxChildren, shortCircuitParentDocSet, nonNestedDocsFilter);
        rewritten.setBoost(getBoost());
        return rewritten;
    }
    return super.rewrite(reader);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ChildrenQuery.java

示例12: rewrite

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ParentQuery.java

示例13: rewrite

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
@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);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:11,代码来源:ParentConstantScoreQuery.java

示例14: applyBoost

import org.apache.lucene.search.Query; //导入方法依赖的package包/类
private void applyBoost(String field, Query q) {
    if (settings.boosts() != null) {
        float boost = settings.boosts().getOrDefault(field, 1f);
        q.setBoost(boost);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:MapperQueryParser.java


注:本文中的org.apache.lucene.search.Query.setBoost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。