@@ -55,7 +55,7 @@ public final class HybridQueryBuilder extends AbstractQueryBuilder<HybridQueryBu
55
55
56
56
private final List <QueryBuilder > queries = new ArrayList <>();
57
57
58
- private int paginationDepth ;
58
+ private Integer paginationDepth ;
59
59
60
60
static final int MAX_NUMBER_OF_SUB_QUERIES = 5 ;
61
61
private final static int DEFAULT_PAGINATION_DEPTH = 10 ;
@@ -65,7 +65,7 @@ public HybridQueryBuilder(StreamInput in) throws IOException {
65
65
super (in );
66
66
queries .addAll (readQueries (in ));
67
67
if (isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery ()) {
68
- paginationDepth = in .readInt ();
68
+ paginationDepth = in .readOptionalInt ();
69
69
}
70
70
}
71
71
@@ -78,7 +78,7 @@ public HybridQueryBuilder(StreamInput in) throws IOException {
78
78
protected void doWriteTo (StreamOutput out ) throws IOException {
79
79
writeQueries (out , queries );
80
80
if (isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery ()) {
81
- out .writeInt (paginationDepth );
81
+ out .writeOptionalInt (paginationDepth );
82
82
}
83
83
}
84
84
@@ -109,8 +109,9 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
109
109
queryBuilder .toXContent (builder , params );
110
110
}
111
111
builder .endArray ();
112
- if (isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery ()) {
113
- builder .field (PAGINATION_DEPTH_FIELD .getPreferredName (), paginationDepth == 0 ? DEFAULT_PAGINATION_DEPTH : paginationDepth );
112
+ // TODO https://github.com/opensearch-project/neural-search/issues/1097
113
+ if (Objects .nonNull (paginationDepth )) {
114
+ builder .field (PAGINATION_DEPTH_FIELD .getPreferredName (), paginationDepth );
114
115
}
115
116
printBoostAndQueryName (builder );
116
117
builder .endObject ();
@@ -324,6 +325,9 @@ private Collection<Query> toQueries(Collection<QueryBuilder> queryBuilders, Quer
324
325
}
325
326
326
327
private static void validatePaginationDepth (final int paginationDepth , final QueryShardContext queryShardContext ) {
328
+ if (Objects .isNull (paginationDepth )) {
329
+ return ;
330
+ }
327
331
if (paginationDepth < LOWER_BOUND_OF_PAGINATION_DEPTH ) {
328
332
throw new IllegalArgumentException (
329
333
String .format (Locale .ROOT , "pagination_depth should be greater than %s" , LOWER_BOUND_OF_PAGINATION_DEPTH )
0 commit comments