Skip to content

Remove support for deprecated force_source highlighting parameter #116943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/changelog/116943.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pr: 116943
summary: Remove support for deprecated `force_source` highlighting parameter
area: Highlighting
type: breaking
issues: []
breaking:
title: Remove support for deprecated `force_source` highlighting parameter
area: REST API
details: The deprecated highlighting `force_source` parameter is no longer supported.
impact: Users should remove usages of the `force_source` parameter from their search requests.
notable: false
2 changes: 0 additions & 2 deletions docs/reference/search/search-your-data/highlighting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ fragmenter:: Specifies how text should be broken up in highlight
snippets: `simple` or `span`. Only valid for the `plain` highlighter.
Defaults to `span`.

force_source:: deprecated; this parameter has no effect

`simple`::: Breaks up text into same-sized fragments.
`span`::: Breaks up text into same-sized fragments, but tries to avoid
breaking up text between highlighted terms. This is helpful when you're
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
public static final ParseField TYPE_FIELD = new ParseField("type");
public static final ParseField FRAGMENTER_FIELD = new ParseField("fragmenter");
public static final ParseField NO_MATCH_SIZE_FIELD = new ParseField("no_match_size");
public static final ParseField FORCE_SOURCE_FIELD = new ParseField("force_source").withAllDeprecated();
public static final ParseField PHRASE_LIMIT_FIELD = new ParseField("phrase_limit");
public static final ParseField OPTIONS_FIELD = new ParseField("options");
public static final ParseField HIGHLIGHT_QUERY_FIELD = new ParseField("highlight_query");
Expand Down Expand Up @@ -152,9 +151,6 @@ protected AbstractHighlighterBuilder(StreamInput in) throws IOException {
}
order(in.readOptionalWriteable(Order::readFromStream));
highlightFilter(in.readOptionalBoolean());
if (in.getTransportVersion().before(TransportVersions.V_8_8_0)) {
in.readOptionalBoolean(); // force_source, now deprecated
}
boundaryScannerType(in.readOptionalWriteable(BoundaryScannerType::readFromStream));
boundaryMaxScan(in.readOptionalVInt());
if (in.readBoolean()) {
Expand Down Expand Up @@ -193,9 +189,6 @@ public final void writeTo(StreamOutput out) throws IOException {
}
out.writeOptionalWriteable(order);
out.writeOptionalBoolean(highlightFilter);
if (out.getTransportVersion().before(TransportVersions.V_8_8_0)) {
out.writeOptionalBoolean(false);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not added a new transport version associated with this change. My assumption is that it is not needed given that 9.0 will never communicate with versions previous than 8.last, hence the conditionals under which the flag was read or written are always going to render false.

out.writeOptionalWriteable(boundaryScannerType);
out.writeOptionalVInt(boundaryMaxScan);
boolean hasBounaryChars = boundaryChars != null;
Expand Down Expand Up @@ -674,7 +667,6 @@ static <HB extends AbstractHighlighterBuilder<HB>> BiFunction<XContentParser, HB
parser.declareString(HB::highlighterType, TYPE_FIELD);
parser.declareString(HB::fragmenter, FRAGMENTER_FIELD);
parser.declareInt(HB::noMatchSize, NO_MATCH_SIZE_FIELD);
parser.declareBoolean((builder, value) -> {}, FORCE_SOURCE_FIELD); // force_source is ignored
parser.declareInt(HB::phraseLimit, PHRASE_LIMIT_FIELD);
parser.declareInt(HB::maxAnalyzedOffset, MAX_ANALYZED_OFFSET_FIELD);
parser.declareObject(HB::options, (XContentParser p, Void c) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,17 +607,6 @@ public void testOrderSerialization() throws Exception {
}
}

public void testForceSourceDeprecation() throws IOException {
String highlightJson = """
{ "fields" : { }, "force_source" : true }
""";
try (XContentParser parser = createParser(JsonXContent.jsonXContent, highlightJson)) {
HighlightBuilder.fromXContent(parser);
}

assertWarnings("Deprecated field [force_source] used, this field is unused and will be removed entirely");
}

protected static XContentBuilder toXContent(HighlightBuilder highlight, XContentType contentType) throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
if (randomBoolean()) {
Expand Down