Java Code Examples for org.apache.lucene.search.highlight.WeightedSpanTerm

The following examples show how to use org.apache.lucene.search.highlight.WeightedSpanTerm. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Elasticsearch   Source File: CustomQueryScorer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void extractUnknownQuery(Query query,
                                   Map<String, WeightedSpanTerm> terms) throws IOException {
    if (query instanceof FunctionScoreQuery) {
        query = ((FunctionScoreQuery) query).getSubQuery();
        extract(query, query.getBoost(), terms);
    } else if (query instanceof FiltersFunctionScoreQuery) {
        query = ((FiltersFunctionScoreQuery) query).getSubQuery();
        extract(query, query.getBoost(), terms);
    } else if (terms.isEmpty()) {
        extractWeightedTerms(terms, query, query.getBoost());
    }
}
 
Example 2
Source Project: lucene-solr   Source File: HighlightCustomQueryTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void extractUnknownQuery(Query query,
    Map<String, WeightedSpanTerm> terms) throws IOException {
  float boost = 1f;
  while (query instanceof BoostQuery) {
    BoostQuery bq = (BoostQuery) query;
    boost *= bq.getBoost();
    query = bq.getQuery();
  }
  if (query instanceof CustomQuery) {
    extractWeightedTerms(terms, new TermQuery(((CustomQuery) query).term), boost);
  }
}
 
Example 3
Source Project: lucene-solr   Source File: DefaultSolrHighlighter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void extract(Query query, float boost, Map<String, WeightedSpanTerm> terms) throws IOException {
  // these queries are not supported in lucene highlighting out of the box since 8.0
  if (query instanceof ToParentBlockJoinQuery) {
    extract(((ToParentBlockJoinQuery) query).getChildQuery(), boost, terms);
  } else if (query instanceof ToChildBlockJoinQuery) {
    extract(((ToChildBlockJoinQuery) query).getParentQuery(), boost, terms);
  } else {
    super.extract(query, boost, terms);
  }
}
 
Example 4
Source Project: Elasticsearch   Source File: CustomQueryScorer.java    License: Apache License 2.0 4 votes vote down vote up
public CustomQueryScorer(WeightedSpanTerm[] weightedTerms) {
    super(weightedTerms);
}