Ranking signal supported operations

Index Version Requirements: v2.0.0+

List of operations supported in the ranking_expr="<your-expression>" syntax.

The explanation on how to use ranking signals is available here.

OperationTypeDescription / Examples
uncalibrated_relevanceFloatthe unmodified relevance score of the object
object.<property>Anythe value of <property> for the object as defined in the object store. Nested fields can be accessed with the dot notation e.g. object.a.b.c
NOWFloatthe current timestamp in unix time (seconds)
timestamp(<timestamp>)Floatfunction to convert a RFC 3339 <timestamp>

Important: The relevance is "uncalibrated" and is only meant to compare objects. The value does not have an intrinsic meaning; its distribution and bounds can vary depending on the evaluation method. We advise against using its value as a cutoff.

Operators

OperatorDescription
^Exponentiation
*Product
/Division (integer if both arguments are integers, otherwise float)
%Modulo (integer if both arguments are integers, otherwise float)
+Sum or String Concatenation
-Difference
<Lower than
>Greater than
<=Lower than or equal
>=Greater than or equal
==Equal
!=Not equal
&&Logical and
||Logical or
-Negation
!Logical not
,Aggregation
;Expression Chaining

Operators: Variables and Assignment

OperatorDescription
=Assignment
+=Sum-Assignment or String-Concatenation-Assignment
-=Difference-Assignment
*=Product-Assignment
/=Division-Assignment
%=Modulo-Assignment
^=Exponentiation-Assignment
&&=Logical-And-Assignment
||=Logical-Or-Assignment

Value Types

Value typeExample
String"abc""""a\"b\\c"
Booleantruefalse
Int3-901354120xfe02-0x1e
Float3..351.000.5123.55423e4-2e-33.54e+2
Tuple(3, 55.0, false, ())(1, 2)
Empty()

Common Functions

IdentifierArgument AmountArgument TypesDescription
min>= 1NumericReturns the minimum of the arguments
max>= 1NumericReturns the maximum of the arguments
len1String/TupleReturns the character length of a string, or the amount of elements in a tuple (not recursively)
floor1NumericReturns the largest integer less than or equal to a number
round1NumericReturns the nearest integer to a number. Rounds half-way cases away from 0.0
ceil1NumericReturns the smallest integer greater than or equal to a number
if3Boolean, Any, AnyIf the first argument is true, returns the second argument, otherwise, returns the third
contains2Tuple, any non-tupleReturns true if second argument exists in first tuple argument.
contains_any2Tuple, Tuple of any non-tupleReturns true if one of the values in the second tuple argument exists in first tuple argument.
typeof1Anyreturns "string", "float", "int", "boolean", "tuple", or "empty" depending on the type of the argument

String Functions

IdentifierArgument AmountArgument TypesDescription
str::regex_matches2String, StringReturns true if the first argument matches the regex in the second argument (Requires regex_support feature flag)
str::regex_replace3String, String, StringReturns the first argument with all matches of the regex in the second argument replaced by the third argument (Requires regex_supportfeature flag)
str::to_lowercase1StringReturns the lower-case version of the string
str::to_uppercase1StringReturns the upper-case version of the string
str::trim1StringStrips whitespace from the start and the end of the string
str::from>= 0AnyReturns passed value as string
str::substring3String, Int, IntReturns a substring of the first argument, starting at the second argument and ending at the third argument. If the last argument is omitted, the substring extends to the end of the string

Mathematical Functions: Common

IdentifierArgument AmountArgument TypesDescription
math::abs1NumericReturns the absolute value of a number, returning an integer if the argument was an integer, and a float otherwise
math::is_nan1NumericReturns true if the argument is the floating-point value NaN, false if it is another floating-point value, and throws an error if it is not a number
math::is_finite1NumericReturns true if the argument is a finite floating-point number, false otherwise
math::is_infinite1NumericReturns true if the argument is an infinite floating-point number, false otherwise
math::is_normal1NumericReturns true if the argument is a floating-point number that is neither zero, infinite, subnormal, or NaN, false otherwise

Mathematical Functions: Logarithms and Exponents

IdentifierArgument AmountArgument TypesDescription
math::ln1NumericReturns the natural logarithm of the number
math::log2Numeric, NumericReturns the logarithm of the number with respect to an arbitrary base
math::log21NumericReturns the base 2 logarithm of the number
math::log101NumericReturns the base 10 logarithm of the number
math::exp1NumericReturns e^(number), (the exponential function)
math::exp21NumericReturns 2^(number)
math::pow2Numeric, NumericRaises a number to the power of the other number
math::sqrt1NumericReturns the square root of a number. Returns NaN for a negative number
math::cbrt1NumericReturns the cube root of a number

Mathematical Functions: Trigonometry

IdentifierArgument AmountArgument TypesDescription
math::cos1NumericComputes the cosine of a number (in radians)
math::acos1NumericComputes the arccosine of a number. The return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1]
math::cosh1NumericHyperbolic cosine function
math::acosh1NumericInverse hyperbolic cosine function
math::sin1NumericComputes the sine of a number (in radians)
math::asin1NumericComputes the arcsine of a number. The return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1]
math::sinh1NumericHyperbolic sine function
math::asinh1NumericInverse hyperbolic sine function
math::tan1NumericComputes the tangent of a number (in radians)
math::atan1NumericComputes the arctangent of a number. The return value is in radians in the range [-pi/2, pi/2]
math::atan22Numeric, NumericComputes the four quadrant arctangent in radians
math::tanh1NumericHyperbolic tangent function
math::atanh1NumericInverse hyperbolic tangent function.
math::hypot2NumericCalculates the length of the hypotenuse of a right-angle triangle given legs of length given by the two arguments

Was this page helpful?