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

The following examples show how to use org.apache.lucene.search.highlight.WeightedSpanTerm. 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 File: CustomQueryScorer.java    From Elasticsearch with 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 File: HighlightCustomQueryTest.java    From lucene-solr with 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 File: DefaultSolrHighlighter.java    From lucene-solr with 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 File: CustomQueryScorer.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public CustomQueryScorer(WeightedSpanTerm[] weightedTerms) {
    super(weightedTerms);
}