private SliceBuilder setField(String field) { if (Strings.isEmpty(field)) { throw new IllegalArgumentException("field name is null or empty"); } this.field = field; return this; }
/** * A Query that matches documents within an range of terms. * * @param fieldName The field name */ public RangeQueryBuilder(String fieldName) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("field name is null or empty"); } this.fieldName = fieldName; }
private CollapseBuilder setField(String field) { if (Strings.isEmpty(field)) { throw new IllegalArgumentException("field name is null or empty"); } this.field = field; return this; }
public ExistsQueryBuilder(String fieldName) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("field name is null or empty"); } this.fieldName = fieldName; }
/** * Construct new GeoDistanceQueryBuilder. * @param fieldName name of indexed geo field to operate distance computation on. * */ public GeoDistanceQueryBuilder(String fieldName) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("fieldName must not be null or empty"); } this.fieldName = fieldName; }
/** * Constructs a new SpanGapQueryBuilder term query. * * @param fieldName The name of the field * @param width The width of the gap introduced */ public SpanGapQueryBuilder(String fieldName, int width) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("[span_gap] field name is null or empty"); } //lucene has not coded any restriction on value of width. //to-do : find if theoretically it makes sense to apply restrictions. this.fieldName = fieldName; this.width = width; }
/** Add a field to run the query against. */ public SimpleQueryStringBuilder field(String field) { if (Strings.isEmpty(field)) { throw new IllegalArgumentException("supplied field is null or empty"); } this.fieldsAndWeights.put(field, AbstractQueryBuilder.DEFAULT_BOOST); return this; }
/** * Adds a field to run the multi match against. */ public MultiMatchQueryBuilder field(String field) { if (Strings.isEmpty(field)) { throw new IllegalArgumentException("supplied field is null or empty."); } this.fieldsBoosts.put(field, AbstractQueryBuilder.DEFAULT_BOOST); return this; }
/** Add a field to run the query against with a specific boost. */ public SimpleQueryStringBuilder field(String field, float boost) { if (Strings.isEmpty(field)) { throw new IllegalArgumentException("supplied field is null or empty"); } this.fieldsAndWeights.put(field, boost); return this; }
/** * Creates a query builder given a query provided as a string */ public WrapperQueryBuilder(String source) { if (Strings.isEmpty(source)) { throw new IllegalArgumentException("query source string cannot be null or empty"); } this.source = source.getBytes(StandardCharsets.UTF_8); }
public static void arrayToDelimitedString(Object[] arr, String delim, StringBuilder sb) { if (isEmpty(arr)) { return; } for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(delim); } sb.append(arr[i]); } }
public MatchPhraseQueryBuilder(String fieldName, Object value) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("[" + NAME + "] requires fieldName"); } if (value == null) { throw new IllegalArgumentException("[" + NAME + "] requires query value"); } this.fieldName = fieldName; this.value = value; }
/** * Adds a field to run the multi match against with a specific boost. */ public MultiMatchQueryBuilder field(String field, float boost) { if (Strings.isEmpty(field)) { throw new IllegalArgumentException("supplied field is null or empty."); } this.fieldsBoosts.put(field, boost); return this; }
/** * Constructs a new common terms query. */ public CommonTermsQueryBuilder(String fieldName, Object text) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("field name is null or empty"); } if (text == null) { throw new IllegalArgumentException("text cannot be null"); } this.fieldName = fieldName; this.text = text; }
/** * Constructs a new regex query. * * @param fieldName The name of the field * @param value The regular expression */ public RegexpQueryBuilder(String fieldName, String value) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("field name is null or empty"); } if (value == null) { throw new IllegalArgumentException("value cannot be null"); } this.fieldName = fieldName; this.value = value; }
/** * Constructs a new {@link FieldMaskingSpanQueryBuilder} given an inner {@link SpanQueryBuilder} for * a given field * @param queryBuilder inner {@link SpanQueryBuilder} * @param fieldName the field name */ public FieldMaskingSpanQueryBuilder(SpanQueryBuilder queryBuilder, String fieldName) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("field name is null or empty"); } if (queryBuilder == null) { throw new IllegalArgumentException("inner clause [query] cannot be null."); } this.queryBuilder = queryBuilder; this.fieldName = fieldName; }
/** Sets the center point for this query. */ public GeoDistanceQueryBuilder geohash(String geohash) { if (Strings.isEmpty(geohash)) { throw new IllegalArgumentException("geohash must not be null or empty"); } this.center.resetFromGeoHash(geohash); return this; }
/** Sets the distance from the center for this query. */ public GeoDistanceQueryBuilder distance(String distance, DistanceUnit unit) { if (Strings.isEmpty(distance)) { throw new IllegalArgumentException("distance must not be null or empty"); } if (unit == null) { throw new IllegalArgumentException("distance unit must not be null"); } double newDistance = DistanceUnit.parse(distance, unit, DistanceUnit.DEFAULT); if (newDistance <= 0.0) { throw new IllegalArgumentException("distance must be greater than zero"); } this.distance = newDistance; return this; }
/** * Constructs a new fuzzy query. * * @param fieldName The name of the field * @param value The value of the term */ public FuzzyQueryBuilder(String fieldName, Object value) { if (Strings.isEmpty(fieldName)) { throw new IllegalArgumentException("field name cannot be null or empty"); } if (value == null) { throw new IllegalArgumentException("query value cannot be null"); } this.fieldName = fieldName; this.value = maybeConvertToBytesRef(value); }
@Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = super.validateNonNullIndex(); if (Strings.isEmpty(type)) { validationException = addValidationError("type is missing", validationException); } if (Strings.isEmpty(id)) { validationException = addValidationError("id is missing", validationException); } if (query == null) { validationException = ValidateActions.addValidationError("query is missing", validationException); } return validationException; }