The Algoliax.Indexer
now supports dynamic definition for the :algolia
settings. It can supports 2 types of configurations:
- (Existing) Keyword list
- (New) Name of a 0-arity function that returns a keyword list
defmodule People do
use Algoliax.Indexer,
index_name: :people,
object_id: :reference,
schemas: [People],
algolia: :runtime_algolia
def runtime_algolia do
[
attribute_for_faceting: ["age"],
custom_ranking: ["desc(updated_at)"]
]
end
end
Also added 2 new exceptions for the :algolia
configuration: InvalidAlgoliaSettingsFunctionError
and InvalidAlgoliaSettingsConfigurationError
Existing direct calls to Algoliax.Settings.replica_settings/2
will still work but will not benefit from
the dynamic :algolia
configuration. Please use Algoliax.Settings.replica_settings/3
instead.
ALGOLIA_API_KEY
and ALGOLIA_APPLICATION_ID
aren't read anymore from system env variables
inside the code. Only application config is now used (as documented).
If you used these env vars, you should now read them inside the config:
config :algoliax,
api_key: System.get_env("ALGOLIA_API_KEY"),
application_id: System.get_env("ALGOLIA_APPLICATION_ID)
New if
option for replicas which decides if they should be updated or not.
- If not provided, the replica will be updated (so no impact on existing configurations)
- Must be
nil|true|false
or the name (atom) of a arity-0 func which returns a boolean - If provided, the replica will be updated only if the value is
true
or the function returnstrue
Useful for Algolia's A/B testing which requires replicas and only deploy them in production.
- Upgrading all dependencies
- Added
dependabot
to the repository
- Added new optional settings
default_filters
to be applied automatically when callingreindex
without query orreindex_atomic
. Defaults to%{}
which was the previous behavior.
defmodule BlondeBeerIndexer do
use Algoliax.Indexer,
index_name: :blonde_beers,
object_id: :name,
schemas: [Beer],
default_filters: %{where: [kind: "blonde"]} # <--- can be a map
end
defmodule BeerIndexer do
use Algoliax.Indexer,
index_name: :various_beers,
object_id: :name,
schemas: [Beer1, Beer2, Beer3],
default_filters: :get_filters # <--- can be a function
def get_filters do
%{
Beer1 => %{where: [kind: "blonde"]}, # <--- custom filter for Beer1
:where => [kind: "brune"] # <--- Will be used for Beer2 and Beer3
}
end
end
- New
CONTRIBUTING.md
file - Simplified the
config/test.exs
file - Provide a
.env.example
file to help contributors to setup their environment
- Errors for
get_object
andget_objects
are now of arity 4 and returns the original request as last attribute
- Added possibility to have multiple indexes for a model (applies for replicas as well)
- Added
build_object/2
with the index name as second parameter (useful for translations for example)
- require Elixir >= 1.15 and OTP 26
- Add wait_task/1 (https://hexdocs.pm/algoliax/Algoliax.html#wait_task/1)
- Indexer operation returns a
%Algoliax.Reponse{}
(#51)
- Ensure clean up on reindex fail
- Replace deprecated
hmac
function with new :crypto APImac
function to support OTP-24
- Drop support for OTP 21. OTP 22+ is now required.
- Welcome to the Jungle became the owner 🎉
- Add ability to define replicas
- Raise when Algolia API error
generate_secured_api_key/1
is removed in favor ofgenerate_secured_api_key/2
- Drop support of Elixir 1.9. Elixir 1.10 or greater required
- update hackney to 1.17
- add ability to customize objectID by overriding
get_object_id/1
- Make sure index is configured before any action.
- add ability to provide preloads for
reindex
andreindex_atomic
function
defmodule People do
use Algoliax.Indexer,
index_name: :people,
object_id: :reference,
schemas: [
{__MODULE__, [:animals]}
]
algolia: [
attribute_for_faceting: ["age"],
custom_ranking: ["desc(updated_at)"]
]
end
- add
generate_secured_api_key!/1
- add ability configure
:recv_timeout
for hackney. - add ability to pass query_filters or Ecto.Query to
reindex/2
.
filters = %{where: [name: "John"]}
People.reindex(filters)
query = from(p in People, where: p.name == "john")
People.reindex(query)
- improved
generate_secured_api_key/1
- remove attributes macros in favor of
build_object/1
- remove
:prepare_object
options - remove
:preloads
options
- add
prepare_object
to modify object before send to algolia - add ability to provide
build_object/1
instead of attributes - add
schemas
option to override caller
- Fix pagination when
cursor_field
different than:id
delete_object/1
andreindex
w/force_delete: true
don't need to build entire object
- change dependencies to optional (ecto)
- Move algoliax to algoliax/indexer.
# old
use Algoliax,
...
# New
use Algoliax.Indexer,
...
- Move algolia specific settings into
:algolia
option
# old
use Algoliax.Indexer,
index_name: :test,
attributes_for_faceting: ["age"],
searchable_attributes: ["full_name"],
custom_ranking: ["desc(updated_at)"],
...
# New
use Algoliax.Indexer,
index_name: :test,
algolia: [
attributes_for_faceting: ["age"],
searchable_attributes: ["full_name"],
custom_ranking: ["desc(updated_at)"]
],
...
- add option to customize column used to find records in batch (
cursor_field
) - add preloads to find records in batch.