mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-27 17:10:22 -04:00
Restore TextSimilarityRankBuilder XContent output (#124564)
This commit is contained in:
parent
2187c252b5
commit
d8e889acb6
2 changed files with 22 additions and 1 deletions
5
docs/changelog/124564.yaml
Normal file
5
docs/changelog/124564.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
pr: 124564
|
||||
summary: Restore `TextSimilarityRankBuilder` XContent output
|
||||
area: Ranking
|
||||
type: bug
|
||||
issues: []
|
|
@ -30,6 +30,12 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.elasticsearch.xpack.inference.rank.textsimilarity.TextSimilarityRankRetrieverBuilder.FAILURES_ALLOWED_FIELD;
|
||||
import static org.elasticsearch.xpack.inference.rank.textsimilarity.TextSimilarityRankRetrieverBuilder.FIELD_FIELD;
|
||||
import static org.elasticsearch.xpack.inference.rank.textsimilarity.TextSimilarityRankRetrieverBuilder.INFERENCE_ID_FIELD;
|
||||
import static org.elasticsearch.xpack.inference.rank.textsimilarity.TextSimilarityRankRetrieverBuilder.INFERENCE_TEXT_FIELD;
|
||||
import static org.elasticsearch.xpack.inference.rank.textsimilarity.TextSimilarityRankRetrieverBuilder.MIN_SCORE_FIELD;
|
||||
|
||||
/**
|
||||
* A {@code RankBuilder} that enables ranking with text similarity model inference. Supports parameters for configuring the inference call.
|
||||
*/
|
||||
|
@ -103,7 +109,17 @@ public class TextSimilarityRankBuilder extends RankBuilder {
|
|||
|
||||
@Override
|
||||
public void doXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
throw new UnsupportedOperationException("This should not be XContent serialized");
|
||||
// this object is not parsed, but it sometimes needs to be output as xcontent
|
||||
// rankWindowSize serialization is handled by the parent class RankBuilder
|
||||
builder.field(INFERENCE_ID_FIELD.getPreferredName(), inferenceId);
|
||||
builder.field(INFERENCE_TEXT_FIELD.getPreferredName(), inferenceText);
|
||||
builder.field(FIELD_FIELD.getPreferredName(), field);
|
||||
if (minScore != null) {
|
||||
builder.field(MIN_SCORE_FIELD.getPreferredName(), minScore);
|
||||
}
|
||||
if (failuresAllowed) {
|
||||
builder.field(FAILURES_ALLOWED_FIELD.getPreferredName(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue