algolia v0.8.0 Algolia

Elixir implementation of Algolia search API, using Hackney for http requests

Link to this section Summary

Functions

Clears all content of an index

Copies an index to a new one

Remove all objects matching a filter (including geo filters)

Deletes the index

Delete a object by its objectID

Get the logs of the latest search and indexing operations

Get an object in an index by objectID

Get the settings of a index

List all indexes

Moves an index to new one

Multiple queries

Partially updates an object, takes option upsert: true or false

Save a single object, without objectID specified, must have objectID as a field

Search a single index

Set the settings of a index

Convinient version of wait_task/4, accepts a response to be waited on directly. This enables piping a operation directly into wait_task

Wait for a task for an index to complete returns :ok when it’s done

Link to this section Functions

Link to this function add_object(index, object, opts \\ [])

Add an Object

An attribute can be chosen as the objectID.

Link to this function add_objects(index, objects, opts \\ [])

Add multiple objects

An attribute can be chosen as the objectID.

Link to this function application_id()
Link to this function clear_index(index)

Clears all content of an index

Link to this function copy_index(src_index, dst_index)

Copies an index to a new one

Link to this function delete_by(index, opts)

Remove all objects matching a filter (including geo filters).

Allowed filter parameters:

  • filters
  • facetFilters
  • numericFilters
  • aroundLatLng and aroundRadius (these two need to be used together)
  • insideBoundingBox
  • insidePolygon

Examples

iex> Algolia.delete_by("index", filters: ["score < 30"])
{:ok, %{"indexName" => "index", "taskId" => 42, "deletedAt" => "2018-10-30T15:33:13.556Z"}}
Link to this function delete_index(index)

Deletes the index

Link to this function delete_object(index, object_id, opts \\ [])

Delete a object by its objectID

Link to this function delete_objects(index, object_ids, opts \\ [])

Delete multiple objects

Link to this function get_logs(opts \\ [])

Get the logs of the latest search and indexing operations.

Options

  • :indexName - Index for which log entries should be retrieved. When omitted, log entries are retrieved across all indices.

  • :length - Maximum number of entries to retrieve. Maximum allowed value: 1000.

  • :offset - First entry to retrieve (zero-based). Log entries are sorted by decreasing date, therefore 0 designates the most recent log entry.

  • :type - Type of log to retrieve: all (default), query, build or error.

Link to this function get_object(index, object_id, opts \\ [])

Get an object in an index by objectID

Link to this function get_settings(index)

Get the settings of a index

List all indexes

Link to this function move_index(src_index, dst_index)

Moves an index to new one

Link to this function multi(queries, opts \\ [])

Multiple queries

Link to this function partial_update_object(index, object, object_id, opts \\ [upsert?: true])

Partially updates an object, takes option upsert: true or false

Link to this function partial_update_objects(index, objects, opts \\ [upsert?: true, id_attribute: :objectID])

Partially updates multiple objects

Link to this function save_object(index, object, opts \\ [])

Save a single object, without objectID specified, must have objectID as a field

Link to this function save_objects(index, objects, opts \\ [id_attribute: :objectID])

Save multiple objects

Link to this function search(index, query, opts \\ [])

Search a single index

Link to this function search_for_facet_values(index, facet, text, query \\ %{})
search_for_facet_values(binary(), binary(), binary(), map()) ::
  {:ok, map()} | {:error, code :: integer(), message :: binary()}

Search for facet values

Enables you to search through the values of a facet attribute, selecting only a subset of those values that meet a given criteria.

For a facet attribute to be searchable, it must have been declared in the attributesForFaceting index setting with the searchable modifier.

Facet-searching only affects facet values. It does not impact the underlying index search.

The results are sorted by decreasing count. This can be adjusted via sortFacetValuesBy.

By default, maximum 10 results are returned. This can be adjusted via maxFacetHits.

Examples

iex> Algolia.search_for_facet_values("species", "phylum", "dophyta")
{
  :ok,
  %{
    "exhaustiveFacetsCount" => false,
    "faceHits" => [
      %{
        "count" => 9000,
        "highlighted" => "Pteri<em>dophyta</em>",
        "value" => "Pteridophyta"
      },
      %{
        "count" => 7000,
        "highlighted" => "Rho<em>dophyta</em>",
        "value" => "Rhodophyta"
      },
      %{
        "count" => 150,
        "highlighted" => "Cyca<em>dophyta</em>",
        "value" => "Cycadophyta"
      }
    ],
    "processingTimeMS" => 42
  }
}
Link to this function set_settings(index, settings)

Set the settings of a index

Link to this function wait(response, time_before_retry)

Convinient version of wait_task/4, accepts a response to be waited on directly. This enables piping a operation directly into wait_task

Link to this function wait_task(index, task_id, time_before_retry \\ 1000)

Wait for a task for an index to complete returns :ok when it’s done