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


Java SpanTermQuery.setBoost方法代码示例

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


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

示例1: getSpanQuery

import org.apache.lucene.search.spans.SpanTermQuery; //导入方法依赖的package包/类
@Override
public SpanQuery getSpanQuery(Element e) throws ParserException {
  String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
  String value = DOMUtils.getNonBlankTextOrFail(e);
  SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, value));

  stq.setBoost(DOMUtils.getAttribute(e, "boost", 1.0f));
  return stq;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:SpanTermBuilder.java

示例2: addComplexPhraseClause

import org.apache.lucene.search.spans.SpanTermQuery; //导入方法依赖的package包/类
private void addComplexPhraseClause(List<SpanQuery> spanClauses, BooleanQuery qc) {
  ArrayList<SpanQuery> ors = new ArrayList<>();
  ArrayList<SpanQuery> nots = new ArrayList<>();
  BooleanClause[] bclauses = qc.getClauses();

  // For all clauses e.g. one* two~
  for (int i = 0; i < bclauses.length; i++) {
    Query childQuery = bclauses[i].getQuery();

    // select the list to which we will add these options
    ArrayList<SpanQuery> chosenList = ors;
    if (bclauses[i].getOccur() == BooleanClause.Occur.MUST_NOT) {
      chosenList = nots;
    }

    if (childQuery instanceof TermQuery) {
      TermQuery tq = (TermQuery) childQuery;
      SpanTermQuery stq = new SpanTermQuery(tq.getTerm());
      stq.setBoost(tq.getBoost());
      chosenList.add(stq);
    } else if (childQuery instanceof BooleanQuery) {
      BooleanQuery cbq = (BooleanQuery) childQuery;
      addComplexPhraseClause(chosenList, cbq);
    } else {
      // TODO alternatively could call extract terms here?
      throw new IllegalArgumentException("Unknown query type:"
          + childQuery.getClass().getName());
    }
  }
  if (ors.size() == 0) {
    return;
  }
  SpanOrQuery soq = new SpanOrQuery(ors
      .toArray(new SpanQuery[ors.size()]));
  if (nots.size() == 0) {
    spanClauses.add(soq);
  } else {
    SpanOrQuery snqs = new SpanOrQuery(nots
        .toArray(new SpanQuery[nots.size()]));
    SpanNotQuery snq = new SpanNotQuery(soq, snqs);
    spanClauses.add(snq);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:44,代码来源:ComplexPhraseQueryParser.java


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