🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
Integrations / Magento 2

Troubleshooting Data, Index, and Queue Issues

Most errors that you encounter when using Algolia for Magento are data or indexing related. This page addresses the most common issues.

Empty search results

When Algolia for Magento is installed, it automatically fetches the Magento product data, transforms it to a JSON structure and pushes this data to Algolia. If any problems are encountered, please make sure that:

Outdated search results

With automatic indexing turned on, the indexing happens asynchronously. It may take some time for your data to be updated.

It’s possible for the indexing queue to crash under certain circumstances. Below is a list of the most common problems you can encounter.

Network error

Network errors are typically resolved automatically thanks to the queueing process. If the network error persists over multiple queue runs, there may be a problem with the underlying infrastructure of the Magento app. When in doubt: if the problem lies with the Algolia infrastructure, please check the status page for any issues.

Memory error

Magento has some known memory leaks which cause problems when memory usage increases. When sending records to Algolia that exceed 10K in size, memory usage increases. Algolia doesn’t only suggest, but in fact requires record sizes to not exceed 10K for performance reasons.

Record size

If the total size of the index exceeds this limit, you should turn on automatic indexing through the queue. The cron job that runs the indexing will break up large indices into chunks within the size limit. When indexing without the cron job, or with the EMPTY_QUEUE=1 argument in the job, the index size isn’t checked.

Failed (re)indexing jobs

To see if any of the jobs that were created have failed, please have a look in the algoliasearch_queue table. If a job fails, it needs to be restarted. This will continue the indexing job from where it stopped, so it won’t run it in its entirety again. If the queue is enabled, the restart will happen automatically. The indexing job can be restarted manually by pressing the restart link. This can be found by clicking the index on the Magento Dashboard.

Incomplete search results

In case some products are missing from the search, please note that the Algolia extension doesn’t index products for which one of the following statements is true:

  • The product is deleted
  • The product is turned off
  • The product is out of stock and the web shop hides products that are out of stock
  • The product isn’t visible in the search and in the web shop

Only when none of the preceding statements are true will Algolia index the product, and will it show up in the search results.

Parsing errors

This error can occur during indexing when the indexed data fails to encode to JSON.

1
JSON parsing error: syntax error

This could be due to incorrect syntax like un-escaped values in your attributes.

Errors from suggestions index

The suggestions index often triggers this error. In the extension, the suggestions index pulls data from Magento’s Search Terms collection. Search Terms is a collection of all submitted queries made by the search form. The extension indexes the query_text value as is, which can sometimes throw errors if Search Terms contain malignant queries generated by bad actors like robots. Lax conditions allow indexing of irrelevant queries.

You can enforce higher conditions to reduce the less relevant Search Terms by increasing the numeric values in Stores > Algolia Search > Autocomplete Menu.

Suggestions configuration

The extension indexes search terms based on these configurations:

1
2
3
4
5
6
7
/* @see \Algolia\AlgoliaSearch\Helper\Entity\SuggestionHelper::getSuggestionCollectionQuery() */

$collection->getSelect()->where(
    'num_results >= ' . $this->configHelper->getMinNumberOfResults($storeId) . '
    AND popularity >= ' . $this->configHelper->getMinPopularity($storeId) . '
    AND query_text != "__empty__"'
);

To return more relevant results, increase these configuration values or clean up your Search Terms by manually deleting problematic query_texts values from the collection.

Record too big errors

Algolia limits individual record size for performance reasons. The limits depend on your plan. If a record is larger than the threshold, Algolia returns the error message Record is too big.

To reduce the amount of errors thrown, the extension truncates or skips attributes with values that are larger than a certain size:

Record too big error

The function below throws the warning error:

\Algolia\AlgoliaSearch\Helper\AlgoliaHelper::prepareRecords()

The private method handleTooBigRecord evaluates attributes and flags large ones.

This preventive strategy isn’t always perfect as some attributes are important for search.

How to resolve

Resolve this error by upgrading your plan or reducing attribute size.

Upgrading your plan

By default, the Algolia extension has a record size limit of 10 kB per record. If your Algolia plan allows a higher record size limit, you can customize the record size limit.

Reducing attribute size

Attributes like description, have a lot of content or hidden script tags that aren’t necessary for search. To reduce the size of this attribute, strip the HTML tags before indexing.

To change attributes before indexing, create an observer on the dispatched event for the entity you need.

For products, this event is: algolia_after_create_product_object

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

namespace Your\CustomModule\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class AlgoliaAfterCreateProductObject implements ObserverInterface
{
    public function execute(Observer $observer)
    {
        $data = $observer->getData('custom_data');
        $product = $observer->getData('productObject');

        // modify description to strip tags
        $description = $data->getData('description');
        $data->setData('description', strip_tags($description));
    }
}

Still having trouble?

Check the troubleshooting guide.

Did you find this page helpful?