Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
a860ca2
feat: added possibility to add indexes as a list - missing tests
quaresc May 24, 2023
32c5e2e
test: added tests to struct_test
quaresc May 24, 2023
32c92c9
test: added tests to schema_test & utils_test
quaresc May 25, 2023
40ca033
feat: added replicas configuration with multiple indexes
quaresc May 31, 2023
a6eaf49
test: added more tests to replica
quaresc May 31, 2023
e7509f3
feat: added index context to build_object
quaresc Jun 5, 2023
e5971d6
docs: added examples in readme and doc function
quaresc Jun 5, 2023
1571797
Update README.md
quaresc Jun 5, 2023
3792762
chore: PR comments
quaresc Jun 5, 2023
c9371a3
feat: added an Algoliax.Responses to group by index_name - refacto ne…
quaresc Jun 14, 2023
8a2666c
feat: refacto
quaresc Jun 14, 2023
599c79b
docs: updated doc & changelog
quaresc Jun 14, 2023
886ba55
chore: PR comment - flat_map
quaresc Jun 14, 2023
d0967f7
chore: PR comment - moduledoc typo
quaresc Jun 14, 2023
5a8793a
Update README.md
quaresc Jun 20, 2023
1fcbc20
Update CHANGELOG.md
quaresc Jun 20, 2023
8c02334
Update lib/algoliax/indexer.ex
quaresc Jun 20, 2023
100c2cd
fix: credo
quaresc Jul 20, 2023
3c83ef4
fix: handle {:not_indexable, model} when rendering response
quaresc Aug 1, 2023
d3bc39f
chore: credo Enum.reject/2
quaresc Aug 1, 2023
c6fcfec
chore: fixed broken tests due to bad rebase
quaresc Sep 20, 2023
c6c4a89
fix: handle no ecto query results (#65)
gpouilloux Nov 6, 2023
2c757fc
chore: merge main, resolve conflicts, fix new tests following macro a…
Jordan-Kowal Apr 12, 2024
43dfa26
fix: format
Jordan-Kowal Apr 12, 2024
a50b0d4
Merge pull request #59 from WTTJ/feat-multiple-indexes
Jordan-Kowal Sep 11, 2024
e8d773f
chore: fixed changelog date
Jordan-Kowal Sep 11, 2024
772f6bf
Merge pull request #72 from WTTJ/release/0-8-0
Jordan-Kowal Sep 11, 2024
7537102
feat: new default_filters settings for reindex and reindex_atomic wit…
Jordan-Kowal Jan 23, 2024
c0b7f12
doc: update changelog and indexer doc
Jordan-Kowal Jan 23, 2024
c831561
fix: format
Jordan-Kowal Apr 12, 2024
1388540
fix: update new tests with reworked macro
Jordan-Kowal Apr 12, 2024
f7e0f0c
fix: format
Jordan-Kowal Apr 12, 2024
b7bb46b
chore: updated changelog
Jordan-Kowal Sep 11, 2024
51bb312
Merge pull request #68 from WTTJ/feat-default-query-for-reindex
Jordan-Kowal Sep 11, 2024
b8eacc4
bump version
Jordan-Kowal Sep 11, 2024
e15cb82
chore: changelog
Jordan-Kowal Sep 11, 2024
b55b2d3
Merge pull request #73 from WTTJ/chore/bump-version
Jordan-Kowal Sep 11, 2024
2eb14d8
chore: upgrade deps
Jordan-Kowal Sep 11, 2024
0a6ae2b
chore: added dependabot
Jordan-Kowal Sep 11, 2024
5fcad9f
chore: remove registry
Jordan-Kowal Sep 11, 2024
28bde0f
Merge pull request #74 from WTTJ/chore/update-deps
Jordan-Kowal Sep 16, 2024
2f9b8a6
release: 8.0.2
Jordan-Kowal Sep 16, 2024
e445bff
Merge pull request #75 from WTTJ/release/0-8-2
Jordan-Kowal Sep 16, 2024
93cac01
chore(deps): bump inflex from 2.0.0 to 2.1.0 in the minors group
dependabot[bot] Sep 16, 2024
9b572c5
Merge pull request #76 from WTTJ/dependabot/hex/minors-f4f927ff0a
Jordan-Kowal Sep 16, 2024
d47fac7
chore(deps-dev): bump credo from 1.7.7 to 1.7.8 in the patches group
dependabot[bot] Sep 30, 2024
60e8c88
Merge pull request #77 from WTTJ/dependabot/hex/patches-1bca61245b
Jordan-Kowal Sep 30, 2024
863a8b6
chore(deps): bump the patches group with 2 updates
dependabot[bot] Oct 7, 2024
c74c89c
Merge pull request #78 from WTTJ/dependabot/hex/patches-be614a28c3
Jordan-Kowal Oct 7, 2024
fa047d6
feat: added to_be_deployed? option to replica for conditional deployment
Jordan-Kowal Oct 14, 2024
2d34e8a
chore: rename func and workflow for filtering replicas
Jordan-Kowal Oct 14, 2024
ec09428
chore: rename new option as if and increased version to 0.8.3
Jordan-Kowal Oct 15, 2024
6586b65
chore: update wording
Jordan-Kowal Oct 15, 2024
5ad14a6
Merge pull request #79 from WTTJ/feat/add-conditional-deploy-to-replicas
Jordan-Kowal Oct 15, 2024
3a26e32
chore(deps-dev): bump postgrex in the patches group
dependabot[bot] Oct 28, 2024
476ce73
Merge pull request #80 from WTTJ/dependabot/hex/patches-6c73a9f187
Jordan-Kowal Oct 28, 2024
6cfb6ad
chore(deps-dev): bump credo from 1.7.8 to 1.7.9 in the patches group
dependabot[bot] Nov 4, 2024
d7e045c
Merge pull request #81 from WTTJ/dependabot/hex/patches-5b7da93708
Jordan-Kowal Nov 4, 2024
9171095
chore: standardize dependabot config
davidjulien Nov 7, 2024
2232ddc
Merge pull request #84 from WTTJ/chore/add-dependabot
davidjulien Nov 7, 2024
84e0a84
chore: add workflow to publish package on release
davidjulien Nov 7, 2024
06a15f2
Merge pull request #82 from WTTJ/chore/add-workflow-to-publish-packag…
davidjulien Nov 7, 2024
13462b7
chore: add CODEOWNERS
davidjulien Nov 7, 2024
d47fb97
Merge pull request #83 from WTTJ/chore/add-codeowners
davidjulien Nov 7, 2024
e684594
chore(deps-dev): bump credo from 1.7.9 to 1.7.10
dependabot[bot] Nov 7, 2024
27e15c4
Merge pull request #85 from WTTJ/dependabot/hex/credo-1.7.10
davidjulien Nov 7, 2024
76d98e5
chore: update publish_public_package workflow
davidjulien Nov 8, 2024
03c9f1a
Merge pull request #86 from WTTJ/chore/update-publish_public_package-…
davidjulien Nov 12, 2024
a1b035b
chore(deps-dev): bump postgrex from 0.19.2 to 0.19.3
dependabot[bot] Nov 13, 2024
6b26719
Merge pull request #87 from WTTJ/dependabot/hex/postgrex-0.19.3
davidjulien Nov 13, 2024
579f860
chore(deps-dev): bump ex_doc from 0.34.2 to 0.35.0
dependabot[bot] Nov 20, 2024
79d3117
Merge pull request #88 from WTTJ/dependabot/hex/ex_doc-0.35.0
Jordan-Kowal Nov 20, 2024
5b544cd
chore(deps-dev): bump ex_doc from 0.35.0 to 0.35.1
dependabot[bot] Nov 22, 2024
8dff34b
Merge pull request #89 from WTTJ/dependabot/hex/ex_doc-0.35.1
davidjulien Nov 22, 2024
e830a6f
feat: don't read anymore ALGOLIA_API_KEY and ALGOLIA_APPLICATION_ID e…
davidjulien Nov 25, 2024
cf799f7
Merge pull request #90 from WTTJ/feat/dont-read-system-algolia-key-an…
davidjulien Nov 25, 2024
2c5031c
feat: read algolia mock port from application config during tests
davidjulien Nov 25, 2024
8fc2332
Merge pull request #91 from WTTJ/feat/read-algolia-mock-ports-from-co…
davidjulien Nov 25, 2024
cf69e07
chore: new version 0.9.0
davidjulien Nov 25, 2024
b895088
Merge pull request #92 from WTTJ/chore/new-version-0.9.0
davidjulien Nov 26, 2024
8889ed7
chore(deps): bump ecto from 3.12.4 to 3.12.5
dependabot[bot] Nov 29, 2024
d3c7ed8
Merge pull request #93 from WTTJ/dependabot/hex/ecto-3.12.5
davidjulien Nov 29, 2024
614b07c
fix: doc indexname at runtime
StephaneRob Dec 9, 2024
2cbe58c
Merge pull request #94 from WTTJ/fix-doc-indexname
StephaneRob Dec 9, 2024
c2b4bc3
feat: allow :algolia settings to be either static or dynamic
Jordan-Kowal Dec 11, 2024
bf1b777
fix: doc
Jordan-Kowal Dec 11, 2024
2f122c9
chore: simplified test
Jordan-Kowal Dec 11, 2024
70a804e
Merge pull request #95 from WTTJ/feat/dynamic-algolia-settings-config…
Jordan-Kowal Dec 12, 2024
e70fc3d
release: 0.9.1
Jordan-Kowal Dec 12, 2024
2cf187f
Merge pull request #96 from WTTJ/release/0-9-1
Jordan-Kowal Dec 12, 2024
79a2562
chore(deps-dev): bump ex_doc from 0.35.1 to 0.36.1
dependabot[bot] Dec 25, 2024
cbd6d19
Merge pull request #97 from WTTJ/dependabot/hex/ex_doc-0.36.1
davidjulien Dec 26, 2024
674025e
chore(deps-dev): bump credo from 1.7.10 to 1.7.11
dependabot[bot] Dec 30, 2024
206210c
Merge pull request #98 from WTTJ/dependabot/hex/credo-1.7.11
davidjulien Dec 30, 2024
839a094
chore(deps-dev): bump ex_doc from 0.36.1 to 0.37.0
dependabot[bot] Feb 6, 2025
5326bcd
chore(deps-dev): bump postgrex from 0.19.3 to 0.20.0
dependabot[bot] Feb 6, 2025
08e6d51
Merge pull request #100 from WTTJ/dependabot/hex/ex_doc-0.37.0
Jordan-Kowal Feb 6, 2025
26a023f
Merge branch 'main' into dependabot/hex/postgrex-0.20.0
Jordan-Kowal Feb 6, 2025
d60cbde
Merge pull request #101 from WTTJ/dependabot/hex/postgrex-0.20.0
Jordan-Kowal Feb 6, 2025
26be3b3
chore(deps-dev): bump ex_doc from 0.37.0 to 0.37.1
dependabot[bot] Feb 11, 2025
7d9267d
Merge pull request #102 from WTTJ/dependabot/hex/ex_doc-0.37.1
Jordan-Kowal Feb 11, 2025
1af5225
chore(deps-dev): bump ex_doc from 0.37.1 to 0.37.2
dependabot[bot] Feb 20, 2025
9f730f1
chore(deps): bump hackney from 1.20.1 to 1.22.0
dependabot[bot] Feb 21, 2025
1801e3a
Merge pull request #105 from WTTJ/dependabot/hex/hackney-1.22.0
davidjulien Feb 21, 2025
2464495
Merge branch 'main' into dependabot/hex/ex_doc-0.37.2
Jordan-Kowal Feb 24, 2025
54991a4
Merge pull request #104 from WTTJ/dependabot/hex/ex_doc-0.37.2
Jordan-Kowal Feb 24, 2025
00eb812
chore(deps): bump hackney from 1.22.0 to 1.23.0
dependabot[bot] Feb 26, 2025
2ea44f4
chore(deps-dev): bump plug_cowboy from 2.7.2 to 2.7.3
dependabot[bot] Feb 26, 2025
fa57473
Merge pull request #107 from WTTJ/dependabot/hex/plug_cowboy-2.7.3
Jordan-Kowal Feb 26, 2025
6786ce9
Merge branch 'main' into dependabot/hex/hackney-1.23.0
Jordan-Kowal Feb 26, 2025
8091a4d
Merge pull request #106 from WTTJ/dependabot/hex/hackney-1.23.0
Jordan-Kowal Feb 26, 2025
b9870f7
fix: update supported settings list
Jordan-Kowal Feb 26, 2025
641c0bd
chore: lint
Jordan-Kowal Feb 26, 2025
d9646d8
Merge pull request #108 from WTTJ/103-configure-synonyms
Jordan-Kowal Feb 26, 2025
cd9cf31
fix: revert hackney back to 1.21.0
Jordan-Kowal Feb 27, 2025
d38b345
Merge branch 'main' into revert-hackney-to-1.21.0
Jordan-Kowal Feb 27, 2025
756d9f5
Merge pull request #110 from WTTJ/revert-hackney-to-1.21.0
Jordan-Kowal Feb 27, 2025
b178298
feat: added new synonyms configuration either hardcoded or from func
Jordan-Kowal Feb 27, 2025
bf5a9d9
chore(deps-dev): bump ex_doc from 0.37.2 to 0.37.3
dependabot[bot] Mar 7, 2025
cd24074
Merge pull request #112 from WTTJ/dependabot/hex/ex_doc-0.37.3
davidjulien Mar 7, 2025
f8e3d7b
Merge branch 'main' into 103-configure-synonyms-on-boot
Jordan-Kowal Mar 10, 2025
f53ed4a
Merge pull request #109 from WTTJ/103-configure-synonyms-on-boot
Jordan-Kowal Mar 10, 2025
215ab42
chore: version bump and changelog update
Jordan-Kowal Mar 10, 2025
09c24d5
Merge pull request #113 from WTTJ/chore/bump-version-0-10-0
Jordan-Kowal Mar 10, 2025
f7afa68
chore(deps-dev): bump credo from 1.7.11 to 1.7.12
dependabot[bot] Apr 17, 2025
55d8aca
Merge pull request #116 from WTTJ/dependabot/hex/credo-1.7.12
Jordan-Kowal Apr 17, 2025
876cddc
chore: update CODEOWNERS
davidjulien Aug 29, 2025
c550f8a
Merge pull request #138 from WTTJ/chore/update-codeowners
davidjulien Sep 4, 2025
5d8f5a7
chore(deps): bump hackney from 1.21.0 to 1.25.0
dependabot[bot] Jul 25, 2025
9f78a08
Merge pull request #133 from WTTJ/dependabot/hex/hackney-1.25.0
davidjulien Sep 4, 2025
9ba24c1
chore(deps-dev): bump sobelow from 0.13.0 to 0.14.0
dependabot[bot] May 9, 2025
f878a62
Merge pull request #117 from WTTJ/dependabot/hex/sobelow-0.14.0
davidjulien Sep 4, 2025
58954d9
chore(deps-dev): bump mix_test_watch from 1.2.0 to 1.3.0
dependabot[bot] Jun 4, 2025
e53052e
Merge pull request #123 from WTTJ/dependabot/hex/mix_test_watch-1.3.0
davidjulien Sep 4, 2025
ca89ace
chore(deps-dev): bump ex_doc from 0.37.3 to 0.38.3
dependabot[bot] Aug 18, 2025
f94f2ee
Merge pull request #137 from WTTJ/dependabot/hex/ex_doc-0.38.3
davidjulien Sep 4, 2025
1829947
chore(deps-dev): bump ex_doc from 0.38.3 to 0.38.4
dependabot[bot] Sep 10, 2025
0391d03
Merge pull request #139 from WTTJ/dependabot/hex/ex_doc-0.38.4
davidjulien Sep 11, 2025
18d88f5
chore(deps-dev): bump mix_audit from 2.1.4 to 2.1.5
dependabot[bot] Sep 4, 2025
0d77faf
Merge pull request #124 from WTTJ/dependabot/hex/mix_audit-2.1.5
davidjulien Sep 11, 2025
253822c
chore(deps-dev): bump plug_cowboy from 2.7.3 to 2.7.4
dependabot[bot] Sep 11, 2025
3ccbbd0
Merge pull request #126 from WTTJ/dependabot/hex/plug_cowboy-2.7.4
davidjulien Sep 11, 2025
15c6961
chore(deps-dev): bump ecto_sql from 3.12.1 to 3.13.2
dependabot[bot] Sep 11, 2025
d8297da
Merge pull request #131 from WTTJ/dependabot/hex/ecto_sql-3.13.2
davidjulien Sep 11, 2025
1abea1b
chore(deps): bump ecto from 3.13.2 to 3.13.3
dependabot[bot] Sep 22, 2025
acc2bee
Merge pull request #140 from WTTJ/dependabot/hex/ecto-3.13.3
davidjulien Sep 22, 2025
980c5b8
chore(deps-dev): bump sobelow from 0.14.0 to 0.14.1
dependabot[bot] Oct 14, 2025
29e6e73
Merge pull request #141 from WTTJ/dependabot/hex/sobelow-0.14.1
davidjulien Oct 14, 2025
f89f3d8
chore(deps-dev): bump credo from 1.7.12 to 1.7.13
dependabot[bot] Oct 16, 2025
5f825c1
Merge pull request #142 from WTTJ/dependabot/hex/credo-1.7.13
davidjulien Oct 16, 2025
6c7a3fc
chore(deps-dev): bump mix_test_watch from 1.3.0 to 1.4.0
dependabot[bot] Oct 22, 2025
43c14dd
Merge pull request #143 from WTTJ/dependabot/hex/mix_test_watch-1.4.0
davidjulien Oct 23, 2025
d1ee4f3
chore(deps-dev): bump ex_doc from 0.38.4 to 0.39.1
dependabot[bot] Oct 24, 2025
bd24b73
Merge pull request #144 from WTTJ/dependabot/hex/ex_doc-0.39.1
davidjulien Oct 24, 2025
80f9d6a
chore(deps): bump ecto from 3.13.3 to 3.13.4
dependabot[bot] Oct 27, 2025
57b7602
Merge pull request #145 from WTTJ/dependabot/hex/ecto-3.13.4
davidjulien Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Test
export API_MOCK_SERVER_PORT=8002
export SLACK_MOCK_API_PORT=8002
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export DB_NAME=algoliax_test
export DB_USERNAME=postgres
export DB_PASSWORD=postgres

# Run
export ALGOLIA_API_KEY=
export ALGOLIA_APPLICATION_ID=
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @WTTJ/mission-platform-backend
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: mix
directory: "/"
schedule:
interval: daily
time: "06:00"
timezone: "Europe/Paris"
open-pull-requests-limit: 100
rebase-strategy: "disabled"
44 changes: 44 additions & 0 deletions .github/workflows/publish_public_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish package to Hex.pm

on:
release:
types: [released]

jobs:
publish:
runs-on: ubuntu-latest
if: "!github.event.release.prerelease"

steps:
- uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.17.2'
otp-version: '26.2.5.2'

- name: Install dependencies
run: |
mix deps.get

- name: Compile
run: |
mix compile

- name: Check version consistency
run: |
MIX_VERSION=$(mix run -e 'IO.puts Mix.Project.config[:version]')
RELEASE_VERSION=${{ github.event.release.tag_name }}
RELEASE_VERSION=${RELEASE_VERSION#v}

if [ "$MIX_VERSION" != "$RELEASE_VERSION" ]; then
echo "Version mismatch: mix.exs version ($MIX_VERSION) != release version ($RELEASE_VERSION)"
exit 1
fi

- name: Publish to Hex.pm
env:
HEX_API_KEY: ${{ secrets.HEXPM_PUBLIC_PACKAGES_KEY }}
run: |
mix hex.publish --yes
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# IDE
.idea/
.vscode/

# Env
.env

# The directory Mix will write compiled artifacts to.
/_build/

Expand Down
167 changes: 165 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,167 @@
# Changelog

## DEV
## v0.10.0 - 2025-03-10

### New

Added the `synonyms` settings to the `Algoliax.Indexer`.
It allows you to automatically setup synonyms for your indexes when calling `MyIndexer.configure_index()`

If not specified or set to `nil`, the synonyms will not be configured.
Otherwise, the following keywords are expected, with each key having a default value:

- `synonyms`: a list of synonym groups, as expected by Algolia. Default `[]`
- `replace_existing_synonyms`: Whether to replace existing synonyms. Default `true`
- `forward_to_replicas`: Whether to forward synonyms to replicas. Default `true`

You can also provide an arity-1 function (that takes the `index_name`) that returns the same keyword list.

If using `forward_to_replicas: true`, make sure not to specify synonyms on the replicas themselves to avoid conflicts/overwrites.

```elixir
defmodule Global do
use Algoliax.Indexer,
index_name: :people,
object_id: :reference,
schemas: People,
algolia: [
attribute_for_faceting: ["age"],
custom_ranking: ["desc(updated_at)"]
]
synonyms: [
synonyms: [
%{
objectID: "synonym1",
type: "synonym",
synonyms: ["pants", "trousers", "slacks"],
...
},
%{
objectID: "synonym2",
...
}
],
forward_to_replicas: false,
replace_existing_synonyms: false
]
end
```

### Other changes

- Updated the list of supported algolia settings.

## v0.9.1 - 2024-12-12

### New

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

```elixir
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`

### Other changes

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.

## v0.9.0 - 2024-11-26

`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:

```elixir
config :algoliax,
api_key: System.get_env("ALGOLIA_API_KEY"),
application_id: System.get_env("ALGOLIA_APPLICATION_ID)
```

## v0.8.3 - 2024-10-18

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 returns `true`

Useful for Algolia's A/B testing which requires replicas and only deploy them in production.

## v0.8.2 - 2024-09-16

- Upgrading all dependencies
- Added `dependabot` to the repository

## v0.8.1 - 2024-09-11

#### New

- Added new **optional** settings `default_filters` to be applied automatically when calling `reindex` without query
or `reindex_atomic`. Defaults to `%{}` which was the previous behavior.

```elixir
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
```

#### Contributing

- New `CONTRIBUTING.md` file
- Simplified the `config/test.exs` file
- Provide a `.env.example` file to help contributors to setup their environment

## v0.8.0 - 2024-09-11

#### Breaking changes

- Errors for `get_object` and `get_objects` are now of arity 4 and returns the original request as last attribute

#### New

- 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)

## v0.7.2 - 2023-09-18

#### Breaking changes

Expand All @@ -10,7 +171,9 @@

#### New

- Add wait_task/1 (https://hexdocs.pm/algoliax/Algoliax.html#wait_task/1)
- Add wait_task/1 (<https://hexdocs.pm/algoliax/Algoliax.html#wait_task/1>)

## v0.7.0 - 2022-03-29

#### Breaking changes

Expand Down
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing

## Install

If you are not using `asdf`, you will need to manually install the program versions listed in `.tool-versions`.
Otherwise, simply run `asdf install` and then:

```shell
mix deps.get
mix deps.compile
mix compile
```

## Run tests

Before running `mix test`, ensure you have setup your environment variables.
Look at the `.env.example` file for the required variables.
Then run `mix test` to run the tests.

## Quality

- Run `mix format` to format the code.
- Run `mix credo` to run the linter.

## CI/CD

We use CircleCI to:

- Run the code_analysis (format/credo)
- Check for vulnerabilities
- Run the tests

See the `.circleci/config.yml` file for more details.
69 changes: 67 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The package can be installed by adding `:algoliax` to your list of dependencies
```elixir
def deps do
[
{:algoliax, "~> 0.7.0"}
{:algoliax, "~> 0.10.0"}
]
end
```
Expand Down Expand Up @@ -89,6 +89,22 @@ defmodule People do
end
```

- `build_object/2` does the same but provides the current index name as a second parameter. Can be useful when indexing the same model on multiple indexes (ie. for translations).

```elixir
defmodule Article do
...

@impl Algoliax
def build_object(author, "article_index_" <> locale) do
%{
author: article.author,
content: article.content[locale]
}
end
end
```

#### Index name at runtime

It's possible to define an index name at runtime, useful if `index_name` depends on environment or comes from an environment variable.
Expand All @@ -108,6 +124,21 @@ defmodule People do
end
```

#### Multiple indexes

It's possible to define multiple indexes for a same model.

To achieve this, just specify an array of index names, or simply return an array in your `index_name/0` runtime function

```elixir
defmodule Article do
use Algoliax.Indexer,
index_name: [:algoliax_article_fr, :algoliax_article_en],
object_id: :reference,
algolia: [...]
end
```

#### Index functions

```elixir
Expand Down Expand Up @@ -238,8 +269,42 @@ use Algoliax.Indexer,
]
```

If the main index holds multiple indexes (e.g for an index per language usecase), replicas need to hold the same amount of names.
The order is important to be associated to the correct main index.

```elixir
use Algoliax.Indexer,
index_name: [:algoliax_article_en, :algoliax_article_fr],
object_id: :reference,
repo: MyApp.Repo,
algolia: [
attributes_for_faceting: ["published_at"],
searchable_attributes: ["content"],
],
replicas: [
[index_name: [:algoliax_article_by_publication_asc_en, :algoliax_article_by_publication_asc_fr], inherit: true, algolia: [ranking: ["asc(published_at)"]]],
[index_name: [:algoliax_article_by_publication_desc_en, :algoliax_article_by_publication_desc_fr], inherit: false, algolia: [ranking: ["desc(published_at)"]]]
]
```

## Configure index name at runtime

To support code for multiple environments, you can also define the index name at runtime. To achieve this, create a function within your indexer module and reference it using its atom in the Indexer configuration.

```elixir
defmodule People do
use Algoliax.Indexer,
index_name: :runtime_index_name,
#....

def runtime_index_name do
System.get_env("INDEX_NAME")
end
end
```

## Copyright and License

Copyright (c) 2020 CORUSCANT (welcome to the jungle) - https://www.welcometothejungle.com
Copyright (c) 2020 CORUSCANT (welcome to the jungle) - <https://www.welcometothejungle.com>

This library is licensed under the [BSD-2-Clause](./LICENSE.md).
Loading