|
[
Permlink
| « Hide
]
Mike Klaas added a comment - 29/Apr/08 12:31 AM
Changed to feature request, since the current behaviour is expected. I'd be happy to review a patch to use SpanScorer in Solr, though.
Attaching a base test case document xml to post to the trunk solr example to see the problem.
Steps to reproduce: Expected results: the only highlight snip results returned should be <em>ax bx cx</em> and nothing else. I am playing around with
1) add or 2) to provide I would appreciate any comments on this. Also, since I already test some of this code, I noticed that we still wouldn't get exact behavior from description. For instance, in text ax bx cx dx ax bx for phrase query "ax bx cx" the result is : <span>ax</span><span>bx</span><span>cx</span> dx ax bx Which means that we got a fix for part of the problem (words from unrelated snippets are no longer highlighted), but we still wouldn't get whole phrase highlighted inside single tag. Probably best to create a new ticket (if necessary) about the <span>ax</span> <span>bx</span> instead of <span>ax bx</span> problem. That highlights have incorrect matches is far worse. I'll adjust the problem description.
I made a fix, patch is uploaded.
Old way of highlighting is still retained and will be used in case requests to Solr Highlighter remain the same as they were (same request parameters). New functionality is invoked by adding another request parameter to URL, hl.usePhraseHighlighter=true. So, for URL: results will be the same as they were, but in case you want to use this fix (and have correct phrase highlighting), the URL would look like this: This patch needs latest lucene-highlighter-.jar and lucene-memory-.jar from trunk (since Patch for Solr-553 (uses Lucene-794 highlighting fix)
Patch works for me on the highlighttest.xml. thanks Bojan!!
What do people think of making span highlighting the default behaviour if the query contains phrases? It might be better to have the default behaviour that which people expect, even if it is technically different output from 1.2.
+1 on making it default if there was a phrasequery. The "old" way comes across as a bad bug if you're displaying the highlights for your search results.
+1 for making it the default - it makes more sense than the old HL that highlighted other matching tokens
that were not a part of the given phrase. Added unit test for this fix to the patch.
Added explicit check for usePhraseHighlighter=true to avoid things like usePhraseHighlighter=false to turn it on.
I'll commit shortly, along with a fresh lucene-highlighter-2.4-dev.jar built from from Lucene trunk. just FYI, I've tested this on a much larger/realworld index and it works great.
[quote]Added explicit check for usePhraseHighlighter=true to avoid things like usePhraseHighlighter=false to turn it on.[/quote]
I'm not sure I follow you here. Just to verify:
If this is correct, is there any point in the usePhraseHighlighter parameter? I don't see where it would entail different behaviour. Also, what are the consequences for dismax queries (pure or mixed)? I think there are no pure vs. mixed situation any more. If usePH=true we use SpanScorer otherwise we use QueryScorer, or at least that's how I read the patch.
DefaultSolrHighlighter.java:295-304 if (Boolean.valueOf(req.getParams().get(HighlightParams.USE_PHRASE_HIGHLIGHTER))) { // wrap CachingTokenFilter around TokenStream for reuse tstream = new CachingTokenFilter(tstream); // get highlighter highlighter = getPhraseHighlighter(query, fieldName, req, (CachingTokenFilter) tstream); // after highlighter initialization, reset tstream since construction of highlighter already used it tstream.reset(); } else { // use "the old way" highlighter = getHighlighter(query, fieldName, req); } I'll wait for
>Probably best to create a new ticket (if necessary) about the <span>ax</span> <span>bx</span> instead of <span>ax bx</span> problem. That >highlights have incorrect matches is far worse. I'll adjust the problem description.
If I remember correctly, this was an ease of implementation issue. Part of it was fitting into the current Highlighter framework (individual tokens are scored and highlighted) and part of it was ease in general I think. I am not sure that it would be too easy to alter. It's very easy to do with the new Highlighter I have been working on, the LargeDocHighlighter. It breaks from the current API, and makes this type of highlight markup quite easy. It may never see the light of day though...to do what I want, all parts of the query need to be located with the MemoryIndex, and the time this takes on non position sensitive queries clauses is almost equal to the savings I get from not iterating through and scoring each token in a TokenStream. I do still have hopes I can pull something off though, and it may end up being useful for something else. For now though, Highlighting each each token seems a small inconvenience to retain all the old Highlighters tests, corner cases, and speed in non position sensitive scoring. Thats not to say there will not be a way if you take a look at the code though. Thanks Bojan.
Committed revision 659664. Needs new Lucene jars, per the earlier comments. Build is currently broken.
Otis,
Here's a patch that fixes the Spell Checker test that gets broken when you upgrade the Lucene jars. Just to point out, as I am not sure its clear, the SpanScorer is just as fast as the old Scorer when no Phrase's, or Span's are in the query. Mark H actually tested it as slightly faster, though thats a bit odd.
When there is a Span or Phrase, none Span/Phrase clauses of the Query are still highlighted the same and at the same speed as the original Scorer...it is just the Span/Phrase clauses that fire up a MemoryIndex and have getSpans called against it. So you really only pay for the extra position sensitive part where actually needed. I committed the new JARs and fixed the SpellChecker test
If I understood Mark correctly, he is saying we can just have usePhraseHighlighter=true
be the default and it won't hurt performance. Should we do that, and allow one to get the old behaviour with usePhraseHighlighter=false if they really prefer the old highlighting? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||