aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryehzu <yehzu2@gmail.com>2021-02-18 17:00:06 +0800
committerTzu-Hui <tzuhuiy@verizonmedia.com>2021-02-18 17:12:07 +0800
commitbe59248995dcc4c18b2e1e35e5a8bdd636bc8137 (patch)
tree2533d4960f87a794ed0e3ccd4527b6b8b7ae4c10
parentd289e5b8fdfcf5472a2953675994fffe310c469d (diff)
support numberic operation for float
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/Field.java66
-rw-r--r--client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy17
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("*")