The Unary Functions class contains trigonometric and other math functions that take a single FieldExpression as an argument.
Available Functions:
- ABS - absolute value
- ACOS - arc cosine
- ASIN - arc sine
- ATAN - arc tangent
- COS - cosine
- COT - cotangent
- DEGREES - convert value from radians to degrees
- LN - natural logarithm
- RADIANS - convert value from degrees to radians
- RANDOM -
- ROUND - to the nearest integer
- SIN - sine
- SQRT - square root
- TAN - tangent
Java Example:
// Assumes the "value" field is a numeric or Point field QueryRequest request = new QueryRequest("*:*"); request.addField( new UnaryMathExpression(UnaryMathExpression.Method.DEGREES, new StoredField("value")) ); // ... (Perform Search)
REST Syntax:
FUNCTIONNAME(FIELDEXPRESSION)
- FUNCTIONNAME - any of the available field function names specified above. (AVG, SUM, etc)
- FIELDEXPRESSION - field expression to apply the function to.
Example:
# Assumes the "angles" field is a numeric multi-value field listing angles in degrees. &fields=RADIANS(angles) as "Angles in Radians"