Algoliax (Algoliax v0.10.0)

View Source

Algoliax is wrapper for Algolia api

Configuration

Algoliax needs only :api_key and application_id config. These configs can either be on config files or using environment varialble "ALGOLIA_API_KEY" and "ALGOLIA_APPLICATION_ID".

config :algoliax,
  api_key: "",
  application_id: ""

Summary

Functions

Generate a secured api key with filter

Same as generate_secured_api_key/2 but returns the key or raises if invalid params

Wait for a task to be published on Algolia side. Work with all indexer function except reindex_atomic/0

Forward user ip to algolia operations

Functions

generate_secured_api_key(api_key, params)

@spec generate_secured_api_key(api_key :: String.t(), params :: map()) ::
  {:ok, binary()} | {:error, binary()}

Generate a secured api key with filter

Examples

Algoliax.generate_secured_api_key("api_key", %{filters: "reference:10"})
Algoliax.generate_secured_api_key("api_key", %{filters: "reference:10 OR nickname:john"})

generate_secured_api_key!(api_key, params)

@spec generate_secured_api_key!(api_key :: String.t(), params :: map()) :: binary()

Same as generate_secured_api_key/2 but returns the key or raises if invalid params

Examples

Algoliax.generate_secured_api_key!("api_key", %{filters: "reference:10"})
Algoliax.generate_secured_api_key!("api_key", %{filters: "reference:10 OR nickname:john"})

wait_task(tasks)

Wait for a task to be published on Algolia side. Work with all indexer function except reindex_atomic/0

Examples

MyApp.People.save_object(%MyApp.People{id: 1}) |> Algoliax.wait_task()

with_user_ip(ip \\ nil, fun)

Forward user ip to algolia operations

Algoliax.with_user_ip("192.168.0.1", fn ->
  MyIndexer.search("test")
end)