SOLR-6692: When using hl.maxMultiValuedToMatch with hl.preserveMulti, only count matched snippets.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1673216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2015-04-13 14:53:56 +00:00
parent c12f09faaf
commit 414b1ea098
3 changed files with 22 additions and 11 deletions

View File

@ -131,7 +131,9 @@ Other Changes
* SOLR-6692: Default highlighter changes:
- hl.maxAnalyzedChars now applies cumulatively on a multi-valied field.
- fragment ranking on a multi-valued field should be more relevant.
- Much more extensible.
- hl.usePhraseHighlighter is now toggleable on a per-field basis.
- Much more extensible (get values from another source; return snippet scores and offsets).
- When using hl.maxMultiValuedToMatch with hl.preserveMulti, only count matched snippets.
(David Smiley)
================== 5.1.0 ==================

View File

@ -549,6 +549,7 @@ public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInf
// normally we want a score (must be highlighted), but if preserveMulti then we return a snippet regardless.
if (bestTextFragment.getScore() > 0 || preserveMulti) {
frags.add(bestTextFragment);
if (bestTextFragment.getScore() > 0)
--mvToMatch; // note: limits fragments (for multi-valued fields), not quite the number of values
}
}

View File

@ -933,7 +933,7 @@ public class HighlighterTest extends SolrTestCaseJ4 {
assertU(commit());
// First insure we can count all six
// First ensure we can count all six
assertQ("Counting all MV pairs failed",
req(
"q", "id:1000",
@ -946,6 +946,7 @@ public class HighlighterTest extends SolrTestCaseJ4 {
);
// NOTE: These tests seem repeated, but we're testing for off-by-one errors
// Now we should see exactly 2 by limiting the number of values searched to 4
assertQ("Off by one by going too far",
req(
@ -959,7 +960,6 @@ public class HighlighterTest extends SolrTestCaseJ4 {
"//lst[@name='highlighting']/lst[@name='1000']/arr[@name='lower' and count(*)=2]"
);
// Does 0 work?
assertQ("Off by one by going too far",
req(
@ -973,7 +973,6 @@ public class HighlighterTest extends SolrTestCaseJ4 {
"//lst[@name='highlighting']/lst[@name='1000' and count(child::*) = 0]"
);
// Now we should see exactly 2 by limiting the number of values searched to 2
assertQ("Off by one by not going far enough",
req(
@ -987,7 +986,6 @@ public class HighlighterTest extends SolrTestCaseJ4 {
"//lst[@name='highlighting']/lst[@name='1000']/arr[@name='lower' and count(*)=2]"
);
// Now we should see exactly 1 by limiting the number of values searched to 1
assertQ("Not counting exactly 1",
req(
@ -1001,7 +999,6 @@ public class HighlighterTest extends SolrTestCaseJ4 {
"//lst[@name='highlighting']/lst[@name='1000']/arr[@name='lower' and count(*)=1]"
);
// Now we should see exactly 4 by limiting the number of values found to 4
assertQ("Matching 4 should exactly match 4",
req(
@ -1015,6 +1012,19 @@ public class HighlighterTest extends SolrTestCaseJ4 {
"//lst[@name='highlighting']/lst[@name='1000']/arr[@name='lower' and count(*)=4]"
);
// But if hl.preserveMulti=true then we should see 6 snippets even though 2 didn't match
assertQ("hl.preserveMulti",
req(
"q", "id:1000",
HighlightParams.HIGHLIGHT, "true",
HighlightParams.FIELDS, "lower",
HighlightParams.Q, "target",
HighlightParams.SNIPPETS, "100",
HighlightParams.MAX_MULTIVALUED_TO_MATCH, "4",
HighlightParams.PRESERVE_MULTI, "true"
),
"//lst[@name='highlighting']/lst[@name='1000']/arr[@name='lower' and count(*)=6]"
);
// Now we should see exactly 2 by limiting the number of values found to 2
assertQ("Matching 6 should exactly search them all",
@ -1029,7 +1039,6 @@ public class HighlighterTest extends SolrTestCaseJ4 {
"//lst[@name='highlighting']/lst[@name='1000']/arr[@name='lower' and count(*)=6]"
);
// Now we should see exactly 1 by limiting the number of values found to 1
assertQ("Matching 6 should exactly match them all",
req(
@ -1057,7 +1066,6 @@ public class HighlighterTest extends SolrTestCaseJ4 {
);
// Should bail at the first parameter matched.
assertQ("Matching 6 should exactly match them all",
req(