@@ -47,6 +47,72 @@ public function ceil(
47
47
return new FunctionExpression ('CEIL ' , [$ value ]);
48
48
}
49
49
50
+ /**
51
+ * Return the cosine similarity between x and y.
52
+ *
53
+ * @link https://www.arangodb.com/docs/stable/aql/functions-numeric.html#cosine_similarity
54
+ *
55
+ * @param array<array<int|float>|int|float>|QueryBuilder|Expression $x
56
+ * @param array<array<int|float>|int|float>|QueryBuilder|Expression $y
57
+ */
58
+ public function cosineSimilarity (
59
+ array |QueryBuilder |Expression $ x ,
60
+ array |QueryBuilder |Expression $ y
61
+ ): FunctionExpression {
62
+ return new FunctionExpression ('COSINE_SIMILARITY ' , [$ x , $ y ]);
63
+ }
64
+
65
+ /**
66
+ * Calculate the score for one or multiple values with a Gaussian function that decays
67
+ * depending on the distance of a numeric value from a user-given origin.
68
+ *
69
+ * @link https://www.arangodb.com/docs/stable/aql/functions-numeric.html#decay_gauss
70
+ *
71
+ * @param array<int|float>|int|float $value
72
+ */
73
+ public function decayGauss (
74
+ array |int |float |QueryBuilder |Expression $ value ,
75
+ int |float |QueryBuilder |Expression $ origin ,
76
+ int |float |QueryBuilder |Expression $ scale ,
77
+ int |float |QueryBuilder |Expression $ offset ,
78
+ int |float |QueryBuilder |Expression $ decay ,
79
+ ): FunctionExpression {
80
+ return new FunctionExpression ('DECAY_GAUSS ' , [$ value , $ origin , $ scale , $ offset , $ decay ]);
81
+ }
82
+
83
+ /**
84
+ * Calculate the score for one or multiple values with an exponential function that decays depending
85
+ * on the distance of a numeric value from a user-given origin.
86
+ *
87
+ * @link https://www.arangodb.com/docs/stable/aql/functions-numeric.html#decay_exp
88
+ */
89
+ public function decayExp (
90
+ int |float |QueryBuilder |Expression $ value ,
91
+ int |float |QueryBuilder |Expression $ origin ,
92
+ int |float |QueryBuilder |Expression $ scale ,
93
+ int |float |QueryBuilder |Expression $ offset ,
94
+ int |float |QueryBuilder |Expression $ decay ,
95
+ ): FunctionExpression {
96
+ return new FunctionExpression ('DECAY_EXP ' , [$ value , $ origin , $ scale , $ offset , $ decay ]);
97
+ }
98
+
99
+ /**
100
+ * Calculate the score for one or multiple values with a linear function that decays depending
101
+ * on the distance of a numeric value from a user-given origin.
102
+ *
103
+ * @link https://www.arangodb.com/docs/stable/aql/functions-numeric.html#decay_linear
104
+ */
105
+ public function decayLinear (
106
+ int |float |QueryBuilder |Expression $ value ,
107
+ int |float |QueryBuilder |Expression $ origin ,
108
+ int |float |QueryBuilder |Expression $ scale ,
109
+ int |float |QueryBuilder |Expression $ offset ,
110
+ int |float |QueryBuilder |Expression $ decay ,
111
+ ): FunctionExpression {
112
+ return new FunctionExpression ('DECAY_LINEAR ' , [$ value , $ origin , $ scale , $ offset , $ decay ]);
113
+ }
114
+
115
+
50
116
/**
51
117
* Return the integer closest but not greater than value.
52
118
*
@@ -58,6 +124,36 @@ public function floor(
58
124
return new FunctionExpression ('FLOOR ' , [$ value ]);
59
125
}
60
126
127
+ /**
128
+ * Return the Manhattan distance between x and y.
129
+ *
130
+ * @link https://www.arangodb.com/docs/stable/aql/functions-numeric.html#l1_distance
131
+ *
132
+ * @param array<array<int|float>|int|float>|QueryBuilder|Expression $x
133
+ * @param array<array<int|float>|int|float>|QueryBuilder|Expression $y
134
+ */
135
+ public function l1Distance (
136
+ array |QueryBuilder |Expression $ x ,
137
+ array |QueryBuilder |Expression $ y
138
+ ): FunctionExpression {
139
+ return new FunctionExpression ('L1_DISTANCE ' , [$ x , $ y ]);
140
+ }
141
+
142
+ /**
143
+ * Return the Euclidean distance between x and y.
144
+ *
145
+ * @link https://www.arangodb.com/docs/stable/aql/functions-numeric.html#l2_distance
146
+ *
147
+ * @param array<array<int|float>|int|float>|QueryBuilder|Expression $x
148
+ * @param array<array<int|float>|int|float>|QueryBuilder|Expression $y
149
+ */
150
+ public function l2Distance (
151
+ array |QueryBuilder |Expression $ x ,
152
+ array |QueryBuilder |Expression $ y
153
+ ): FunctionExpression {
154
+ return new FunctionExpression ('L2_DISTANCE ' , [$ x , $ y ]);
155
+ }
156
+
61
157
/**
62
158
* Return the largest element of an array.
63
159
*
0 commit comments