This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 9dee381  SOLR-15259: hl.fragAlignRatio now defaults to 0.33 (#573)
9dee381 is described below

commit 9dee3815edb07de3081a4d6f9f558e00c5adc6f6
Author: David Smiley <[email protected]>
AuthorDate: Sat Feb 5 16:42:55 2022 -0500

    SOLR-15259: hl.fragAlignRatio now defaults to 0.33 (#573)
    
    to be faster and maybe looks nicer.
---
 solr/CHANGES.txt                                   |  3 +++
 .../solr/highlight/UnifiedSolrHighlighter.java     |  2 +-
 .../solr/highlight/TestUnifiedSolrHighlighter.java | 24 +++++++++++++---------
 solr/solr-ref-guide/src/highlighting.adoc          |  4 ++--
 .../src/major-changes-in-solr-9.adoc               |  2 ++
 5 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d2929c7..1b9b051 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 an
diff --git 
a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java 
b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
index 4c56200..8d25d31 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 PluginInf
         return 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.java
index 3a2a70e..07b6d30 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.adoc
index 3306c3f..38976d0 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.adoc
index 7e9e83a..17611da 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 DocTransformer
 and `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

Reply via email to