Skip to content
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

MeiliSearch plugin creates index but does not add documents #5902

Closed
genox opened this issue Dec 15, 2023 · 7 comments
Closed

MeiliSearch plugin creates index but does not add documents #5902

genox opened this issue Dec 15, 2023 · 7 comments

Comments

@genox
Copy link

genox commented Dec 15, 2023

Bug report

I followed the Quickstart guide on the medusa website. I have a pristine Meilisearch instance, all medusa packages are up to date. I have the latest version of every medusa package installed, I double checked that since various sources here mention that this will fix the issue. I have a minimal plugin configuration, only host and key is set. I use custom attributes on the Product entity.

When I start medusa, I see that there is an event generated:

info:    Processing SEARCH_INDEX_EVENT which has 1 subscribers

In the meilisearch UI I can see that the index products has been created, but there are no documents.

There are no further relevant log entries or messages regarding the indexing.

Editing a product triggers an event, too, but there is no indexing happening and there are no further messages.

System information

  "dependencies": {
    "@medusajs/admin": "7.1.9",
    "@medusajs/cache-inmemory": "^1.8.10",
    "@medusajs/cache-redis": "1.9.0",
    "@medusajs/event-bus-local": "^1.9.7",
    "@medusajs/event-bus-redis": "1.8.10",
    "@medusajs/medusa": "1.19.0",
    "@medusajs/medusa-cli": "^1.3.22",
    "@medusajs/ui": "2.2.4",
    "@tanstack/react-query": "4.22.0",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "cross-env": "^7.0.3",
    "dotenv": "16.3.1",
    "express": "^4.18.2",
    "medusa-file-minio": "1.3.0",
    "medusa-fulfillment-manual": "1.1.38",
    "medusa-interfaces": "1.3.7",
    "medusa-payment-manual": "1.0.24",
    "medusa-payment-stripe": "6.0.6",
    "medusa-plugin-meilisearch": "^2.0.10",
    "medusa-plugin-variant-images": "1.0.4",
    "prism-react-renderer": "2.0.6",
    "typeorm": "0.3.16"
  },

Steps to reproduce the behavior

Try to add the plugin to an existing project and try to index products?

Expected behavior

  1. creation of the index
  2. population of the index with documents

Speculations

I assume the method that tries to put together an indexable document based on the Product entity fails. But the subscriber doesn't log anything to the console. Custom attributes maybe? Are there any known limitations and pitfalls?

Please don't suggest to update packages, I did that already and triple checked.. rm -rf node_modules && rm -f yarn.lock etc included.

@genox
Copy link
Author

genox commented Dec 15, 2023

Ok this is .. confusing.

On a hunch, I installed "@medusajs/utils": "^1.11.2",, deleted the existing index and restarted medusa.

Lo and behold, the index was created.

The problem is, there is no mention anywhere that @medusajs/utils is required as a dependency and no warning or error notifies the user that it should be there.

And the medusa starter project that I used does not install this package either, neither does medusa new

@genox
Copy link
Author

genox commented Dec 15, 2023

See: https://github.com/medusajs/medusa/blob/develop/packages/medusa-plugin-meilisearch/package.json

Please note that the current package.json of medusa-plugin-meiliisearch explicitly demands "@medusajs/utils": "^1.9.4",

So, well, it was an outdated dependency after all. But the issue is with the plugin referring to an outdated version and yarn being very exact on which version to install, despite the fact that the version number is prefixed with ^

Please note the output of yarn why @medusajs/utils:

