File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1+ pr : 124564
2+ summary : Restore `TextSimilarityRankBuilder` XContent output
3+ area : Ranking
4+ type : bug
5+ issues : []
Original file line number Diff line number Diff line change 3030import java .util .List ;
3131import java .util .Objects ;
3232
33+ import static org .elasticsearch .xpack .inference .rank .textsimilarity .TextSimilarityRankRetrieverBuilder .FAILURES_ALLOWED_FIELD ;
34+ import static org .elasticsearch .xpack .inference .rank .textsimilarity .TextSimilarityRankRetrieverBuilder .FIELD_FIELD ;
35+ import static org .elasticsearch .xpack .inference .rank .textsimilarity .TextSimilarityRankRetrieverBuilder .INFERENCE_ID_FIELD ;
36+ import static org .elasticsearch .xpack .inference .rank .textsimilarity .TextSimilarityRankRetrieverBuilder .INFERENCE_TEXT_FIELD ;
37+ import static org .elasticsearch .xpack .inference .rank .textsimilarity .TextSimilarityRankRetrieverBuilder .MIN_SCORE_FIELD ;
38+
3339/**
3440 * A {@code RankBuilder} that enables ranking with text similarity model inference. Supports parameters for configuring the inference call.
3541 */
@@ -103,7 +109,17 @@ public void doWriteTo(StreamOutput out) throws IOException {
103109
104110 @ Override
105111 public void doXContent (XContentBuilder builder , Params params ) throws IOException {
106- throw new UnsupportedOperationException ("This should not be XContent serialized" );
112+ // this object is not parsed, but it sometimes needs to be output as xcontent
113+ // rankWindowSize serialization is handled by the parent class RankBuilder
114+ builder .field (INFERENCE_ID_FIELD .getPreferredName (), inferenceId );
115+ builder .field (INFERENCE_TEXT_FIELD .getPreferredName (), inferenceText );
116+ builder .field (FIELD_FIELD .getPreferredName (), field );
117+ if (minScore != null ) {
118+ builder .field (MIN_SCORE_FIELD .getPreferredName (), minScore );
119+ }
120+ if (failuresAllowed ) {
121+ builder .field (FAILURES_ALLOWED_FIELD .getPreferredName (), true );
122+ }
107123 }
108124
109125 @ Override
You can’t perform that action at this time.
0 commit comments