Lukas there really isn't any support for custom Query types in Highlighter, as you've found. If you inherit from one of the types it does support, or rewrite your query to one of them, that should work, but the Query class just doesn't provide enough support for Highlighter to work with in the general case. There is work in LUCENE-3318 which could eventually help, but it's a ways away from being committed I think. At least that's my read of the code.

-Mike

On 9/9/2011 7:53 AM, Lukáš Vlček wrote:
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



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to