File tree 2 files changed +22
-1
lines changed
x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity
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 30
30
import java .util .List ;
31
31
import java .util .Objects ;
32
32
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
+
33
39
/**
34
40
* A {@code RankBuilder} that enables ranking with text similarity model inference. Supports parameters for configuring the inference call.
35
41
*/
@@ -103,7 +109,17 @@ public void doWriteTo(StreamOutput out) throws IOException {
103
109
104
110
@ Override
105
111
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
+ }
107
123
}
108
124
109
125
@ Override
You can’t perform that action at this time.
0 commit comments