Skip to content

Refacto rename indexName to indexUid #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 21, 2021
Merged

Refacto rename indexName to indexUid #89

merged 3 commits into from
Jun 21, 2021

Conversation

blump
Copy link

@blump blump commented Jun 9, 2021

this PR corrects the minor omnission of PR #69

this PR corrects the minor omnission of PR # 69
This does not work correctly with a UUID or ULID object as the primary key.

To index a document, no problem, Meilisearch does convert the ObjectId into a character string.

On the other hand, to delete a resource from MeiliSearch, you must indicate the ObjectId in character string in the url of the DELETE request.

While waiting for the refactoring on the objectID which will surely correct this bug (# 58).

My fix while waiting for the refacto of the objectId is to indicate the ObjectID property of the normalized object instead of entity-> getID ().
@curquiza
Copy link
Member

It seems to be the continuity of your previous job @codedge, I ask you for a review if you have time 🙂 If you don't, tell me.

@codedge
Copy link
Contributor

codedge commented Jun 10, 2021

Yes, will do!

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied your request for change @codedge! Thanks to both of you!

bors merge

@bors
Copy link
Contributor

bors bot commented Jun 21, 2021

@bors bors bot merged commit 6f58dac into meilisearch:main Jun 21, 2021
bors bot added a commit that referenced this pull request Jun 22, 2021
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants