aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryehzu <yehzu2@gmail.com>2021-02-18 17:04:53 +0800
committerTzu-Hui <tzuhuiy@verizonmedia.com>2021-02-18 17:12:17 +0800
commit89a254471faabf1e86046a73ffe8606f36ec9de8 (patch)
tree1c950aabaf4e70f5a9786480e439774ce8015941
parentbe59248995dcc4c18b2e1e35e5a8bdd636bc8137 (diff)
support numberic operation for double
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/Field.java67
-rw-r--r--client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy17
2 files changed, 84 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 05b85a61bc3..c540e844c7a 100644
--- a/client/src/main/java/ai/vespa/client/dsl/Field.java
+++ b/client/src/main/java/ai/vespa/client/dsl/Field.java
@@ -403,6 +403,73 @@ public class Field extends QueryChain {
* @param t the t
* @return the query
*/
+ public Query eq(double 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(double 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(double 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(double 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(double 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(double l, double m) {
+ return common("range", annotation, l, new Double[]{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);
}
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 2f4352879d0..671405a9c73 100644
--- a/client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy
+++ b/client/src/test/groovy/ai/vespa/client/dsl/QTest.groovy
@@ -128,6 +128,23 @@ class QTest extends Specification {
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 "double numeric operations"() {
+ given:
+ def q = Q.select("*")
+ .from("sd1")
+ .where("f1").le(1.1D)
+ .and("f2").lt(2.2D)
+ .and("f3").ge(3.3D)
+ .and("f4").gt(4.4D)
+ .and("f5").eq(5.5D)
+ .and("f6").inRange(6.6D, 7.7D)
+ .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("*")