Apache Solr open-source search software
SOLR-15259: hl.fragAlignRatio now defaults to 0.33 (#573)
David Smiley9dee3815edb0
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d2929c72673..1b9b051035c 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -600,6 +600,9 @@ Bug Fixes* SOLR-15919: Replace File with Path for many ZK operations (Mike Drob)++* SOLR-15259: hl.fragAlignRatio now defaults to 0.33 to be faster and maybe looks nicer. (David Smiley)+* SOLR-13138: Removed deprecated hl.method=postings highlighter, deprecated in 7.0. (David Smiley)* SOLR-15944: The Tagger's JSON response format now always uses an object/map to represent each tag instead of andiff --git a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.javaindex 4c562000cbb..8d25d313a29 100644--- a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java+++ b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java@@ -329,7 +329,7 @@ public class UnifiedSolrHighlighter extends SolrHighlighter implements PluginInfreturn baseBI;}- float fragalign = params.getFieldFloat(field, HighlightParams.FRAGALIGNRATIO, 0.5f);+ float fragalign = params.getFieldFloat(field, HighlightParams.FRAGALIGNRATIO, 0.33f);if (params.getFieldBool(field, HighlightParams.FRAGSIZEISMINIMUM, true)) {return LengthGoalBreakIterator.createMinLength(baseBI, fragsize, fragalign);}diff --git a/solr/core/src/test/org/apache/solr/highlight/TestUnifiedSolrHighlighter.java b/solr/core/src/test/org/apache/solr/highlight/TestUnifiedSolrHighlighter.javaindex 3a2a70e5d10..07b6d307856 100644--- a/solr/core/src/test/org/apache/solr/highlight/TestUnifiedSolrHighlighter.java+++ b/solr/core/src/test/org/apache/solr/highlight/TestUnifiedSolrHighlighter.java@@ -246,24 +246,26 @@ public class TestUnifiedSolrHighlighter extends SolrTestCaseJ4 {assertU(adoc("text", "This document contains # special characters, while the other document contains the same # special character.", "id", "103"));assertU(adoc("text", "While the other document contains the same # special character.", "id", "104"));assertU(commit());+ // Set hl.fragAlignRatio because this test was written when it had a middle default+ String[] defParams = {"q", "text:document", "sort", "id asc", "hl", "true", "hl.method", "unified", "hl.bs.type", "SEPARATOR","hl.bs.separator","#", "hl.fragAlignRatio", "0.5"};assertQ("CUSTOM breakiterator",- req("q", "text:document", "sort", "id asc", "hl", "true", "hl.bs.type", "SEPARATOR","hl.bs.separator","#","hl.fragsize", "-1"),+ req(defParams,"hl.fragsize", "-1"),"//lst[@name='highlighting']/lst[@name='103']/arr[@name='text']/str='This <em>document</em> contains #'");assertQ("different breakiterator",- req("q", "text:document", "sort", "id asc", "hl", "true", "hl.bs.type", "SEPARATOR","hl.bs.separator","#","hl.fragsize", "-1"),+ req(defParams,"hl.fragsize", "-1"),"//lst[@name='highlighting']/lst[@name='104']/arr[@name='text']/str='While the other <em>document</em> contains the same #'");assertQ("CUSTOM breakiterator with fragsize 70 minimum",- req("q", "text:document", "sort", "id asc", "hl", "true", "hl.bs.type", "SEPARATOR","hl.bs.separator","#","hl.fragsize", "70", "hl.fragsizeIsMinimum", "true"),+ req(defParams,"hl.fragsize", "70", "hl.fragsizeIsMinimum", "true"),"//lst[@name='highlighting']/lst[@name='103']/arr[@name='text']/str='This <em>document</em> contains # special characters, while the other <em>document</em> contains the same #'");assertQ("CUSTOM breakiterator with fragsize 70 avg",- req("q", "text:document", "sort", "id asc", "hl", "true", "hl.bs.type", "SEPARATOR","hl.bs.separator","#","hl.fragsize", "70", "hl.fragsizeIsMinimum", "false"),+ req(defParams,"hl.fragsize", "70", "hl.fragsizeIsMinimum", "false"),"//lst[@name='highlighting']/lst[@name='103']/arr[@name='text']/str='This <em>document</em> contains #'");assertQ("CUSTOM breakiterator with fragsize 90 avg",- req("q", "text:document", "sort", "id asc", "hl", "true", "hl.bs.type", "SEPARATOR","hl.bs.separator","#","hl.fragsize", "90", "hl.fragsizeIsMinimum", "false"),+ req(defParams,"hl.fragsize", "90", "hl.fragsizeIsMinimum", "false"),"//lst[@name='highlighting']/lst[@name='103']/arr[@name='text']/str='This <em>document</em> contains #'");assertQ("CUSTOM breakiterator with fragsize 100 avg",- req("q", "text:document", "sort", "id asc", "hl", "true", "hl.bs.type", "SEPARATOR","hl.bs.separator","#","hl.fragsize", "100", "hl.fragsizeIsMinimum", "false"),+ req(defParams,"hl.fragsize", "100", "hl.fragsizeIsMinimum", "false"),"//lst[@name='highlighting']/lst[@name='103']/arr[@name='text']/str='This <em>document</em> contains # special characters, while the other <em>document</em> contains the same #'");}@@ -272,17 +274,19 @@ public class TestUnifiedSolrHighlighter extends SolrTestCaseJ4 {clearIndex();assertU(adoc("id", "10", "text", "This is a sentence just under seventy chars in length blah blah. Next sentence is here."));assertU(commit());+ // Set hl.fragAlignRatio because this test was written when it had a middle default+ String[] defParams = {"q", "text:seventy", "hl", "true", "hl.method", "unified", "hl.fragAlignRatio", "0.5"};assertQ("default fragsize",- req("q", "text:seventy", "hl", "true", "hl.fragsizeIsMinimum", "true"),+ req(defParams, "hl.fragsizeIsMinimum", "true"),"//lst[@name='highlighting']/lst[@name='10']/arr[@name='text']/str='This is a sentence just under <em>seventy</em> chars in length blah blah. Next sentence is here.'");assertQ("default fragsize",- req("q", "text:seventy", "hl", "true", "hl.fragsizeIsMinimum", "true", "hl.fragsize", "60"),+ req(defParams, "hl.fragsizeIsMinimum", "true", "hl.fragsize", "60"),"//lst[@name='highlighting']/lst[@name='10']/arr[@name='text']/str='This is a sentence just under <em>seventy</em> chars in length blah blah. '");assertQ("smaller fragsize",- req("q", "text:seventy", "hl", "true", "hl.fragsizeIsMinimum", "false"),+ req(defParams, "hl.fragsizeIsMinimum", "false"),"//lst[@name='highlighting']/lst[@name='10']/arr[@name='text']/str='This is a sentence just under <em>seventy</em> chars in length blah blah. '");assertQ("default fragsize",- req("q", "text:seventy", "hl", "true", "hl.fragsize", "90", "hl.fragsizeIsMinimum", "false"),+ req(defParams, "hl.fragsize", "90", "hl.fragsizeIsMinimum", "false"),"//lst[@name='highlighting']/lst[@name='10']/arr[@name='text']/str='This is a sentence just under <em>seventy</em> chars in length blah blah. Next sentence is here.'");}diff --git a/solr/solr-ref-guide/src/highlighting.adoc b/solr/solr-ref-guide/src/highlighting.adocindex 3306c3fb621..38976d0a8cb 100644--- a/solr/solr-ref-guide/src/highlighting.adoc+++ b/solr/solr-ref-guide/src/highlighting.adoc@@ -359,12 +359,12 @@ The offset source can be explicitly configured to one of: `ANALYSIS`, `POSTINGS`+[%autowidth,frame=none]|===-|Optional |Default: `0.5`+|Optional |Default: `0.33`|===+This parameter influences where the first match (i.e., highlighted text) in a passage is positioned.+-The default value of `0.5` means to align the match to the middle.+The default value of `0.33` means to align the match to the left third.A value of `0.0` means to align the match to the left, while `1.0` to align it to the right.This setting is a best-effort hint, as there are a variety of factors.When there's lots of text to be highlighted, lowering this number can help performance a lot.diff --git a/solr/solr-ref-guide/src/major-changes-in-solr-9.adoc b/solr/solr-ref-guide/src/major-changes-in-solr-9.adocindex 7e9e83a7ccb..17611daf4e8 100644--- a/solr/solr-ref-guide/src/major-changes-in-solr-9.adoc+++ b/solr/solr-ref-guide/src/major-changes-in-solr-9.adoc@@ -155,6 +155,8 @@ Currently this change should only effect compatibility of custom code overriding* SOLR-14510: The `writeStartDocumentList` in `TextResponseWriter` now receives an extra boolean parameter representing the "exactness" of the `numFound` value (exact vs approximation).Any custom response writer extending `TextResponseWriter` will need to implement this abstract method now (instead previous with the same name but without the new boolean parameter).+* SOLR-15259: hl.fragAlignRatio now defaults to 0.33 to be faster and maybe looks nicer.+* SOLR-9376: The response format for field values serialized as raw XML (via the `[xml]` raw value DocTransformerand `wt=xml`) has changed. Previously, values were dropped in directly as top-level child elements of each `<doc>`,obscuring associated field names and yielding inconsistent `<doc>` structure. As of version 9.0, raw values are