Skip to content

Conversation

@bidoubiwa
Copy link
Contributor

@bidoubiwa bidoubiwa commented Oct 27, 2021

Important

  • Only works with the newest v0.24.0 version of MeiliSearch
  • Introduces a new way to index your data in MeiliSearch. You will need to re-index your content ⚠️

Important

  • ⚠️ Introduces a new way to index your data in MeiliSearch. You will need to re-index your content ⚠️
  • Only works with the newest v0.24.0 version of MeiliSearch

Features

Small changes

Custom Configuration

Inside the api/[collection]/model folder of all existing collections, there is an associated [collection_name].js file. In this condiguration file it is now possible to add information about how your collection should act with MeiliSearch.

All possible configurations are explained in the next sections.

Example

// api/restaurant/models/restaurant.js

module.exports = {
  meilisearch: {
    // parameters
  }
}

Custom Index Name

Previously, when adding a collection to MeiliSearch you had no choice on the index naming, it was the same as the collection name.

For example, when adding the restaurant collection to MeiliSearch, the indexUid inside MeiliSearch would also be called restaurant.

With this new version, it is now possible to define a custom index name in your collections model options.

// api/restaurant/models/restaurant.js

module.exports = {
  meilisearch: {
    indexName: "my_restaurants"
  }
}

Multiple collections in the same index

You can point multiple collections to the same index.
For example if you want both entries from shoes and shirts to go to the same index, they need to share the same indexName, for example clothes.

// api/shoes/models/shoes.js

module.exports = {
  meilisearch: {
    indexName: "clothes"
  }
}
// api/shirts/models/shirts.js

module.exports = {
  meilisearch: {
    indexName: "clothes"
  }
}

Transform sent data

Before, the whole entry of a collection was sent to MeiliSearch. Including all the sensitive fields about the authors for example. There was no way to decide which field to send to MeiliSearch.

It is now possible by setting a transformEntry function in the configuration file of the collection's model (lots of examples here)

Example to sanitize your field, and thus removing all sensitive data:

// api/restaurant/models/restaurant.js
const { sanitizeEntity } = require('strapi-utils')

module.exports = {
  meilisearch: {
    transformEntry({ entry, model }) {
      return sanitizeEntity(entry, { model })
    },
  },
}

For example, you can now:

  • Remove specific rows,
  • Sanitize the content of private fields
  • Change the content of a field

⚠️ Avoid playing around with the id fields as it is possible your collections may be duplicated in an index.

Error notification on failed entries indexation

When indexing a collection by clicking on the un-checked you receive a notification when the index has been created successfully in MeiliSearch.
Nonetheless, if the entries addition fails, you receive no explanation as to why. The only information you see is that the counter stays at 0.

This release tracks the entries addition process and raises error notifications as to why documents were not able to be added.

Better permission system

Since strapi-plugin-users-permissions is not a mandatory plugin, the new permission system is very basic. Now, You need to be an admin in the admin panel to access or use any of the API routes of the MeiliSearch plugin.

Use the checkbox to add collection instead of row

Previously, when clicking on the row of a collection, indexation or removal was triggered. This was non-intuitive and has been removed. Now to add or remove a collection from MeiliSearch you need to click on the checkbox

Clarity on different API keys

It was not clear that the plugin required either the master key or the private key to be able to use the plugin. This leads to users using the same key in their front end to make search requests.

You need to use the public key in your front-end app and the private or master-key in Strapi. See keys documentation

fixes: #42
fixes: #112
fixes: #193
fixes: #218
fixes: #249
fixes: #284
fixes: #279
fixes: #191
fixes: #117
fixes: #126

TODO

harish2704 and others added 30 commits October 20, 2021 18:30
Fix: include lib directory while packing

fix records count for composite index
handle "update" button for composite index

updating both develooper and end-user documentation

Fix typo in documentation

Start improving README for new features

Fix admin front errors
Fix linting

Fix method naming

Change naming to explicit collection or indexUid
Update README.md

Co-authored-by: Amélie <[email protected]>

Update README.md

Co-authored-by: Amélie <[email protected]>

Update services/collection.js

Co-authored-by: Amélie <[email protected]>

Update services/collection.js

Co-authored-by: Amélie <[email protected]>

Update services/collection.js

Co-authored-by: Amélie <[email protected]>

Remove unecessary file in package json
handle "update" button for composite index
Add possibility to chose the name of the index
@ghost
Copy link

ghost commented Nov 29, 2021

When are you planning on releasing this PR?

@bidoubiwa
Copy link
Contributor Author

@haye-webbio Today or tomorrow. I think today but just in case it might be tomorrow

@ghost
Copy link

ghost commented Nov 29, 2021

@haye-webbio Today or tomorrow. I think today but just in case it might be tomorrow

Looking forward to it! Thanks :)

bidoubiwa and others added 3 commits November 29, 2021 15:37
* Raise document addition errors
* Remove action on row click instead of checkbox click
322: Raise document errors r=bidoubiwa a=bidoubiwa

related to #126 

Co-authored-by: Charlotte Vermandel <[email protected]>
Co-authored-by: cvermand <[email protected]>
@bidoubiwa bidoubiwa added the skip-changelog The PR will not appear in the release changelogs label Nov 29, 2021
@bidoubiwa
Copy link
Contributor Author

bors merge

@bidoubiwa
Copy link
Contributor Author

bors -r

@meili-bors
Copy link
Contributor

meili-bors bot commented Nov 29, 2021

Did you mean "r-"?

@bidoubiwa
Copy link
Contributor Author

bors r-

@meili-bors
Copy link
Contributor

meili-bors bot commented Nov 29, 2021

Canceled.

Copy link

@alallema alallema left a comment

Choose a reason for hiding this comment

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

LGTM! 🌮

@bidoubiwa
Copy link
Contributor Author

bors merge

@meili-bors
Copy link
Contributor

meili-bors bot commented Nov 29, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment