Scrypath.Meilisearch.FederatedDecode (scrypath v0.3.7)

Copy Markdown View Source

Decodes federated /multi-search responses into per-index raw maps suitable for building the public search result structs returned from Scrypath.search/3.

Federated responses carry a flat hits list tagged with _federation.indexUid and optional facetsByIndex keyed by index UID. This module never calls String.to_atom/1 on remote keys.

Summary

Functions

Returns global merge order for a flat federated hits stream.

Returns {:ok, [{schema, raw_map}]} aligned to indexed_schemas declaration order.

Functions

merge_hit_order(response, indexed_schemas)

@spec merge_hit_order(map(), [{module(), String.t()}]) ::
  {:ok, [{module(), term()}]} | {:error, term()}

Returns global merge order for a flat federated hits stream.

Each element is {schema_module, id} where id is the primary key value from the hit map ("id" first, else the schema's configured document_id as a string key). Declaration order in indexed_schemas is only used to resolve index UIDs to modules; hit list order is preserved from response.

per_schema_maps(response, indexed_schemas)

@spec per_schema_maps(map(), [{module(), String.t()}]) ::
  {:ok, [{module(), map()}]} | {:error, term()}

Returns {:ok, [{schema, raw_map}]} aligned to indexed_schemas declaration order.

indexed_schemas is [{schema_module, index_uid_string}, ...].