Skip to main content

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.

FunctionDescription
sim.jaccardCalculate Jaccard similarity coefficient between sets

Text Functions (flex.text.*)

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

FunctionDescription
text.capitalizeCapitalize the first character of a string
text.decapitalizeLowercase the first character of a string
text.swapCaseSwap the case of all characters in a string
text.camelCaseConvert string to camelCase format
text.upperCamelCaseConvert string to UpperCamelCase (PascalCase)
text.snakeCaseConvert string to snake_case format
text.formatFormat string with placeholder substitution
text.indexOfFind first occurrence of substring
text.indexesOfFind all occurrences of substring
text.joinJoin array elements with delimiter
text.lpadPad string on the left to target length
text.rpadPad string on the right to target length
text.regexGroupsExtract regex matches and capture groups
text.repeatRepeat string multiple times
text.replaceReplace text using regex pattern
text.jaroWinklerCompute Jaro-Winkler similarity for short strings
text.levenshteinCompute Levenshtein edit distance between strings

Collection Functions (flex.coll.*)

Operations on lists and arrays including set operations and transformations.

FunctionDescription
coll.zipCombine two lists element-by-element into pairs
coll.unionCombine lists and return unique elements
coll.intersectionFind common elements between lists
coll.shuffleRandomly shuffle list elements
coll.frequenciesCount frequency of each element in list

Map Functions (flex.map.*)

Map/object manipulation for property management and transformation.

FunctionDescription
map.mergeShallow merge multiple maps
map.fromPairsConvert list of key-value pairs to map
map.submapExtract subset of keys from map
map.removeKeyRemove single key from map
map.removeKeysRemove multiple keys from map

JSON Functions (flex.json.*)

JSON serialization and parsing utilities.

FunctionDescription
json.toJsonSerialize value to JSON string
json.fromJsonMapParse JSON string to map
json.fromJsonListParse JSON string to list

Date Functions (flex.date.*)

Date and time manipulation, formatting, and parsing.

FunctionDescription
date.formatFormat date/time with pattern and timezone
date.parseParse date/time string with optional pattern
date.truncateTruncate date to specific unit (day, month, etc.)
date.toTimeZoneConvert date to timezone offset

Bitwise Functions (flex.bitwise.*)

Low-level bitwise operations on integers.

FunctionDescription
bitwise.andBitwise AND operation
bitwise.orBitwise OR operation
bitwise.xorBitwise XOR (exclusive OR) operation
bitwise.notBitwise NOT (one's complement) operation
bitwise.shiftLeftLeft bit shift operation
bitwise.shiftRightRight 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