Hi all!

I'm trying to do some simple highlighting, but I cannot seem to figure out how 
to make it work.

I'm using my own QueryParser which generates custom made queries. I would like 
Solr to be able to highlight them.

I've tried many options in the highlighter but cannot get any snippets to show.

However, if I change the QueryParser to the default solr parser it works.

There is certainly a place in the config or in the query parser where I can 
specify how Solr can highlight my custom queries?

I checked a bit in the source code, and in WeightedSpanTermExtractor class, in 
the method extract(Query query, Map terms), there is a huge list of 
instanceof's that check which type of query we are attempting to match.

Is that the only place where the conversion between query <-> highlighting 
happens? If so, its looks pretty hard coded and would not work with any other 
queries than the ones included in Lucene.

I guess there must be a good reason for this, but is there any other way of 
making the highlighter work without having to hard code all the possible 
queries in a big if / instanceofs?

If we could somehow reuse the code contained in each query to find possible 
matches, it would avoid having to recode the same logic elsewhere.

But as I said, there must be a good reason for doing it the way its already 
coded.

Any ideas on how to work this out with the existing code base would be greatly 
appreciated :)

Daniel Shane

Reply via email to