Troubleshooting Data, Index, and Queue Issues
On this page
Most errors that you will encounter when using Algolia for Magento are data or indexing related. We’ve created this page to address data-related 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:
- The App ID and API Keys are correct
- The queue is running in case automatic indexing is turned on.
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 application. When in doubt: if the problem lies with the Algolia infrastructure, please have a look at our status page to see if there are any problems.
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 does not 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, it is recommended to 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 will not be 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 will not 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 does not index products for which one of the following statements is true:
- The product is deleted
- The product is disabled
- The product is out of stock and the webshop hides products that are out of stock
- The product is not visible in the search and in the webshop
Only when none of the above statements are true will Algolia index the product, and will it show up in the search results.
Still having problems? Take a look here.
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 unescaped 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 > Configuration > Algolia Search > Autocomplete.
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:
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
There are two options that can resolve this error: upgrading your plan or reducing attribute size.
Upgrading your plan
As mentioned before, record size limits depend on your plan. Upon installation, the extension fetches your plan’s record size limit and saves it to Magento’s configuration data under this path:
algoliasearch_advanced/advanced/max_record_size_limit
If you upgraded your limit, unset this value in the core_config_data
table. This forces the extension to fetch the plan value again and store it. The default value is 10 KB.
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
Refer to the customisation guide for more details on updating attribute data. For this example, you can leverage the native PHP function strip_tags()
to strip the HTML tags out. Below is an example of the product observer to update the description attribute:
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));
}
}