This module provides functions to create secondary index (SI) filter
predicates for use in query operations via the Client#query
command.
Example
const Aerospike = require('aerospike') Aerospike.connect().then(async (client) => { // find any records that have a recent location within 1000m radius of the specified coordinates let geoFilter = Aerospike.filter.geoWithinRadius('recent', 103.8, 1.305, 1000, Aerospike.indexType.LIST) let query = client.query('test', 'demo') query.where(geoFilter) let results = await query.results() for (let record in results) { console.log(record.bins.recent) } client.close() })
Classes
Methods
-
<static> contains(bin, value, indexType)
Filter for list/map membership.
-
The filter matches records with a bin that has a list or map value that contain the given string or integer.
Parameters:
Name Type Description bin
string The name of the bin.
value
string | number The value that should be a member of the list or map in the bin.
indexType
number One of
module:aerospike.indexType
, i.e. LIST, MAPVALUES or MAPKEYS.Returns:
SI filter predicate, that can be applied to queries using
Query#where
. -
<static> equal(bin, value)
String/integer equality filter.
-
The filter matches records with a bin that matches a specified string or integer value.
Parameters:
Name Type Description bin
string The name of the bin.
value
string The filter value.
Returns:
SI filter predicate, that can be applied to queries using
Query#where
. -
<static> geoContainsGeoJSONPoint(bin, value [, indexType])
Geospatial filter that matches regions that contain a given GeoJSON point.
-
Depending on the index type, the filter will match GeoJSON regions within list or map values as well (requires server
= 3.8).
Parameters:
Name Type Argument Default Description bin
string The name of the bin.
value
GeoJSON GeoJSON point value.
indexType
number <optional>
Aerospike.indexType.DEFAULT One of
module:aerospike.indexType
, i.e. LIST or MAPVALUES.Returns:
SI filter predicate, that can be applied to queries using
Query#where
. -
<static> geoContainsPoint(bin, lng, lat [, indexType])
Geospatial filter that matches regions that contain a given lng/lat coordinate.
-
Depending on the index type, the filter will match GeoJSON regions within list or map values as well (requires server
= 3.8).
Parameters:
Name Type Argument Default Description bin
string The name of the bin.
lng
number Longitude of the point.
lat
number Latitude of the point.
indexType
number <optional>
Aerospike.indexType.DEFAULT One of
module:aerospike.indexType
, i.e. LIST or MAPVALUES.Returns:
SI filter predicate, that can be applied to queries using
Query#where
. -
<static> geoWithinGeoJSONRegion(bin, value [, indexType])
Geospatial filter that matches points within a given GeoJSON region.
-
Depending on the index type, the filter will match GeoJSON values contained in list or map values as well (requires Aerospike server version >= 3.8).
Parameters:
Name Type Argument Default Description bin
string The name of the bin.
value
GeoJSON GeoJSON region value.
indexType
number <optional>
Aerospike.indexType.DEFAULT One of
module:aerospike.indexType
, i.e. LIST or MAPVALUES.Returns:
SI filter predicate, that can be applied to queries using
Query#where
. -
<static> geoWithinRadius(bin, lng, lat, radius [, indexType])
Geospatial filter that matches points within a radius from a given point.
-
Depending on the index type, the filter will match GeoJSON values contained in list or map values as well (requires Aerospike server version >= 3.8).
Parameters:
Name Type Argument Default Description bin
string The name of the bin.
lng
number Longitude of the center point.
lat
number Latitude of the center point.
radius
number Radius in meters.
indexType
number <optional>
Aerospike.indexType.DEFAULT One of
module:aerospike.indexType
, i.e. LIST or MAPVALUES.Returns:
SI filter predicate, that can be applied to queries using
Query#where
. -
<static> range(bin, min, max [, indexType])
Integer range filter.
-
The filter matches records with a bin value in the given integer range. The filter can also be used to match for integer values within the given range that are contained with a list or map by specifying the appropriate index type.
Parameters:
Name Type Argument Default Description bin
string The name of the bin.
min
number Lower end of the range (inclusive).
max
number Upper end of the range (inclusive).
indexType
number <optional>
Aerospike.indexType.DEFAULT One of
module:aerospike.indexType
, i.e. LIST or MAPVALUES.Returns:
SI filter predicate, that can be applied to queries using
Query#where
.