Skip to content

Filtering records

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Aerospike Voyager filters the records in a set with the Aerospike Expression Language (AEL). The filter panel has two tabs that write the same language:

  • The Filters tab builds a filter from rows of field, operator, and value. It suggests the bins found in the records on screen and the record metadata you can filter on, such as time to live and record size.
  • The Expression tab takes a filter you write by hand. It checks the text as you type, suggests what can come next, and offers a fix when the problem is obvious.

Voyager compiles the filter into an Aerospike expression before it sends the query, so a filter does not depend on the server’s own AEL support. String functions and regular expressions are the exception: they need Aerospike Database 8.2.0 and later. See String functions and regular expressions.

Prerequisites

The filter row

Every set has a filter row between the page controls and the record list. With no filter applied, it reads No filters applied. Click the filter icon (Filter records) to open the filter panel.

When a filter is applied, the row shows one chip for each condition, with the and or or connective between them, and a count on the filter icon. Click a chip to open the panel with that condition selected. Click Add condition to add a row to the filter, or Clear all to remove the filter and return to every record in the set.

Filter row above the sample_users records showing a filter icon with a count of 2, chips age > 30, and, active == true, an Add condition button, and Clear all at the right

A filter that the Filters tab cannot show as rows, such as one that uses a string function or a nested path, appears in the row as Filtered by an expression with an Edit expression button. See Switching between tabs.

The filter row and the Search by user key or digest lookup are exclusive. The filter row is unavailable while a lookup is active, and the lookup is unavailable while a filter is applied.

Filters tab

The Filters tab builds a filter one condition at a time. Each row has a Field, an Operator, a Value, and a Data type. The expression the rows produce appears below them, with a copy button.

Filter panel open on the Filters tab with an empty WHERE row containing Field, Operator, Value, and Data type controls, an Add condition button, the placeholder Add a filter, or switch to the Expression tab to write one, and Cancel and Apply buttons

Add a condition

  1. Click the filter icon in the filter row, or click Add condition.
  2. Open Field and choose a bin or a record metadata field. You can also type any bin name.
  3. Choose an Operator.
  4. Enter a Value. The operators is true, is false, exists, and does not exist take no value.
  5. Check the Data type. Voyager fills it in from the field you chose.
  6. Click Apply, or press CMD+ENTER on macOS or CTRL+ENTER on Windows and Linux. On the Filters tab, ENTER also applies the filter.
Filters tab with Field age, Operator greater than, Value 30, and Data type integer, the generated expression $.age > 30 below the row, and the Apply button enabled

Choose a field

The Field list has two groups:

  • Record metadata lists the metadata fields you can filter on. See Filter on record metadata.
  • Bins lists the bins found in the records loaded on the current page, each labeled with the type Voyager inferred from those records. The group heading reminds you that these are the bins seen on this page, and that any name can be typed.
Field list open on the Filters tab showing a Record metadata group with Time to live ttl(), Last updated lastUpdateTime(), Time since last update timeSinceLastUpdate(), Expires at voidTime(), Record size recordSize(), and Key stored with record keyExists(), followed by a Bins group

Aerospike records in the same set can hold different bins, and the same bin can hold different types in different records. The bin suggestions describe the loaded page, not the whole set:

  • A bin that is not on the current page can still be typed. Voyager offers the typed name back, labeled unknown, and accepts it.
  • When the loaded records disagree about a bin’s type, the bin is labeled mixed types and no data type is filled in.
  • When no records are loaded, including after a filter that matched nothing, only the Record metadata group appears. Typing a bin name still works.

Filter on record metadata

Record metadata describes the record itself rather than its bins. Each metadata field has a fixed type, so Voyager locks the Data type when you choose one and offers only the operators that type accepts.

FieldAELType
Time to live$.ttl()integer
Last updated$.lastUpdateTime()integer
Time since last update$.timeSinceLastUpdate()integer
Expires at$.voidTime()integer
Record size$.recordSize()integer
Key stored with record$.keyExists()boolean

