Search in sources :

Example 1 with AveragePayloadFunction

use of org.apache.lucene.queries.payloads.AveragePayloadFunction in project lucene-solr by apache.

the class BoostingTermBuilder method getSpanQuery.

@Override
public SpanQuery getSpanQuery(Element e) throws ParserException {
    String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");
    String value = DOMUtils.getNonBlankTextOrFail(e);
    SpanQuery btq = new PayloadScoreQuery(new SpanTermQuery(new Term(fieldName, value)), new AveragePayloadFunction());
    btq = new SpanBoostQuery(btq, DOMUtils.getAttribute(e, "boost", 1.0f));
    return btq;
}
Also used : SpanTermQuery(org.apache.lucene.search.spans.SpanTermQuery) SpanBoostQuery(org.apache.lucene.search.spans.SpanBoostQuery) Term(org.apache.lucene.index.Term) AveragePayloadFunction(org.apache.lucene.queries.payloads.AveragePayloadFunction) SpanQuery(org.apache.lucene.search.spans.SpanQuery) PayloadScoreQuery(org.apache.lucene.queries.payloads.PayloadScoreQuery)

Aggregations

Term (org.apache.lucene.index.Term)1 AveragePayloadFunction (org.apache.lucene.queries.payloads.AveragePayloadFunction)1 PayloadScoreQuery (org.apache.lucene.queries.payloads.PayloadScoreQuery)1 SpanBoostQuery (org.apache.lucene.search.spans.SpanBoostQuery)1 SpanQuery (org.apache.lucene.search.spans.SpanQuery)1 SpanTermQuery (org.apache.lucene.search.spans.SpanTermQuery)1