├─ @medusajs/core-flows@npm:0.0.3
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/event-bus-local@npm:1.9.7
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.9.2)
│
├─ @medusajs/event-bus-redis@npm:1.8.10
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.9.2)
│
├─ @medusajs/link-modules@npm:0.2.5
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/medusa-cli@npm:1.3.22
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/medusa@npm:1.19.0
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/medusa@patch:@medusajs/medusa@npm%3A1.19.0#./.yarn/patches/@medusajs-medusa-npm-1.19.0-3db0e6d4bd.patch::version=1.19.0&hash=023e96&locator=backend%40workspace%3A.
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/medusa@patch:@medusajs/medusa@npm%3A1.19.0#./.yarn/patches/@medusajs-medusa-npm-1.19.0-3db0e6d4bd.patch::version=1.19.0&hash=023e96&locator=backend%40workspace%3A. [f5126]
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/modules-sdk@npm:1.12.5
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/orchestration@npm:0.5.1
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ @medusajs/workflows-sdk@npm:0.1.0
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.1)
│
├─ backend@workspace:.
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.11.2)
│
├─ medusa-plugin-meilisearch@npm:2.0.10
│  └─ @medusajs/utils@npm:1.11.2 (via npm:^1.9.4)
│
└─ medusa-plugin-meilisearch@npm:2.0.10 [f5126]
   └─ @medusajs/utils@npm:1.11.2 (via npm:^1.9.4)

I assume we can blame yarn for this issue, but maybe it would be still good to bump the versions in plugins to prevent this from happening again and again (I am not the first, nor will I be the last to spend an afternoon trying to get this to work).

Or maybe just add the module to the starter at the latest version on the top-level package.json.

@megaarmos
Copy link

megaarmos commented Dec 15, 2023

After an extended period of attempting to resolve the issue without success, I finally managed to retrieve the documents by simply using npm instead of yarn.

@olivermrbl
Copy link
Contributor

Thanks for sharing your findings @genox. We are aware of the versioning issue and are currently working to find a good solution to it :)

@DoubleOTheven
Copy link

I have the same issue. 1 subscriber, it creates the index, but no records are uploaded to Meilisearch and no errors are in the console. I've set logging to verbose. Here are my dependencies:

"dependencies": {
		"@medusajs/admin": "latest",
		"@medusajs/cache-inmemory": "latest",
		"@medusajs/cache-redis": "^1.9.0",
		"@medusajs/event-bus-local": "latest",
		"@medusajs/event-bus-redis": "^1.8.12",
		"@medusajs/file-local": "latest",
		"@medusajs/medusa": "latest",
		"@medusajs/utils": "^1.11.8",
		"@tanstack/react-query": "4.22.0",
		"body-parser": "^1.19.0",
		"cors": "^2.8.5",
		"dotenv": "16.3.1",
		"express": "^4.17.2",
		"medusa-fulfillment-manual": "latest",
		"medusa-interfaces": "latest",
		"medusa-payment-manual": "latest",
		"medusa-payment-stripe": "latest",
		"medusa-plugin-algolia": "^0.2.20",
		"medusa-plugin-meilisearch": "^2.0.10",
		"prism-react-renderer": "^2.0.4",
		"typeorm": "^0.3.16"
	},

Medusa Config:

 {
    resolve: 'medusa-plugin-meilisearch',
    options: {
      config: {
        host: process.env.MEILISEARCH_HOST,
        apiKey: process.env.MEILISEARCH_API_KEY,
      },
      settings: {
        indexName: {
          indexSettings: {
            searchableAttributes: ['title', 'description'],
            displayedAttributes: ['id', 'title', 'description'],
          },
        },
      },
    },
  },

@MohmDev
Copy link

MohmDev commented Jun 1, 2024

Ok this is .. confusing.

On a hunch, I installed "@medusajs/utils": "^1.11.2",, deleted the existing index and restarted medusa.

Lo and behold, the index was created.

The problem is, there is no mention anywhere that @medusajs/utils is required as a dependency and no warning or error notifies the user that it should be there.

And the medusa starter project that I used does not install this package either, neither does medusa new

@genox I was stuck on the same problem and this solved it for me. Thanks for sharing!

@meyvan
Copy link

meyvan commented Sep 10, 2024

this is still not working. im using npm and installed medusa/utils. it is not working at all

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

No branches or pull requests

6 participants