Re: Solr highlighter and custom queries?
: Actually, its not as much a Solr problem as a Lucene one, as it turns : out, the WeightedSpanTermExtractor is in Lucene and not Solr. : : Why they decided to only highlight queries that are in Lucene I don't : know, but what I did to solve this problem was simply to make my queries : extends a Lucene query instead of just Query. I am not very well informed on highlighting, but as i understand it the Span based Highlighter is specificly designed to deal with position based information that depends on dealing either with SpanQueries or with well known query types where that information can be faked. However, i believe the more traditional highlighter (using QueryTermExtractor) was able to deal with highlighting any query tat implemented extractTerms(Set) so perhaps something about the way you are using the highlighter is triggering the use of WeightedSpanTermExtractor instead of QueryTermExtractor? -Hoss
Solr highlighter and custom queries?
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
Re: Solr highlighter and custom queries?
Actually, its not as much a Solr problem as a Lucene one, as it turns out, the WeightedSpanTermExtractor is in Lucene and not Solr. Why they decided to only highlight queries that are in Lucene I don't know, but what I did to solve this problem was simply to make my queries extends a Lucene query instead of just Query. So I decided to extend a BooleanQuery, which is the closest fit to what mine actually does. This make the highlighting do something even though its not perfect. Daniel Shane