Java 类org.apache.lucene.search.spans.SpanBoostQuery 实例源码

项目:elasticsearch_my    文件:AbstractQueryTestCase.java   
/**
 * Checks the result of {@link QueryBuilder#toQuery(QueryShardContext)} given the original {@link QueryBuilder}
 * and {@link QueryShardContext}. Verifies that named queries and boost are properly handled and delegates to
 * {@link #doAssertLuceneQuery(AbstractQueryBuilder, Query, SearchContext)} for query specific checks.
 */
private void assertLuceneQuery(QB queryBuilder, Query query, SearchContext context) throws IOException {
    if (queryBuilder.queryName() != null) {
        Query namedQuery = context.getQueryShardContext().copyNamedQueries().get(queryBuilder.queryName());
        assertThat(namedQuery, equalTo(query));
    }
    if (query != null) {
        if (queryBuilder.boost() != AbstractQueryBuilder.DEFAULT_BOOST) {
            assertThat(query, either(instanceOf(BoostQuery.class)).or(instanceOf(SpanBoostQuery.class)));
            if (query instanceof SpanBoostQuery) {
                SpanBoostQuery spanBoostQuery = (SpanBoostQuery) query;
                assertThat(spanBoostQuery.getBoost(), equalTo(queryBuilder.boost()));
                query = spanBoostQuery.getQuery();
            } else {
                BoostQuery boostQuery = (BoostQuery) query;
                assertThat(boostQuery.getBoost(), equalTo(queryBuilder.boost()));
                query = boostQuery.getQuery();
            }
        }
    }
    doAssertLuceneQuery(queryBuilder, query, context);
}
项目:lucene-addons    文件:SQPTestBase.java   
float getBoost(Query q) {
  if (q instanceof BoostQuery) {
    return ((BoostQuery)q).getBoost();
  } else if (q instanceof SpanBoostQuery) {
    return ((SpanBoostQuery)q).getBoost();
  }
  return 1.0f;
}
项目:lucene-addons    文件:QueryParserTestBase.java   
private Float getBoost(Query q) {
  if (q instanceof BoostQuery) {
    return ((BoostQuery)q).getBoost();
  } else if (q instanceof SpanBoostQuery) {
    return ((SpanBoostQuery)q).getBoost();
  }
  return 1.0f;
}