Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,9 @@ private Optional<String> getDocumentScoreField(List<java.lang.reflect.Field> all

private boolean isAnnotationPreset(java.lang.reflect.Field idField, List<SchemaField> fields) {
return (!idField.isAnnotationPresent(Indexed.class) && !idField.isAnnotationPresent(Searchable.class) && !idField
.isAnnotationPresent(TagIndexed.class) && !idField.isAnnotationPresent(TextIndexed.class) && (fields.stream()
.noneMatch(f -> f.getName().equals(idField.getName()))));
.isAnnotationPresent(TagIndexed.class) && !idField.isAnnotationPresent(TextIndexed.class) && !idField
.isAnnotationPresent(NumericIndexed.class) && (fields.stream().noneMatch(f -> f.getName().equals(idField
.getName()))));
}

private List<SearchField> createIndexedFieldsForIdFields(Class<?> cl, List<SchemaField> fields, boolean isDocument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ public enum QueryClause {
NUMERIC_BETWEEN( //
QueryClauseTemplate.of(FieldType.NUMERIC, Part.Type.BETWEEN, QueryClause.FIELD_NUMERIC_BETWEEN, 2) //
),
/**
* Numeric field query clause for range matching.
* Matches numeric fields that are equal to any of the specified values.
*/
NUMERIC_IN( //
QueryClauseTemplate.of(FieldType.NUMERIC, Part.Type.IN, QueryClause.FIELD_EQUAL, 1) //
),
/**
* Numeric field query clause for negated membership testing.
* Matches numeric fields that are not equal to any of the specified values.
*/
NUMERIC_NOT_IN( //
QueryClauseTemplate.of(FieldType.NUMERIC, Part.Type.NOT_IN, QueryClause.FIELD_EQUAL, 1) //
),
/**
* Numeric field query clause for "less than" comparisons.
* Matches numeric fields whose values are less than the specified value.
Expand Down Expand Up @@ -569,31 +583,40 @@ public String prepareQuery(String field, Object... params) {
if (this == QueryClause.TAG_CONTAINING_ALL) {
value = c.stream().map(n -> "@" + field + ":{" + QueryUtils.escape(ObjectUtils.asString(n,
converter)) + "}").collect(Collectors.joining(" "));
prepared = prepared.replace(PARAM_PREFIX + i++, value);
} else if (this == QueryClause.NUMERIC_CONTAINING) {
value = c.stream().map(n -> "@" + field + ":[" + QueryUtils.escape(ObjectUtils.asString(n,
converter)) + " " + QueryUtils.escape(ObjectUtils.asString(n, converter)) + "]").collect(Collectors
.joining("|"));
prepared = prepared.replace(PARAM_PREFIX + i++, value);
} else if (this == QueryClause.NUMERIC_IN) {
value = c.stream().map(n -> "@" + field + ":[" + QueryUtils.escape(ObjectUtils.asString(n,
converter)) + " " + QueryUtils.escape(ObjectUtils.asString(n, converter)) + "]").collect(Collectors
.joining("|"));
prepared = value;
} else if (this == QueryClause.NUMERIC_CONTAINING_ALL) {
value = c.stream().map(n -> "@" + field + ":[" + QueryUtils.escape(ObjectUtils.asString(n,
converter)) + " " + QueryUtils.escape(ObjectUtils.asString(n, converter)) + "]").collect(Collectors
.joining(" "));
prepared = prepared.replace(PARAM_PREFIX + i++, value);
} else if (this == QueryClause.GEO_CONTAINING) {
value = c.stream().map(n -> {
Point p = (Point) n;
return "@" + field + ":[" + p.getX() + " " + p.getY() + " .000001 ft]";
}).collect(Collectors.joining("|"));
prepared = prepared.replace(PARAM_PREFIX + i++, value);
} else if (this == QueryClause.GEO_CONTAINING_ALL) {
value = c.stream().map(n -> {
Point p = (Point) n;
return "@" + field + ":[" + p.getX() + " " + p.getY() + " .000001 ft]";
}).collect(Collectors.joining(" "));
prepared = prepared.replace(PARAM_PREFIX + i++, value);
} else {
value = c.stream()//
.map(n -> QueryUtils.escape(ObjectUtils.asString(n, converter), false)).collect(Collectors.joining(
"|"));
prepared = prepared.replace(PARAM_PREFIX + i++, value);
}

prepared = prepared.replace(PARAM_PREFIX + i++, value);
} else {
if (clauseTemplate.getIndexType() == FieldType.TEXT) {
prepared = prepared.replace(PARAM_PREFIX + i++, param.toString());
Expand Down