diff options
Diffstat (limited to 'client/src/main/java/ai/vespa/client/dsl/Field.java')
-rw-r--r-- | client/src/main/java/ai/vespa/client/dsl/Field.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/client/src/main/java/ai/vespa/client/dsl/Field.java b/client/src/main/java/ai/vespa/client/dsl/Field.java index 6d199ead2b8..59459899189 100644 --- a/client/src/main/java/ai/vespa/client/dsl/Field.java +++ b/client/src/main/java/ai/vespa/client/dsl/Field.java @@ -571,6 +571,29 @@ public class Field extends QueryChain { return common("nearestNeighbor", annotation, (Object) rankFeature); } + /** + * Fuzzy query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#fuzzy + * + * @param text the text to match fuzzily + * @return the query + */ + public Query fuzzy(String text) { + return common("fuzzy", annotation, text); + } + + /** + * Fuzzy query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#fuzzy + * + * @param annotation the annotation + * @param text the text to match fuzzily + * @return the query + */ + public Query fuzzy(Annotation annotation, String text) { + return common("fuzzy", annotation, text); + } + private Query common(String relation, Annotation annotation, Object value) { return common(relation, annotation, value, values.toArray()); } @@ -629,6 +652,8 @@ public class Field extends QueryChain { return hasAnnotation ? Text.format("([%s]nearestNeighbor(%s, %s))", annotation, fieldName, valuesStr) : Text.format("nearestNeighbor(%s, %s)", fieldName, valuesStr); + case "fuzzy": + return Text.format("%s contains (%sfuzzy(%s))", fieldName, annotation, values.get(0)); default: Object value = values.get(0); valuesStr = value instanceof Long ? value + "L" : value.toString(); |