Search in sources :

Example 1 with WeightedSpanTerm

use of org.apache.lucene.search.highlight.WeightedSpanTerm in project lucene-solr by apache.

the class HighlightCustomQueryTest method testHighlightKnownQuery.

public void testHighlightKnownQuery() throws IOException {
    WeightedSpanTermExtractor extractor = new WeightedSpanTermExtractor() {

        @Override
        protected void extractUnknownQuery(Query query, Map<String, WeightedSpanTerm> terms) throws IOException {
            terms.put("foo", new WeightedSpanTerm(3, "foo"));
        }
    };
    Map<String, WeightedSpanTerm> terms = extractor.getWeightedSpanTerms(new TermQuery(new Term("bar", "quux")), 3, new CannedTokenStream());
    // no foo
    assertEquals(Collections.singleton("quux"), terms.keySet());
}
Also used : TermQuery(org.apache.lucene.search.TermQuery) Query(org.apache.lucene.search.Query) TermQuery(org.apache.lucene.search.TermQuery) BoostQuery(org.apache.lucene.search.BoostQuery) WeightedSpanTerm(org.apache.lucene.search.highlight.WeightedSpanTerm) WeightedSpanTermExtractor(org.apache.lucene.search.highlight.WeightedSpanTermExtractor) Term(org.apache.lucene.index.Term) WeightedSpanTerm(org.apache.lucene.search.highlight.WeightedSpanTerm) CannedTokenStream(org.apache.lucene.analysis.CannedTokenStream) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 CannedTokenStream (org.apache.lucene.analysis.CannedTokenStream)1 Term (org.apache.lucene.index.Term)1 BoostQuery (org.apache.lucene.search.BoostQuery)1 Query (org.apache.lucene.search.Query)1 TermQuery (org.apache.lucene.search.TermQuery)1 WeightedSpanTerm (org.apache.lucene.search.highlight.WeightedSpanTerm)1 WeightedSpanTermExtractor (org.apache.lucene.search.highlight.WeightedSpanTermExtractor)1