FLEX Function Reference

FLEX is FalkorDB’s open source community UDF package, available at github.com/FalkorDB/flex.
It contains a variety of useful functionality, including:

  • String and set similarity metrics for fuzzy matching and comparison
  • Date and time manipulation, formatting, and parsing
  • Low-level bitwise operations on integers

We welcome contributions to extend this library with additional functionality.

The following sections document all FLEX (FalkorDB Library for Extensions) functions.

Function Categories

Similarity Functions (flex.sim.*)

Set similarity metrics for fuzzy matching and comparison.

Function Description
sim.jaccard Calculate Jaccard similarity coefficient between sets

Text Functions (flex.text.*)

String manipulation, formatting, case conversion utilities, and string similarity metrics.

Function Description
text.capitalize Capitalize the first character of a string
text.decapitalize Lowercase the first character of a string
text.swapCase Swap the case of all characters in a string
text.camelCase Convert string to camelCase format
text.upperCamelCase Convert string to UpperCamelCase (PascalCase)
text.snakeCase Convert string to snake_case format
text.format Format string with placeholder substitution
text.indexOf Find first occurrence of substring
text.indexesOf Find all occurrences of substring
text.join Join array elements with delimiter
text.lpad Pad string on the left to target length
text.rpad Pad string on the right to target length
text.regexGroups Extract regex matches and capture groups
text.repeat Repeat string multiple times
text.replace Replace text using regex pattern
text.jaroWinkler Compute Jaro-Winkler similarity for short strings
text.levenshtein Compute Levenshtein edit distance between strings

Collection Functions (flex.coll.*)

Operations on lists and arrays including set operations and transformations.

Function Description
coll.zip Combine two lists element-by-element into pairs
coll.union Combine lists and return unique elements
coll.intersection Find common elements between lists
coll.shuffle Randomly shuffle list elements
coll.frequencies Count frequency of each element in list

Map Functions (flex.map.*)

Map/object manipulation for property management and transformation.

Function Description
map.merge Shallow merge multiple maps
map.fromPairs Convert list of key-value pairs to map
map.submap Extract subset of keys from map
map.removeKey Remove single key from map
map.removeKeys Remove multiple keys from map

JSON Functions (flex.json.*)

JSON serialization and parsing utilities.

Function Description
json.toJson Serialize value to JSON string
json.fromJsonMap Parse JSON string to map
json.fromJsonList Parse JSON string to list

Date Functions (flex.date.*)

Date and time manipulation, formatting, and parsing.

Function Description
date.format Format date/time with pattern and timezone
date.parse Parse date/time string with optional pattern
date.truncate Truncate date to specific unit (day, month, etc.)
date.toTimeZone Convert date to timezone offset

Bitwise Functions (flex.bitwise.*)

Low-level bitwise operations on integers.

Function Description
bitwise.and Bitwise AND operation
bitwise.or Bitwise OR operation
bitwise.xor Bitwise XOR (exclusive OR) operation
bitwise.not Bitwise NOT (one’s complement) operation
bitwise.shiftLeft Left bit shift operation
bitwise.shiftRight Right bit shift with sign extension

Common Use Cases

Data Cleaning and Normalization

  • text.camelCase, text.snakeCase - Normalize field names
  • text.replace - Remove or sanitize unwanted characters
  • coll.union - Deduplicate lists
  • text.levenshtein - Find similar strings with edit distance
  • text.jaroWinkler - Match names and short strings
  • sim.jaccard - Compare sets and tag similarity

Data Aggregation and Analysis

  • date.truncate - Group by time periods
  • coll.frequencies - Count occurrences
  • map.submap - Select relevant fields

API and Data Exchange

  • json.toJson, json.fromJsonMap - JSON serialization
  • map.removeKeys - Filter sensitive data
  • text.format - Build formatted messages

Permission and Flag Management

  • bitwise.and, bitwise.or - Check and set permission flags
  • bitwise.xor - Toggle flags

Table of contents