Module elasticsearch_filter_app

Elasticsearch search library for Emergence filter agents.

Description

Elasticsearch search library for Emergence filter agents.

Not an OTP application — no start/stop. Use as a dependency:

em_filter:start_agent(my_agent, elasticsearch_filter_app, #{ capabilities => elasticsearch_filter_app:base_capabilities() ++ ["mydomain"] })

Config file: elastic_config.json (in working directory). See elastic_config.json.sample for the full format.

Handler contract: handle/2 (Body, Memory) -> {Results, Memory}.

Function Index

auth_headers/1Build Authorization header for API key or basic auth.
base_capabilities/0
build_query/3Build an ES query map.
detect_query_type/1Heuristic: query_string if input contains ES-specific syntax.
handle/2
map_hit/2Map a single ES hit to an Emergence embryo.

Function Details

auth_headers/1

auth_headers(X1::map()) -> [{string(), string()}]

Build Authorization header for API key or basic auth. API key is passed as-is (Elastic returns it pre-encoded). Basic auth encodes username:password in base64.

base_capabilities/0

base_capabilities() -> [binary()]

build_query/3

build_query(Query::string(), Fields::[binary()], Size::pos_integer()) -> map()

Build an ES query map. Uses query_string when the input looks like ES syntax (field:val, boolean operators, range brackets), multi_match otherwise.

detect_query_type/1

detect_query_type(Query::string()) -> multi_match | query_string

Heuristic: query_string if input contains ES-specific syntax.

handle/2

handle(Body::binary() | term(), Memory::map()) -> {list(), map()}

map_hit/2

map_hit(X1::map(), Index::map()) -> {true, map()} | false

Map a single ES hit to an Emergence embryo. Returns false to filter out hits with missing required fields.


Generated by EDoc