@@ -162,7 +162,7 @@ public String fieldName() {
162
162
* of query to be equal regardless of whether it was created from XContent or via Java API.
163
163
*/
164
164
public RangeQueryBuilder from (Object from , boolean includeLower ) {
165
- this .from = convertToBytesRefIfString (from );
165
+ this .from = maybeConvertToBytesRef (from );
166
166
this .includeLower = includeLower ;
167
167
return this ;
168
168
}
@@ -178,7 +178,7 @@ public RangeQueryBuilder from(Object from) {
178
178
* Gets the lower range value for this query.
179
179
*/
180
180
public Object from () {
181
- return convertToStringIfBytesRef (this .from );
181
+ return maybeConvertToString (this .from );
182
182
}
183
183
184
184
/**
@@ -199,7 +199,7 @@ public RangeQueryBuilder gte(Object from) {
199
199
* The to part of the range query. Null indicates unbounded.
200
200
*/
201
201
public RangeQueryBuilder to (Object to , boolean includeUpper ) {
202
- this .to = convertToBytesRefIfString (to );
202
+ this .to = maybeConvertToBytesRef (to );
203
203
this .includeUpper = includeUpper ;
204
204
return this ;
205
205
}
@@ -218,7 +218,7 @@ public RangeQueryBuilder to(Object to) {
218
218
* of query to be equal regardless of whether it was created from XContent or via Java API.
219
219
*/
220
220
public Object to () {
221
- return convertToStringIfBytesRef (this .to );
221
+ return maybeConvertToString (this .to );
222
222
}
223
223
224
224
/**
@@ -334,8 +334,8 @@ public RangeQueryBuilder relation(String relation) {
334
334
protected void doXContent (XContentBuilder builder , Params params ) throws IOException {
335
335
builder .startObject (NAME );
336
336
builder .startObject (fieldName );
337
- builder .field (FROM_FIELD .getPreferredName (), convertToStringIfBytesRef (this .from ));
338
- builder .field (TO_FIELD .getPreferredName (), convertToStringIfBytesRef (this .to ));
337
+ builder .field (FROM_FIELD .getPreferredName (), maybeConvertToString (this .from ));
338
+ builder .field (TO_FIELD .getPreferredName (), maybeConvertToString (this .to ));
339
339
builder .field (INCLUDE_LOWER_FIELD .getPreferredName (), includeLower );
340
340
builder .field (INCLUDE_UPPER_FIELD .getPreferredName (), includeUpper );
341
341
if (timeZone != null ) {
@@ -377,26 +377,26 @@ public static RangeQueryBuilder fromXContent(XContentParser parser) throws IOExc
377
377
currentFieldName = parser .currentName ();
378
378
} else {
379
379
if (FROM_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
380
- from = parser .objectBytes ();
380
+ from = maybeConvertToBytesRef ( parser .objectBytes () );
381
381
} else if (TO_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
382
- to = parser .objectBytes ();
382
+ to = maybeConvertToBytesRef ( parser .objectBytes () );
383
383
} else if (INCLUDE_LOWER_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
384
384
includeLower = parser .booleanValue ();
385
385
} else if (INCLUDE_UPPER_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
386
386
includeUpper = parser .booleanValue ();
387
387
} else if (AbstractQueryBuilder .BOOST_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
388
388
boost = parser .floatValue ();
389
389
} else if (GT_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
390
- from = parser .objectBytes ();
390
+ from = maybeConvertToBytesRef ( parser .objectBytes () );
391
391
includeLower = false ;
392
392
} else if (GTE_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
393
- from = parser .objectBytes ();
393
+ from = maybeConvertToBytesRef ( parser .objectBytes () );
394
394
includeLower = true ;
395
395
} else if (LT_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
396
- to = parser .objectBytes ();
396
+ to = maybeConvertToBytesRef ( parser .objectBytes () );
397
397
includeUpper = false ;
398
398
} else if (LTE_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
399
- to = parser .objectBytes ();
399
+ to = maybeConvertToBytesRef ( parser .objectBytes () );
400
400
includeUpper = true ;
401
401
} else if (TIME_ZONE_FIELD .match (currentFieldName , parser .getDeprecationHandler ())) {
402
402
timeZone = parser .text ();
0 commit comments