|
| 1 | +/* |
| 2 | + * Copyright (c) 2024 MarkLogic Corporation |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.marklogic.client.expression; |
| 18 | + |
| 19 | +import com.marklogic.client.type.XsAnyAtomicTypeSeqVal; |
| 20 | +import com.marklogic.client.type.XsDoubleVal; |
| 21 | +import com.marklogic.client.type.XsFloatVal; |
| 22 | +import com.marklogic.client.type.XsStringVal; |
| 23 | +import com.marklogic.client.type.XsUnsignedIntVal; |
| 24 | + |
| 25 | +import com.marklogic.client.type.ServerExpression; |
| 26 | + |
| 27 | +// IMPORTANT: Do not edit. This file is generated. |
| 28 | + |
| 29 | +/** |
| 30 | + * Builds expressions to call functions in the vec server library for a row |
| 31 | + * pipeline. |
| 32 | + */ |
| 33 | +public interface VecExpr { |
| 34 | + public ServerExpression add(ServerExpression vector1, ServerExpression vector2); |
| 35 | +/** |
| 36 | + * Constructs a vector result by decoding the base64 binary input. |
| 37 | + * |
| 38 | + * <a name="ml-server-type-base64-decode"></a> |
| 39 | + |
| 40 | + * <p> |
| 41 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:base64-decode" target="mlserverdoc">vec:base64-decode</a> server function. |
| 42 | + * @param base64Vector The base64 binary encoded string vector to decode. (of <a href="{@docRoot}/doc-files/types/xs_string.html">xs:string</a>) |
| 43 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type |
| 44 | + */ |
| 45 | + public ServerExpression base64Decode(ServerExpression base64Vector); |
| 46 | +/** |
| 47 | + * Returns the base64 encoding of the vector. Useful for compressing a high-dimensional float vector represented as a string into fewer characters. |
| 48 | + * |
| 49 | + * <a name="ml-server-type-base64-encode"></a> |
| 50 | + |
| 51 | + * <p> |
| 52 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:base64-encode" target="mlserverdoc">vec:base64-encode</a> server function. |
| 53 | + * @param vector1 The vector to base64 encode. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 54 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_string.html">xs:string</a> server data type |
| 55 | + */ |
| 56 | + public ServerExpression base64Encode(ServerExpression vector1); |
| 57 | +/** |
| 58 | + * Returns the cosine similarity between two vectors. The vectors must be of the same dimension. |
| 59 | + * |
| 60 | + * <a name="ml-server-type-cosine-similarity"></a> |
| 61 | + |
| 62 | + * <p> |
| 63 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:cosine-similarity" target="mlserverdoc">vec:cosine-similarity</a> server function. |
| 64 | + * @param vector1 The vector from which to calculate the cosine similarity with vector2. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 65 | + * @param vector2 The vector from which to calculate the cosine similarity with vector1. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 66 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type |
| 67 | + */ |
| 68 | + public ServerExpression cosineSimilarity(ServerExpression vector1, ServerExpression vector2); |
| 69 | +/** |
| 70 | + * Returns the dimension of the vector passed in. |
| 71 | + * |
| 72 | + * <a name="ml-server-type-dimension"></a> |
| 73 | + |
| 74 | + * <p> |
| 75 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:dimension" target="mlserverdoc">vec:dimension</a> server function. |
| 76 | + * @param vector1 The vector to find the dimension of. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 77 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type |
| 78 | + */ |
| 79 | + public ServerExpression dimension(ServerExpression vector1); |
| 80 | +/** |
| 81 | + * Returns the dot product between two vectors. The vectors must be of the same dimension. Use this function to calculate similarity between vectors if you are certain they are both of magnitude 1. |
| 82 | + * |
| 83 | + * <a name="ml-server-type-dot-product"></a> |
| 84 | + |
| 85 | + * <p> |
| 86 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:dot-product" target="mlserverdoc">vec:dot-product</a> server function. |
| 87 | + * @param vector1 The vector from which to calculate the dot product with vector2. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 88 | + * @param vector2 The vector from which to calculate the dot product with vector1. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 89 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type |
| 90 | + */ |
| 91 | + public ServerExpression dotProduct(ServerExpression vector1, ServerExpression vector2); |
| 92 | +/** |
| 93 | + * Returns the Euclidean distance between two vectors. The vectors must be of the same dimension. |
| 94 | + * |
| 95 | + * <a name="ml-server-type-euclidean-distance"></a> |
| 96 | + |
| 97 | + * <p> |
| 98 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:euclidean-distance" target="mlserverdoc">vec:euclidean-distance</a> server function. |
| 99 | + * @param vector1 The vector from which to calculate the Euclidean distance to vector2. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 100 | + * @param vector2 The vector from which to calculate the Euclidean distance to vector1. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 101 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type |
| 102 | + */ |
| 103 | + public ServerExpression euclideanDistance(ServerExpression vector1, ServerExpression vector2); |
| 104 | +/** |
| 105 | + * Returns the element at the k-th index of the vector. |
| 106 | + * |
| 107 | + * <a name="ml-server-type-get"></a> |
| 108 | + |
| 109 | + * <p> |
| 110 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:get" target="mlserverdoc">vec:get</a> server function. |
| 111 | + * @param vector1 The vector to grab the k-th element of. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 112 | + * @param k The zero-based index of vector1 to return. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 113 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_float.html">xs:float</a> server data type |
| 114 | + */ |
| 115 | + public ServerExpression get(ServerExpression vector1, ServerExpression k); |
| 116 | +/** |
| 117 | + * Returns the magnitude of the vector. |
| 118 | + * |
| 119 | + * <a name="ml-server-type-magnitude"></a> |
| 120 | + |
| 121 | + * <p> |
| 122 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:magnitude" target="mlserverdoc">vec:magnitude</a> server function. |
| 123 | + * @param vector1 The vector to find the magnitude of. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 124 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a> server data type |
| 125 | + */ |
| 126 | + public ServerExpression magnitude(ServerExpression vector1); |
| 127 | +/** |
| 128 | + * Returns the vector passed in, normalized to a length of 1. |
| 129 | + * |
| 130 | + * <a name="ml-server-type-normalize"></a> |
| 131 | + |
| 132 | + * <p> |
| 133 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:normalize" target="mlserverdoc">vec:normalize</a> server function. |
| 134 | + * @param vector1 The vector to normalize. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 135 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type |
| 136 | + */ |
| 137 | + public ServerExpression normalize(ServerExpression vector1); |
| 138 | +public ServerExpression subtract(ServerExpression vector1, ServerExpression vector2); |
| 139 | +/** |
| 140 | + * Returns a subvector of the input vector, starting at the specified index and with the specified length. |
| 141 | + * |
| 142 | + * <a name="ml-server-type-subvector"></a> |
| 143 | + |
| 144 | + * <p> |
| 145 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:subvector" target="mlserverdoc">vec:subvector</a> server function. |
| 146 | + * @param vector The input vector. (of <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a>) |
| 147 | + * @param start The starting index of the subvector (inclusive). (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 148 | + * @param length The length of the subvector. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 149 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type |
| 150 | + */ |
| 151 | + public ServerExpression subvector(ServerExpression vector, ServerExpression start, ServerExpression length); |
| 152 | +/** |
| 153 | + * Returns a vector value. |
| 154 | + * |
| 155 | + * <a name="ml-server-type-vector"></a> |
| 156 | + |
| 157 | + * <p> |
| 158 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector" target="mlserverdoc">vec:vector</a> server function. |
| 159 | + * @param values The values to create the vector from. Can be a sequence or json:array of integer or floating-point numbers. (of <a href="{@docRoot}/doc-files/types/xs_anyAtomicType.html">xs:anyAtomicType</a>) |
| 160 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/vec_vector.html">vec:vector</a> server data type |
| 161 | + */ |
| 162 | + public ServerExpression vector(ServerExpression values); |
| 163 | +/** |
| 164 | + * A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option. |
| 165 | + * <p> |
| 166 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function. |
| 167 | + * @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 168 | + * @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>) |
| 169 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type |
| 170 | + */ |
| 171 | + public ServerExpression vectorScore(ServerExpression score, double similarity); |
| 172 | +/** |
| 173 | + * A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option. |
| 174 | + * |
| 175 | + * <a name="ml-server-type-vector-score"></a> |
| 176 | + |
| 177 | + * <p> |
| 178 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function. |
| 179 | + * @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 180 | + * @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>) |
| 181 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type |
| 182 | + */ |
| 183 | + public ServerExpression vectorScore(ServerExpression score, ServerExpression similarity); |
| 184 | +/** |
| 185 | + * A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option. |
| 186 | + * <p> |
| 187 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function. |
| 188 | + * @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 189 | + * @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>) |
| 190 | + * @param similarityWeight The weight of the vector similarity on the score. The default value is 1.0. Values less than or equal to zero have no effect. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>) |
| 191 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type |
| 192 | + */ |
| 193 | + public ServerExpression vectorScore(ServerExpression score, double similarity, double similarityWeight); |
| 194 | +/** |
| 195 | + * A helper function that returns the hybrid score using a cts:score and a vector similarity function. You can tune the effect of the vector similarity on the score using the "similarity-weight" option. |
| 196 | + * <p> |
| 197 | + * Provides a client interface to the <a href="http://docs.marklogic.com/vec:vector-score" target="mlserverdoc">vec:vector-score</a> server function. |
| 198 | + * @param score The cts:score of the matching document. (of <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a>) |
| 199 | + * @param similarity The similarity between the vector in the matching document and the query vector. The result of a call to ovec:cosine-similarity() or op.vec.cosineSimilarity(). In the case that the vectors are normalized, pass ovec:dot-product() or op.vec.dotProduct(). Note that vec:euclideanDistance() should not be used here. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>) |
| 200 | + * @param similarityWeight The weight of the vector similarity on the score. The default value is 1.0. Values less than or equal to zero have no effect. (of <a href="{@docRoot}/doc-files/types/xs_double.html">xs:double</a>) |
| 201 | + * @return a server expression with the <a href="{@docRoot}/doc-files/types/xs_unsignedInt.html">xs:unsignedInt</a> server data type |
| 202 | + */ |
| 203 | + public ServerExpression vectorScore(ServerExpression score, ServerExpression similarity, ServerExpression similarityWeight); |
| 204 | +} |
0 commit comments