You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
92: Allowing different entities indexed into same index r=curquiza a=codedge
While this PR got out of control 😄 and poses a bigger rewrite of the tests, it addresses multiple issues.
## Passing index names via command line
Passing index name via command line now takes care if the name of the is already prefixed or not. Running
- `bin/console meili:import --indices=prefix_indexName`
- `bin/console meili:import --indices=indexName`
leads to the same index creations which is `prefix_indexName` - given the `prefix` hold a value.
## Indexing different models into the same index
See #90
Although MS supports importing different models into the same index, this was not easiliy possible using this package.
The configuration in `meili_search.yml` would not allowe to set the same index name twice.
Now you can do the following
```yaml
meili_search:
# Other...
indices:
- name: tags
class: 'MeiliSearch\Bundle\Test\Entity\Tag'
index_if: isPublic
# Yes, we want to have links in the same index as tags
# We just set the same index name 'tags'
- name: tags
class: 'MeiliSearch\Bundle\Test\Entity\Link'
index_if: isSponsored
```
This would lead to the result of having models of `Tag` and `Link` inside the very same index `tags`.
⚠️ Make sure your identity key is unique across both models. Given you use a field `id`, the value of this needs to be unique across both models.
@curquiza When the PR is approved and merged this should be documented inside a the wiki.
## Using aggregators
See #90
You can now create an aggregator, register your models and will get an aggregated index created in MS. As the identity field of each model is used as identity field in the aggregated index...
> Make sure your identity key is unique across both models. Given you use a field `id`, the value of this needs to be unique across both models.
@curquiza When the PR is approved and merged this should be documented inside a the wiki.
## Fixing inconsistency
See #89
Fixes some left of overs from refatoring `indexName` -> ìndexUid`. #89 is outdated with this PR here.
## Further changes
- No separate folder to hold the test database in `tests/blog.sqlite`. Just use the `var/test.sqlite` folder which already holds cached/runtime data.
- Reset the database and MS instance for each test via the `setUp` method. No need to have a dedicated `refreshDb` and `clearUp` call spread across the test. Each test should be atomic and not relying on former data. So 🗑️ everything 😃
- Update the `phpunit.xml` to the more recent format using the [`--migrate-configuration`](https://phpunit.readthedocs.io/en/9.5/textui.html?highlight=migrate#command-line-options) option.
- Updating the test entities to make it easier with having properties inside the database and imported into MS.
- Converting the config to a `Collection` object, see `illuminate/collection`. Makes it a lot easier to deal with, if you ask me 🙈
Co-authored-by: Holger Lösken <[email protected]>
0 commit comments