medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
23.74k stars 2.29k forks source link

Meilisearch not indexing anything other than products #7585

Open BorisKamp opened 1 month ago

BorisKamp commented 1 month ago

Hi!

Using medusa 1.20.6 and medusa-plugin-meilisearch 2.0.10 im unable to get meilisearch to index anything other than products....

here's my config:

{
    resolve: `medusa-plugin-meilisearch`,
    options: {
      // config object passed when creating an instance
      // of the MeiliSearch client
      config: {
        host: process.env.MEILISEARCH_HOST,
        apiKey: process.env.MEILISEARCH_API_KEY,
      },
      settings: {
        products: {
          indexSettings: {
            searchableAttributes: ['title', 'description'],
            displayedAttributes: [
              'title',
              'description',
              'thumbnail',
              'handle',
            ],
          },
          primaryKey: 'id',
          transformer: (product) => ({
            id: product.id,
            title: product.title,
            description: product.description,
            thumbnail: product.thumbnail,
            handle: product.handle,
          }),
        },
        customers: {
          indexSettings: {
            searchableAttributes: ['email', 'first_name', 'last_name'],
            displayedAttributes: ['email', 'first_name', 'last_name'],
          },
          primaryKey: 'id',
          transformer: (customer) => ({
            id: customer.id,
            bb_company_slug: customer.bb_company_slug,
            first_name: customer.first_name,
            last_name: customer.last_name,
          }),
        },
        orders: {
          indexSettings: {
            searchableAttributes: [
              'bb_company_slug',
              'picqer_order_id',
              'picqer_id_order',
            ],
            displayedAttributes: [
              'bb_company_slug',
              'picqer_order_id',
              'picqer_id_order',
            ],
          },
          primaryKey: 'id',
          transformer: (order) => ({
            id: order.id,
            bb_company_slug: order.bb_company_slug,
            picqer_order_id: order.picqer_order_id,
            picqer_id_order: order.picqer_id_order,
          }),
        },
      },
    },
  },

Meilisearch is running in docker.

What am I doing wrong?

BorisKamp commented 1 month ago

This is my docker-compose.yml by the way

services:
  meilisearch:
    container_name: meilisearch.container.birdblocker-medusa.local
    image: getmeili/meilisearch:latest
    environment:
      - MEILI_MASTER_KEY=ALeVKQMMLxF9hTBgDnjgcv4xkqUG6GE
      - MEILI_NO_ANALYTICS=true
      - MEILI_ENV=development
    ports:
      - 7700:7700
    networks:
      - birdblocker-medusa-net

networks:
  birdblocker-medusa-net:
adevinwild commented 1 month ago

Issue solved, basically the Meilisearch plugin, is not designed to have indexes other than products, so we created a new subscriber to inject these new indexes ourselves.