lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukáš Vlček <lukas.vl...@gmail.com>
Subject Search highlighter for custom Query implementations - how to?
Date Fri, 09 Sep 2011 11:53:51 GMT
Hi,

What is the recommended way to use custom Query implementations with Lucene
(3.3.0) Highlighter framework?

In short, what worries me a bit is the fact
that WeightedSpanTermExtractor#extract(Query, Map<String, WeightedSpanTerm>)
accepts a general Query parameter but inside it does a lot of tests against
particular implementations ( ... if query instanceof BooleanQuery then ... )
with no default option to fall back to. What if I have my own (or
third-party) implementation of Query? Or even with some Lucene built-in
Query types (like BoostingQuery) there is a chance that the extract() method
will silently fall through and does not let me know that this particular
Query implementation is unknown to it.

AFAIK typical use case of Highlighter API can go like this:

Query query = _some_query_instance_;
QueryScorer scorer = new QueryScorer(query, "field"); // query? or
query.rewrite() or ... ?
... etc ...
Highlighter highlighter = new Highlighter(scorer);
... etc ...

Saying this, I am looking for an advice about how to deal with this
Highlighter API correctly so that I do not have to check the source code
of WeightedSpanTermExtractor in advance to learn whether I need to call
rewrite (or other custom method) on the query object or not.

Regards,
Lukas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message