#Medusa search issue
62 messages · Page 1 of 1 (latest)
I have added the keys in the .env file
and installed the algolia module also
warn: An error occurred while processing SEARCH_INDEX_EVENT: [object Object]
This is what I'm getting in the postman
This is my algolia index
seems like it doesn't have any data
because of that I'm not getting any hits
Medusa config plugin array:
`medusa-fulfillment-manual`,
`medusa-payment-manual`,
// To enable the admin plugin, uncomment the following lines and run `yarn add @dim swiftjs/admin`
{
resolve: "@medusajs/admin",
/** @type {import('@medusajs/admin').PluginOptions} */
options: {
autoRebuild: true,
},
},
{
resolve: `medusa-file-spaces`,
options: {
spaces_url: process.env.SPACE_URL,
bucket: process.env.SPACE_BUCKET,
endpoint: process.env.SPACE_ENDPOINT,
access_key_id: process.env.SPACE_ACCESS_KEY_ID,
secret_access_key: process.env.SPACE_SECRET_ACCESS_KEY,
},
},
{
resolve: `medusa-plugin-algolia`,
options: {
applicationId: process.env.ALGOLIA_APP_ID,
adminApiKey: process.env.ALGOLIA_ADMIN_API_KEY,
settings: {
products: {
indexSettings: {
searchableAttributes: ["title", "description"],
attributesToRetrieve: [
"id",
"title",
"description",
"handle",
"thumbnail",
"variants",
"variant_sku",
"options",
"collection_title",
"collection_handle",
"images",
],
},
transform: (product) => ({
id: product.id,
// other attributes...
}),
},
},
},
},
];```
Hi
I think when creating index its adding the description also
which is big in size
so algolia is preventing
Record at the position 0 objectID=prod_01GX8FFCFT6C8ZATJPMCM7E7K0 is too big size=15839/10000 bytes. Please have a look at https://www.algolia.com/doc/guides/sending-and-managing-data/prepare-your-data/in-depth/index-and-records-size-and-usage-limitations/#record-size-limits
Learn about the size and usage limitations of your indices, records, and queries, restrictions related to performance, and infrastructure resources.
I think if I skip saving descriptons it may work
is there any way to handle it?
like which fields we are pushing in the algolia?
You can edit the fields in the configuration. Try removing description from the attributesToRetrieve array and see if that resolves it?
Maybe also remove variants. That will be a json object an may be causing issues.
Actually, I would remove variants first and try it again. I think that is more likely to be your issue than large descriptions.
Oh ok
I will try
This does not change anything 😦
I checked the types
The function name instead of transform should be transformer
let me try
options is also a json object. try this basic config, and if that works, then you can try adding additional fields from there: settings: { products: { indexSettings: { searchableAttributes: [ "title", "description", "variant_sku", ], displayedAttributes: [ "title", "description", "variant_sku", "thumbnail", "handle", ], }, primaryKey: "id", transform: (product) => ({ id: product.id, // other attributes... }), }, },
if you can't get this basic configuration to work, then you know you have an issue that is not to do with your config options.
options and variants stick out because I know in the medusa db, those are relations and not present on the product table. I don't know enough about how meili works to know if that's causing a problem, but it's possible
{
"message": "Invalid object attributes: displayedAttributes near line:1 column:83",
"status": 400
}
I'm using free plan for algolia
ah, right. My bad. Looking at the readme for that plugin, it looks like you did already have the default config. Sorry about that. The only difference I see is the images line in the transform block. Here is the latest suggested conf from the plugin repo: const plugins = [ // ... { resolve: `medusa-plugin-algolia`, options: { applicationId: process.env.ALGOLIA_APP_ID, adminApiKey: process.env.ALGOLIA_ADMIN_API_KEY, settings: { products: { indexSettings: { searchableAttributes: ["title", "description"], attributesToRetrieve: [ "id", "title", "description", "handle", "thumbnail", "variants", "variant_sku", "options", "collection_title", "collection_handle", "images", ], }, transform: (product) => ({ id: product.id, // other attributes... }), }, }, }, }, ]
I'm getting issue because record size is getting big. When I'm transforming it, i'm getting error like this:
{
name: 'MissingObjectIDError',
message: "All objects must have an unique objectID (like a primary key) to be valid. Algolia is also able to generate objectIDs automatically but it's not recommended. To do it, use the {'autoGenerateObjectIDIfNotExist': true} option."
}
That doesn't seem to be related to size?
I might also suggest that I've found meilisearch to be super easy to use, just as an option.
does it have free option 😛
yes, it is installed locally, like postgres etc
and like redis
it's really super easy to set up, and your data doesn't have to leave your server
nice
If you are on ubuntu/debian, here are the steps I used: ```
echo "deb [trusted=yes] https://apt.fury.io/meilisearch/ /" | sudo tee /etc/apt/sources.list.d/fury.list
sudo apt update && sudo apt install meilisearch-http
sudo mkdir /var/meilisearch
sudo nano /etc/systemd/system/meilisearch.service
[Unit]
Description=Meilisearch
After=systemd-user-sessions.service
[Service]
Type=simple
WorkingDirectory=/var/meilisearch
ExecStart=/usr/bin/meilisearch --env "production" --master-key "01GQV25S0P5WJJS4758KGAQBQZ"
Restart=always
[Install]
WantedBy=multi-user.target
sudo systemctl enable meilisearch
sudo service meilisearch start```
change your key to what your real one is, that is from an old deployment log
Thank you @waxen tangle
@waxen tangle now algolia is also working 😃 i made it work with transformer. It was issue because the record in index was too big.
Also i had to pass one extra field in object using transform called "objectID" which should be unique.
I was able to fix by checking logs by adding logs in addCollectionToIndex in dist folder
Nice! It would be great if you could do a pull request to the plugin repo README file with the updated configuration requirement so that others who install going forward will not run into the same issue. Or, if you post your final config, I can do the PR. Here is the file: https://github.com/medusajs/medusa/tree/develop/packages/medusa-plugin-algolia @dim brook
hi, im also getting error saying record size is too big..
so the final solution is to upgrade the plan on algolia or did you do some work around?
I had
Wait
@waxen tangle
// {
// resolve: medusa-plugin-algolia,
// options: {
// applicationId: process.env.ALGOLIA_APP_ID,
// adminApiKey: process.env.ALGOLIA_ADMIN_API_KEY,
// settings: {
// products: {
// indexSettings: {
// searchableAttributes: ["title"],
// attributesToRetrieve: [
// "id",
// "title",
// "handle",
// "thumbnail",
// "images",
// "collection_title",
// "metadata",
// "tags"
// ],
// },
// transformer: (product) => {
// return {
// objectID: product.id,
// id: product.id,
// title: product.title,
// handle: product.handle,
// thumbnail: product.thumbnail,
// collection_title: product.collection && product.collection.title ? product.collection.title : null,
// metadata: product.metadata,
// tags: product.tags,
// images: product.images
// }
// }
// },
// },
// },
// },
This is my algolia config
Can you please raise pr
This is currently commented
Little busy
@waxen tangle you can raise pr by referring my config. Actually only problem is that in the documentation there is typo, it needs to be transformer instead of transform and this way you can modify the product saved in index. Free algolia limits the product size that gets added in the index. So by transformer I'm only saving few required fields
this needs to be done in the free version only and should not be issue in paid version