For what each field returns and its units, see Record metadata functions in the AEL reference. Record size requires Aerospike Database 7.0 and later.

The numeric fields offer the six comparison operators under the heading Fixed by metadata accessor. Key stored with record offers is true and is false.

Filters tab with Field recordSize() and Data type locked to integer, and the Operator menu open under the heading Fixed by metadata accessor listing equals, not equal, greater than, less than, greater than or equal, and less than or equal

For example, to find records that expire within the next hour, add two conditions joined with and: Time to live > greater than 0, and Time to live < less than 3600. Records that never expire do not match $.ttl() > 0.

When a filter uses a metadata field, the matching chip on every record card in the result is highlighted, so you can check the result by eye. Time to live and Expires at highlight Exp, Last updated and Time since last update highlight Updated, and Record size highlights Size. See Record cards.

Operators

OperatorAEL producedExample
== equals$.bin == value$.country == 'US'
!= not equal$.bin != value$.status != 'inactive'
> greater than$.bin > value$.age > 30
< less than$.bin < value$.price < 50.0
>= greater than or equal$.bin >= value$.count >= 10
<= less than or equal$.bin <= value$.count <= 100
is true$.bin == true$.active == true
is false$.bin == false$.active == false
exists$.bin.exists()$.email.exists()
does not existnot($.bin.exists())not($.phone.exists())

For a bin, the Operator menu leads with the operators that suit the bin’s inferred type, under a heading such as Suggested for text or Suggested for numbers. The rest follow under Other operators. The inferred type changes only the order: every operator stays available for every bin, because the same bin can hold another type in records that are not loaded. A bin with no inferred type shows one plain list.

Operator menu for the string bin name, with == equals, != not equal, exists, and does not exist under Suggested for text, and the comparison and truth operators under Other operators

When you choose a map or list bin, the operator defaults to exists, and a notice explains that filtering on a value inside the collection uses the Expression tab. The notice has a Switch to expression tab link.

The Filters tab has no string operators such as contains or starts with. Write those on the Expression tab.

Data type

The Data type control sets how Voyager writes the value into the expression: string, integer, double, or boolean.

  • For a bin, Voyager fills in the type it inferred from the loaded records. You can change it, for example to compare a numeric-looking ZIP code as a string.
  • For a metadata field, the type is locked. Hovering over the control shows Data type is set for this field.
  • A double value is written with a decimal part, so 8 becomes 8.0. A string value is written in single quotes, or in double quotes when it contains a single quote. A string that contains both kinds of quote is rejected.
  • The operators >, <, >=, and <= need an integer or double data type.

Apply stays disabled while a row shows a message under one of its controls. Every row needs a field, an operator, and a data type, and a value unless the operator is is true, is false, exists, or does not exist. The value must fit the data type: a whole number such as 42 for integer, a number such as 3.14 for double, and true or false for boolean.

Combine conditions

One connective joins every condition in the filter. The second row’s Condition control sets and or or, and later rows follow it. To mix and and or, write the filter on the Expression tab, where you can group conditions with parentheses.

The Filters tab holds up to five conditions. At five, the panel shows Limit of 5 conditions reached. Write an expression to add more. with an Expression editor button that switches tabs. The Expression tab has no condition limit.

Drag a row by its handle to reorder conditions. Click the trash icon to remove a row.

Clear or cancel

Click Clear all to remove every condition. Click Cancel to close the panel without applying your changes. If you close the panel with unapplied changes, Voyager asks you to confirm: click Discard changes to close, or Cancel to keep editing.

Expression tab

The Expression tab takes an AEL filter expression: a condition that is true for the records you want to keep. It uses the same language as the Filters tab, so you can start with the builder, then switch tabs to see and extend the expression it wrote.

