Repository: meilisearch/strapi-plugin-meilisearch (js)

Issue:
i18n page/document search not working as expected 
**Description**
I'm working on adding multi-language pages to the search collection. Following the documentation, I've added `locale: 'all'` to the `entriesQuery` property in the plugin config (see the included screenshot) to include all pages (documents) in the search.

**Expected behavior**
I expect that the pages for all languages get added to Meilisearch.

**Current behavior**
Currently when clicking the update button on a page no pages get added. When i change de `local: 'all'` to a specific language like 'en' the pages (documents) for this language get added

**Screenshots or Logs**
![config](https://github.com/user-attachments/assets/8fdfbff4-fa1c-4193-b9b2-e105eb312c9c)

`locale: 'all'`
![all](https://github.com/user-attachments/assets/0545c676-fb7d-4582-a1fe-9fe9d585b495)

`locale: 'en'`
![en](https://github.com/user-attachments/assets/0cbea0eb-d980-476a-ad61-3acd3adb0293)

**Environment (please complete the following information):**
- OS: Windows 11, strapi hosted on Docker (WSL)
- Meilisearch version: 1.11.3
- strapi-plugin-meilisearch version: 0.13.1
- Browser: Microsoft Edge (chromium) Version 131.0.2903.70
- Strapi version: 5.4.2


Pull request description:
Add support for indexing with wildcard locale
# Pull Request

## Related issue
Fixes #988 

## What does this PR do?
- Adds back support for indexing (all) localised content types in Strapi.
- Updates README and examples

The [i18n plugin](https://docs-v4.strapi.io/dev-docs/plugins/i18n) in Strapi 4 to localise content used the key-value pair `locale: 'all'` in the `entriesQuery` to query entries in all locales. [This is reflected in the `strapi-plugin-meilisearch` README](https://github.com/meilisearch/strapi-plugin-meilisearch?tab=readme-ov-file#-entries-query). 

[In Strapi 5, i18n is now part of the Strapi core](https://docs.strapi.io/dev-docs/migration/v4-to-v5/breaking-changes/i18n-content-manager-locale). With this change, the key-value pair changed to `locale: '*'`. 

(Or perhaps this change happened together with the move from the [Entity Service API](https://docs.strapi.io/dev-docs/api/entity-service/crud) to the [Document Service API](https://docs.strapi.io/dev-docs/api/document-service)). Reading the code, it appears that this plugin already uses the Document Service, but the [link in the `strapi-plugin-meilisearch` README still points to the Entity Service](https://github.com/meilisearch/strapi-plugin-meilisearch?tab=readme-ov-file#-entries-query). Regardless of whether the root cause is the Strapi 4 + i18n / Strapi 5 change, or the Entity Service / Document Service change, I've updated the README to point to the correct docs.)

This PR only _adds_ support for the wildcard `*` locale, and left support in for the `all` locale, used previously, maintaining backwards compatibility. I've updated the README to reflect usage first and foremost with Strapi 5, with a small note for usage with Strapi 4.

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thanks for the work on the plugin, happy to hear your thoughts and make adjustments to the PR as needed!


Patch:
diff --git a/README.md b/README.md
index c2a9f4a..3c7958a 100644
--- a/README.md
+++ b/README.md
@@ -427,9 +427,9 @@ The options you can set are described in the [`findMany` documentation](https://
 
 **Common use cases**
 
-If you are using the [🌍 Internationalization (i18n)](https://docs.strapi.io/developer-docs/latest/plugins/i18n.html) plugin, an additional field `locale` should also be added in `entriesQuery`.
+If you are localizing your Strapi content, an additional field `locale` should also be added in `entriesQuery`.
 
-⚠️ Warning: if you do not specify `locale: "all"` in `entriesQuery`, you may not index all available entries, potentially leading to missing products in your search results. To ensure all entries in every language are indexed in Meilisearch, include the `locale` field with the value 'all'.
+⚠️ Warning: if you do not specify `locale: "*"` in `entriesQuery`, you may not index all available entries, potentially leading to missing products in your search results. To ensure all entries in every language are indexed in Meilisearch, include the `locale` field with the value 'all'.
 
 ```js
 module.exports = {
@@ -437,7 +437,7 @@ module.exports = {
     config: {
       restaurant: {
         entriesQuery: {
-          locale: 'all',
+          locale: '*',
         },
       },
     },
@@ -445,6 +445,8 @@ module.exports = {
 }
 ```
 
+If you are using Strapi 4 with the [🌍 Internationalization (i18n)](https://docs.strapi.io/developer-docs/latest/plugins/i18n.html) plugin, the `locale` field should be set to `all`.
+
 If you want to add a collection with a relation to the collection being included, you have to configure the `populate` parameter in `entriesQuery`. See [the docs](https://docs.strapi.io/dev-docs/api/entity-service/populate) on how it works, and [an example](./resources/entries-query/populate.js) in our resources.
 
 **Example**
diff --git a/resources/entries-query/locale.js b/resources/entries-query/locale.js
index 2f11369..d16fda5 100644
--- a/resources/entries-query/locale.js
+++ b/resources/entries-query/locale.js
@@ -4,7 +4,7 @@ module.exports = {
     config: {
       restaurant: {
         entriesQuery: {
-          locale: 'all',
+          locale: '*',
         },
       },
     },
diff --git a/server/src/services/meilisearch/config.js b/server/src/services/meilisearch/config.js
index f819b3a..b29e51d 100644
--- a/server/src/services/meilisearch/config.js
+++ b/server/src/services/meilisearch/config.js
@@ -243,8 +243,10 @@ export default ({ strapi }) => {
 
     /**
      * Remove language entries.
-     * In the plugin entriesQuery, if `locale` is set and not equal to `all`
-     * all entries that do not have the specified language are removed.
+     * In the plugin entriesQuery, if `locale` is set and not equal to
+     * `all` (used with the i18n plugin for Strapi) or `*` (used with Strapi 5
+     * native localization), all entries that do not have the specified
+     * language are removed.
      *
      * @param {object} options
      * @param {Array<Object>} options.entries - The entries to filter.
@@ -258,7 +260,11 @@ export default ({ strapi }) => {
 
       const entriesQuery = contentTypeConfig.entriesQuery || {}
 
-      if (!entriesQuery.locale || entriesQuery.locale === 'all') {
+      if (
+        !entriesQuery.locale ||
+        entriesQuery.locale === 'all' ||
+        entriesQuery.locale === '*'
+      ) {
         return entries
       } else {
         return entries.filter(entry => entry.locale === entriesQuery.locale)


Test patch:
diff --git a/server/src/__tests__/configuration.test.js b/server/src/__tests__/configuration.test.js
index 764c3a1..095cca2 100644
--- a/server/src/__tests__/configuration.test.js
+++ b/server/src/__tests__/configuration.test.js
@@ -393,6 +393,34 @@ describe('Test Meilisearch plugin configurations', () => {
     expect(entries).toEqual([{ id: 1, locale: 'fr' }])
   })
 
+  test('Test should not remove any entries with wildcard locale', async () => {
+    const customStrapi = createStrapiMock({
+      restaurantConfig: {
+        entriesQuery: {
+          locale: '*',
+        },
+      },
+    })
+
+    const contentType = 'restaurant'
+    const meilisearchService = createMeilisearchService({
+      strapi: customStrapi,
+    })
+
+    const entries = meilisearchService.removeLocaleEntries({
+      contentType,
+      entries: [
+        { id: 1, locale: 'fr' },
+        { id: 2, locale: 'en' },
+      ],
+    })
+
+    expect(entries).toEqual([
+      { id: 1, locale: 'fr' },
+      { id: 2, locale: 'en' },
+    ])
+  })
+
   test('Test should keep unpublished entries when status is set to draft', async () => {
     const customStrapi = createStrapiMock({
       restaurantConfig: {