algolia / algolia/search-bundle

Multiple indexes per Entity

Open
#269 4 comments 0 reactions 0 assignees View on GitHub
Feature Request
Dominant language
PHP
Stars
193
Forks
74
PR merge metrics
No merged PRs in 30d

Description

Hello !

- Symfony version: 4.1.6
- Algolia Search Bundle version: 3.3.2
- Algolia Client Version: 1.27.0
- Language Version: 7.2.7

### Description

I was trying to index the same entity twice with 2 indices name.
My goal was to leverage instantsearch.js [sortBySelector](https://community.algolia.com/instantsearch.js/v2/widgets/sortBySelector.html) widget.

So I did something like this:

```
algolia_search:
indices:
- name: publication
class: App\Entity\Publication
index_if: isPublished
enable_serializer_groups: true

- name: publication_sort_by_date_desc
class: App\Entity\Publication
index_if: isPublished
enable_serializer_groups: true
```

It looks like it was working as expected at 1st glance but no.
Only the last declared indice is pushed to Algolia. The others are not updated anymore: no clear, no update, no import, etc.

Is this something that could be interesting to support within the bundle? Am I going to the wrong direction and this feature should be implemented differently?
At the end, if this is a bad idea, an error message to prevent creating such a config could really nice for DX. Perhaps I missed something in the doc.

Cheers and thanks for this awesome bundle :+1:

Contributor guide

Open the contributing guide

Research direction

The reported entry point is the algolia_search.indices configuration; start by reproducing the two-index setup with the same entity and observe which index receives imports and updates. Determine whether multiple indices should be supported or rejected, and define done as either both indices receiving clear, import, and update operations or a clear configuration error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
backend, search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.