Expression tab with the expression $.age > 30 and $.active == true, the message Expression valid., the hint $. for bins and metadata, Tab to accept, Cmd+Enter to apply, an Examples button, a documentation icon, and the Apply button enabled

The message line directly under the editor reports whether the expression is valid. In the panel footer, a hint line lists the keys that matter, followed by an Examples button and a documentation icon that opens the AEL documentation.

Write an expression

A bin is written $.bin, and a metadata field is written with parentheses, such as $.ttl():

$.age > 30 and $.active == true
$.address.city == 'Miami'
$.ttl() > 0 and $.ttl() < 3600

For operators, paths into maps and lists, record metadata functions, string functions, and regular expressions, see the AEL reference.

Autocomplete

The editor suggests what the language allows at the cursor:

  • At the start of a condition, or after and, or, not(, or (: the bins in the loaded records with their inferred types, the metadata fields such as $.ttl(), and not(.
  • After a bin or metadata field: the comparison operators, =~, .exists(), and string functions such as .contains(''), .startsWith(''), .endsWith(''), .upper(), .lower(), .trim(), .substr(from: 0, to: 3), and .strlen().
  • After a comparison operator: true and false.
  • After a complete condition: and and or.

Suggestions open as you type a letter, $, or .. Press CTRL+SPACE to open them at any point. Press TAB to accept the highlighted suggestion and ESC to close the list. ENTER does not accept a suggestion. When you accept a function that takes an argument, the cursor lands inside its quotes. Autocomplete inserts .contains('') without the argument name, a form Voyager accepts. The Developer SDKs need the named form, .contains(needle: ''), so use that form in an expression you plan to copy into application code.

Expression editor after typing $. with the suggestion list showing $.active boolean, $.address map, $.age integer, $.email string, $.location GeoJSON, $.name string, and $.tags list

Bin suggestions come from the loaded page, like the Filters tab. Keys inside maps and positions inside lists are not suggested. Type them by hand.

Validation as you type

Voyager checks the expression against the AEL grammar shortly after you stop typing. The check runs inside Voyager and never contacts the cluster. While it runs, the message line reads Checking…. A valid expression reads Expression valid.

When the expression is wrong, Voyager underlines the part that is wrong, explains the problem in the message line, and disables Apply. When the fix is obvious, a button below the message applies it in one click.

Expression editor with $.age = 30, the = underlined, the message Use == to compare a bin with a value; a single = assigns and cannot appear in a filter., and a Change to '==' button
You writeVoyager reportsOne-click fix
$.age = 30Use == to compare a bin with a value. A single = assigns and cannot appear in a filter.Change to ’==‘
$.age > 30 AND $.active == trueUnexpected “AND” in the expression. Did you mean and?Change to ‘and’
$.age > 30 && $.active == trueUnexpected ”&” in the expression. Did you mean and?Change to ‘and’
A misspelled keyword, metadata field, or loaded bin nameDid you mean the closest match?Change to the match
ttl() > 0Metadata accessors start with $..Change to ‘$.ttl()‘
$.age >The expression ends before it is complete.None
$.name.upper() == 5Cannot compare string == int: incompatible operand types.None

Voyager can only report a type mismatch where AEL knows both types, such as a function result or a metadata field. A bin has no fixed type, so $.age > 'thirty' is valid. It matches no record whose age is an integer.

If the syntax check cannot run, the message reads Syntax checking is unavailable. You can still apply this filter, errors will surface when the query runs. and Apply stays available. If the connection to the cluster drops, Apply is unavailable until it returns.

String functions and regular expressions

The editor accepts AEL string functions, such as $.name.upper() == 'HANK MOORE', and regular expressions, such as $.name =~ /^ha/i. See String path functions and Regex match in the AEL reference.

Expression editor with $.email.contains('example') and a message stating that the string operation contains() needs Aerospike 8.2 or later and naming the connected cluster version C-8.1.1.1, with Apply disabled

Maps and lists

Filter on a value inside a map or list bin with an AEL path, such as $.address.city == 'Miami' or $.tags.[0] == 'gaming'. See Paths and navigation in the AEL reference.

.exists() works on a top-level bin, such as $.email.exists(), but not on a nested path. For $.address.city.exists(), the editor reports Residual predicate could not be compiled to a native expression. and Apply stays disabled. Compare the nested value instead.

Examples

Click Examples below the editor for a quick reference of common filters: comparisons, existence checks, string functions, regular expressions, and and or, and every metadata field.

Examples popover listing $.field == 'value', $.field > 30, $.field == true, $.field.exists(), not($.field.exists()), string function examples such as $.field.contains('abc') and $.field =~ /^ac/i, and, or, and the six metadata accessors

Switching between tabs

Switching from the Filters tab to the Expression tab writes your conditions into the editor.

Switching back works when the expression fits the Filters tab: five conditions or fewer, one connective, and only the operators the builder offers. Otherwise the Filters tab is unavailable, and the Expression tab shows This expression can’t be converted to filters. Continue editing here or clear to start over. The expression is still valid and still runs. Expressions that do not fit include ones that:

  • Mix and and or, or group conditions with parentheses.
  • Use a string function, a regular expression, or a collection path.
  • Have more than five conditions.

When you apply one of these, the filter row reads Filtered by an expression. Click Edit expression to change it.

Records view after applying an expression that combines recordSize() with a grouped or condition, with the filter row reading Filtered by an expression beside an Edit expression button, and the Size chip highlighted on each record card

How Voyager runs a filter

Voyager compiles the expression into an Aerospike expression and runs it as a query on the set. If a secondary index on a bin covers part of the filter, Voyager uses it. Otherwise the query scans the set and the cluster evaluates the filter on every record.

Verify

After you apply a filter:

  • The filter row shows one chip per condition, or Filtered by an expression for an expression the Filters tab cannot show, and the records count shows the number of matches.
  • When the filter uses a record metadata field, the matching chip on each record card is highlighted.
  • A filter that matches no records shows No matching records found, with Edit filters and Clear all buttons.

Troubleshoot

SymptomCauseFix
No matching records found for records you expectedA misspelled bin name matches nothing, because Aerospike has no fixed schema. A value of the wrong type also matches nothing, such as $.age > '30' against an integer bin.Check the bin name against a record card, or choose it from the Field list. Check the Data type on the Filters tab, or the quotes on the Expression tab.
Apply is disabled on the Filters tabA row is incomplete, or its value does not fit the data typeFill in every field of the row. Enter a whole number for integer, a number for double, and true or false for boolean.
The editor names a function and a server version, and Apply is disabledString functions and regular expressions need Aerospike Database 8.2.0 and later, and Record size needs 7.0Upgrade the cluster, or rewrite the filter with comparison operators.
Residual predicate could not be compiled to a native expression..exists() on a path inside a map or listCompare the nested value instead, such as $.address.city == 'Miami'.
Syntax checking is unavailable.Voyager could not check the expressionApply the filter. Any error appears when the query runs.
Connection lost — reconnecting. and Apply is disabledThe connection to the cluster droppedWait for Voyager to reconnect, or check the cluster.
Limit of 5 conditions reached.The Filters tab holds five conditionsClick Expression editor and add the condition there.
The Filters tab is unavailableThe expression uses something the Filters tab cannot show, such as mixed and and or, a string function, or a path into a map or listKeep editing on the Expression tab, or click Clear all to start over.
The filter row is unavailableA user key or digest lookup is activeClear the lookup.
Request timed outA filter that no secondary index covers scans the whole set, and the scan ran past its socket timeoutAdd a condition that narrows the result, filter on a bin that has a secondary index, or raise Socket timeout under Query / scan policy.
Query queue fullThe cluster is running too many queries at onceWait for the running queries to finish, then apply the filter again.

For other problems, see Voyager troubleshooting.

Next steps