diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/main/java/ai/vespa/client/dsl/Field.java | 66 | ||||
-rw-r--r-- | client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy | 17 |
2 files changed, 83 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 b12ae51787d..05b85a61bc3 100644 --- a/client/src/main/java/ai/vespa/client/dsl/Field.java +++ b/client/src/main/java/ai/vespa/client/dsl/Field.java @@ -396,6 +396,72 @@ public class Field extends QueryChain { return common("range", annotation, l, new Long[]{m}); } + /** + * Equal to query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#numeric + * + * @param t the t + * @return the query + */ + public Query eq(float t) { + return common("=", annotation, t); + } + + /** + * Greater than or equal to query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#numeric + * + * @param t the t + * @return the query + */ + public Query ge(float t) { + return common(">=", annotation, t); + } + + /** + * Greater than query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#numeric + * + * @param t the t + * @return the query + */ + public Query gt(float t) { + return common(">", annotation, t); + } + + /** + * Less than or equal to query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#numeric + * + * @param t the t + * @return the query + */ + public Query le(float t) { + return common("<=", annotation, t); + } + + /** + * Less than query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#numeric + * + * @param t the t + * @return the query + */ + public Query lt(float t) { + return common("<", annotation, t); + } + + /** + * In range query. + * https://docs.vespa.ai/en/reference/query-language-reference.html#numeric + * + * @param l the l + * @param m the m + * @return the query + */ + public Query inRange(float l, float m) { + return common("range", annotation, l, new Float[]{m}); + } /** * Is true query. diff --git a/client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy b/client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy index 3353ef6f827..2f4352879d0 100644 --- a/client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy +++ b/client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy @@ -111,6 +111,23 @@ class QTest extends Specification { q == """yql=select * from sd1 where f1 <= 1L and f2 < 2L and f3 >= 3L and f4 > 4L and f5 = 5L and range(f6, 6L, 7L);""" } + def "float numeric operations"() { + given: + def q = Q.select("*") + .from("sd1") + .where("f1").le(1.1) + .and("f2").lt(2.2) + .and("f3").ge(3.3) + .and("f4").gt(4.4) + .and("f5").eq(5.5) + .and("f6").inRange(6.6, 7.7) + .semicolon() + .build() + + expect: + q == """yql=select * from sd1 where f1 <= 1.1 and f2 < 2.2 and f3 >= 3.3 and f4 > 4.4 and f5 = 5.5 and range(f6, 6.6, 7.7);""" + } + def "nested queries"() { given: def q = Q.select("*") |