Skip to content

Commit

Permalink
Adds a new parameter, max_analyzer_offset, for the highlighter (#3893)
Browse files Browse the repository at this point in the history
* #3842 adds a new parameter to the highlighter, the max_analyzer_offset. When this parameter is provided the highlight stops in its value. This prevents the highlighter to go beyond the index maxAnalyzedOffset.

Signed-off-by: Hauck <[email protected]>

* Adds a test for the new parameter

Signed-off-by: Hauck <[email protected]>

* Fix the test add in the previous commit;

Signed-off-by: Hauck <[email protected]>

* This was checking against the wrong field

Signed-off-by: Hauck <[email protected]>

* Only runs the test for the correct version

Signed-off-by: Hauck <[email protected]>

* Skips the test in Elasticsearch as well;

Signed-off-by: Hauck <[email protected]>

* Remove elastic 3.0 to test

Signed-off-by: Hauck <[email protected]>

* Skips all versions

Signed-off-by: Hauck <[email protected]>

* Remove unnecessary fields as pointed by @reta

Signed-off-by: Hauck <[email protected]>

* Compute if fieldMaxAnalyzedIsNotValid in the constructor as suggest by @reta

Signed-off-by: Hauck <[email protected]>

* As discussed, it is better to throws different exceptions for when the fieldMaxAnalyzed is not valid and for when it is disabled;

Signed-off-by: Hauck <[email protected]>

* hint what to do to allow highlight of bigger documents
Signed-off-by: Hauck <[email protected]>

* Let the user define the new parameter globally for all fields highlighted

Signed-off-by: Hauck <[email protected]>

* Change the  fieldMaxAnalyzedOffset Integer in order to use null when it is absent in highlight. This allows the error messages to much more precise, showing invalid for all negative numbers;

Signed-off-by: Hauck <[email protected]>

* Update javadocs and implements the stream methods for the new fields;

Signed-off-by: Hauck <[email protected]>

* builder.field do not accept null, so check before calling the method is necessary

Signed-off-by: Hauck <[email protected]>

* Only send and read the new fields if the version supports it

Signed-off-by: Hauck <[email protected]>

* the previous commit was checking the wrong field

Signed-off-by: Hauck <[email protected]>

* Check for version 3.0.0 instead of current version

Signed-off-by: Hauck <[email protected]>

* Update server/src/main/java/org/apache/lucene/search/uhighlight/CustomUnifiedHighlighter.java

Co-authored-by: Andriy Redko <[email protected]>
Signed-off-by: Hauck <[email protected]>

* Execute the test after version 3.0.0

Signed-off-by: Hauck <[email protected]>

Co-authored-by: Andriy Redko <[email protected]>
(cherry picked from commit 931813f)
  • Loading branch information
hauck-jvsh authored and dblock committed Nov 8, 2022
1 parent 93a7640 commit d2c3e77
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ public final void writeTo(StreamOutput out) throws IOException {
out.writeMap(options);
}
out.writeOptionalBoolean(requireFieldMatch);
<<<<<<< HEAD
if (out.getVersion().onOrAfter(Version.V_2_2_0)) {
=======
if (out.getVersion().onOrAfter(Version.V_3_0_0)) {
>>>>>>> Adds a new parameter, max_analyzer_offset, for the highlighter (#3893)
out.writeOptionalVInt(maxAnalyzerOffset);
}
doWriteTo(out);
Expand Down

0 comments on commit d2c3e77

Please sign in to comment.