org.apache.lucene.search.highlight.WeightedSpanTermExtractor Java Examples
The following examples show how to use
org.apache.lucene.search.highlight.WeightedSpanTermExtractor.
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: DefaultSolrHighlighter.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Return a {@link org.apache.lucene.search.highlight.QueryScorer} suitable for this Query and field. * * @param query The current query * @param tokenStream document text tokenStream that implements reset() efficiently (e.g. CachingTokenFilter). * If it's used, call reset() first. * @param fieldName The name of the field * @param request The SolrQueryRequest */ protected QueryScorer getSpanQueryScorer(Query query, String fieldName, TokenStream tokenStream, SolrQueryRequest request) { QueryScorer scorer = new QueryScorer(query, request.getParams().getFieldBool(fieldName, HighlightParams.FIELD_MATCH, false) ? fieldName : null) { @Override protected WeightedSpanTermExtractor newTermExtractor(String defaultField) { return new CustomSpanTermExtractor(defaultField); } }; scorer.setExpandMultiTermQuery(request.getParams().getBool(HighlightParams.HIGHLIGHT_MULTI_TERM, true)); boolean defaultPayloads = true;//overwritten below try { // It'd be nice to know if payloads are on the tokenStream but the presence of the attribute isn't a good // indicator. final Terms terms = request.getSearcher().getSlowAtomicReader().terms(fieldName); if (terms != null) { defaultPayloads = terms.hasPayloads(); } } catch (IOException e) { log.error("Couldn't check for existence of payloads", e); } scorer.setUsePayloads(request.getParams().getFieldBool(fieldName, HighlightParams.PAYLOADS, defaultPayloads)); return scorer; }
Example #2
Source File: CustomQueryScorer.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override protected WeightedSpanTermExtractor newTermExtractor(String defaultField) { return defaultField == null ? new CustomWeightedSpanTermExtractor() : new CustomWeightedSpanTermExtractor(defaultField); }
Example #3
Source File: HighlightCustomQueryTest.java From lucene-solr with Apache License 2.0 | 4 votes |
@Override protected WeightedSpanTermExtractor newTermExtractor(String defaultField) { return defaultField == null ? new MyWeightedSpanTermExtractor() : new MyWeightedSpanTermExtractor(defaultField); }