Aerospike.Filter (Aerospike Driver v0.3.1)

Copy Markdown View Source

Secondary-index predicate values for query builders.

Use range/3, equal/2, contains/3, geo_within/2, or geo_contains/2 to build a predicate, then pass it to Aerospike.Query.where/2.

using_index/2 targets a named index, and with_ctx/2 carries nested CDT context for context-aware predicates.

Summary

Types

Collection secondary-index kind accepted by contains/3.

GeoJSON input accepted by geospatial query filters.

Secondary-index filter kind encoded for the query predicate.

Indexed scalar particle type inferred for integer and string predicates.

Scalar value accepted by equality and CDT membership filters.

t()

Secondary-index query filter consumed by Aerospike.Query.where/2.

Functions

CDT membership filter for list or map indexes.

Equality on a bin. The particle type is inferred from the value.

Geo point query for regions containing a GeoJSON point.

Builds a geo_contains/2 point query from longitude and latitude.

Geo region query for points within a GeoJSON region.

Builds a geo_within/2 circle query from center longitude, latitude, and radius.

Numeric range on a bin, inclusive.

Targets a named secondary index.

Attaches nested CDT context to the filter.

Types

collection_index_type()

@type collection_index_type() :: :list | :mapkeys | :mapvalues

Collection secondary-index kind accepted by contains/3.

geo_geometry()

GeoJSON input accepted by geospatial query filters.

Binary inputs are expected to be non-empty GeoJSON strings. Typed Aerospike.Geo values are converted with Aerospike.Geo.to_json/1.

index_type()

@type index_type() ::
  :default | :list | :mapkeys | :mapvalues | :geo_within | :geo_contains

Secondary-index filter kind encoded for the query predicate.

:list, :mapkeys, and :mapvalues target CDT collection indexes. :geo_within and :geo_contains target geospatial predicates.

particle_type()

@type particle_type() :: :integer | :string

Indexed scalar particle type inferred for integer and string predicates.

scalar_value()

@type scalar_value() :: integer() | String.t()

Scalar value accepted by equality and CDT membership filters.

t()

@type t() :: %Aerospike.Filter{
  begin: term(),
  bin_name: String.t(),
  ctx: [Aerospike.Ctx.step()] | nil,
  end: term(),
  index_name: String.t() | nil,
  index_type: index_type(),
  particle_type: particle_type()
}

Secondary-index query filter consumed by Aerospike.Query.where/2.

A query can carry one secondary-index filter. index_name is optional and is set by using_index/2; ctx is optional nested-CDT context set by with_ctx/2.

Functions

contains(bin_name, index_type, value)

@spec contains(String.t(), collection_index_type(), scalar_value()) :: t()

CDT membership filter for list or map indexes.

index_type must match the collection index created for the bin: :list, :mapkeys, or :mapvalues.

equal(bin_name, value)

@spec equal(String.t(), scalar_value()) :: t()

Equality on a bin. The particle type is inferred from the value.

Supports integer and string values. Integer values must fit in Aerospike's signed int64 range.

geo_contains(bin_name, point)

@spec geo_contains(String.t(), geo_geometry()) :: t()

Geo point query for regions containing a GeoJSON point.

Use this with a :geo2dsphere index on region data. The point may be a GeoJSON string or a typed Aerospike.Geo value.

geo_contains_point(bin_name, lng, lat)

@spec geo_contains_point(String.t(), number(), number()) :: t()

Builds a geo_contains/2 point query from longitude and latitude.

geo_within(bin_name, region)

@spec geo_within(String.t(), geo_geometry()) :: t()

Geo region query for points within a GeoJSON region.

Use this with a :geo2dsphere index on point data. The region may be a GeoJSON string or a typed Aerospike.Geo value.

geo_within_radius(bin_name, lng, lat, radius)

@spec geo_within_radius(String.t(), number(), number(), number()) :: t()

Builds a geo_within/2 circle query from center longitude, latitude, and radius.

range(bin_name, begin_val, end_val)

@spec range(String.t(), integer(), integer()) :: t()

Numeric range on a bin, inclusive.

begin_val and end_val must fit in Aerospike's signed int64 range. Raises ArgumentError when the bin name is empty, a value is out of range, or the range is inverted.

using_index(filter, index_name)

@spec using_index(t(), String.t()) :: t()

Targets a named secondary index.

Use this when the server has multiple compatible indexes and the query should address one index explicitly.

with_ctx(filter, ctx)

@spec with_ctx(t(), [Aerospike.Ctx.step()]) :: t()

Attaches nested CDT context to the filter.

ctx must be a non-empty list of Aerospike.Ctx steps that points at the nested collection value indexed by the server.