algolia / algoliasearch-magento-2-es-compatibility

Algolia Search ES Compatibility module for Magento 2 >=2.3.1 || >=2.2.8
Other
0 stars 6 forks source link

Search and Category page breaks expecting an 'aggregations' field #10

Open drpayyne opened 4 years ago

drpayyne commented 4 years ago

Hello!

I have installed this module with a local Magento v2.3.1 instance and also have a local ES cluster v6.7.2 configured. I'm able to index everything properly and instance search works as well. But the category page and search page breaks. How do I work around this issue? Also, if anyone could explain what this module actually does and what flows it affects, that would be great. Thanks!

Upon analysis of the following stack trace (truncated, due to redundant data), I noticed that \Magento\Elasticsearch\SearchAdapter\Aggregation\Builder\Term::build expects an aggregations field in the $queryResult array, whereas it has documents and a hits field which contains all the documents again. This $queryResult's origin can be traced back to fetching documents from Algolia at https://github.com/algolia/algoliasearch-magento-2-es-compatibility/blob/master/Adapter/AlgoliaElasticSearch5Adapter.php#L80 and then transformed into Elasticsearch acceptable.

1 exception(s):
Exception #0 (Exception): Notice: Undefined index: aggregations in /var/www/html/demco-m2/vendor/magento/module-elasticsearch/SearchAdapter/Aggregation/Builder/Term.php on line 26

Exception #0 (Exception): Notice: Undefined index: aggregations in /var/www/html/demco-m2/vendor/magento/module-elasticsearch/SearchAdapter/Aggregation/Builder/Term.php on line 26
<pre>#1 Magento\Elasticsearch\SearchAdapter\Aggregation\Builder\Term->build(&Magento\Framework\Search\Request\Aggregation\TermBucket#0000000057c197560000000016bd0ad6#, array('scope' => &Magento\Framework\Search\Request\Dimension#0000000057c197550000000016bd0ad6#), array(59430 => array('entity_id' => 59430, 'score' => 6950, '_id' => 59430), 59425 => array('entity_id' => 59425, 'score' => 6949, '_id' => 59425), 59533 => array('entity_id' => 59533, 'score' => 6948, '_id' => 59533), 59465 => array('entity_id' => 59465, 'score' => 6947, '_id' => 59465), 59457 => array('entity_id' => 59457, 'score' => 6946, '_id' => 59457), 59405 => array('entity_id' => 59405, 'score' => 6945, '_id' => 59405), 59407 => array('entity_id' => 59407, 'score' => 6944, '_id' => 59407), 59455 => array('entity_id' => 59455, 'score' => 6943, '_id' => 59455), 59565 => ... TRUNCATED HERE ... 48786, 'score' => 6085, '_id' => 48786), array('entity_id' => 48756, 'score' => 6084, '_id' => 48756), array('entity_id' => 48753, 'score' => 6083, '_id' => 48753), array('entity_id' => 48752, 'score' => 6082, '_id' => 48752))))) called at [vendor/algolia/algoliasearch-magento-2-es-compatibility/Adapter/AlgoliaElasticSearch5Adapter.php:89]
#3 Algolia\AlgoliaSearchElastic\Adapter\AlgoliaElasticSearch5Adapter->query(&Magento\Framework\Search\Request#0000000057c191130000000016bd0ad6#) called at [vendor/magento/module-search/Model/SearchEngine.php:42]
#4 Magento\Search\Model\SearchEngine->search(&Magento\Framework\Search\Request#0000000057c191130000000016bd0ad6#) called at [vendor/magento/framework/Search/Search.php:72]
#5 Magento\Framework\Search\Search->search(&Magento\Framework\Api\Search\SearchCriteria#0000000057c18b9e0000000016bd0ad6#) called at [vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext/Collection.php:359]
#6 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection->_renderFiltersBefore() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:342]
#7 Magento\Framework\Data\Collection\AbstractDb->_renderFilters() called at [vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext/Collection.php:410]
#8 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection->_renderFilters() called at [vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php:920]
#9 Magento\Eav\Model\Entity\Collection\AbstractCollection->load(false, false) called at [vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php:799]
#10 Magento\Catalog\Model\ResourceModel\Product\Collection->load(false, false) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#11 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->___callParent('load', array(false, false)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#12 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#13 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->___callPlugins('load', array(), array(array('joinProductsWhen...', 'add_stock_inform...', 'productCollectio...', 'loadPreview'))) called at [generated/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection/Interceptor.php:39]
#14 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->load() called at [vendor/magento/module-review/Observer/CatalogBlockProductCollectionBeforeToHtmlObserver.php:38]
#15 Magento\Review\Observer\CatalogBlockProductCollectionBeforeToHtmlObserver->execute(&Magento\Framework\Event\Observer#0000000057c18aaa0000000016bd0ad6#) called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:72]
#16 Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(&Magento\Review\Observer\CatalogBlockProductCollectionBeforeToHtmlObserver#0000000057c18aab0000000016bd0ad6#, &Magento\Framework\Event\Observer#0000000057c18aaa0000000016bd0ad6#) called at [vendor/magento/framework/Event/Invoker/InvokerDefault.php:60]
#17 Magento\Framework\Event\Invoker\InvokerDefault->dispatch(array('instance' => 'Magento\Review\O...', 'shared' => false, 'name' => 'review'), &Magento\Framework\Event\Observer#0000000057c18aaa0000000016bd0ad6#) called at [vendor/magento/module-staging/Model/Event/Manager.php:97]
#18 Magento\Staging\Model\Event\Manager->dispatch('catalog_block_pr...', array('collection' => &Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor#0000000057c1951d0000000016bd0ad6#)) called at [generated/code/Magento/Staging/Model/Event/Manager/Proxy.php:95]
#19 Magento\Staging\Model\Event\Manager\Proxy->dispatch('catalog_block_pr...', array('collection' => &Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor#0000000057c1951d0000000016bd0ad6#)) called at [vendor/magento/module-catalog/Block/Product/ListProduct.php:471]
#20 Magento\Catalog\Block\Product\ListProduct->initializeProductCollection() called at [vendor/magento/module-catalog/Block/Product/ListProduct.php:116]
#21 Magento\Catalog\Block\Product\ListProduct->_getProductCollection() called at [vendor/magento/module-catalog/Block/Product/ListProduct.php:139]
#22 Magento\Catalog\Block\Product\ListProduct->getLoadedProductCollection() called at [vendor/magento/module-catalog-search/Block/Result.php:182]
#23 Magento\CatalogSearch\Block\Result->_getProductCollection() called at [vendor/magento/module-catalog-search/Block/Result.php:206]
#24 Magento\CatalogSearch\Block\Result->getResultCount() called at [app/code/Demco/Search/view/frontend/templates/result.phtml:10]
#25 include('/var/www/html/de...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#26 Magento\Framework\View\TemplateEngine\Php->render(&Magento\CatalogSearch\Block\Result#0000000057c194a20000000016bd0ad6#, '/var/www/html/de...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#27 Magento\Framework\View\Element\Template->fetchView('/var/www/html/de...') called at [vendor/magento/framework/View/Element/Template.php:301]
#28 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:668]
#29 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:557]
#30 Magento\Framework\View\Layout->_renderBlock('search.result') called at [vendor/magento/framework/View/Layout.php:533]
#31 Magento\Framework\View\Layout->renderNonCachedElement('search.result') called at [vendor/magento/framework/View/Layout.php:488]
#32 Magento\Framework\View\Layout->renderElement('search.result', false) called at [vendor/magento/framework/View/Layout.php:585]
#33 Magento\Framework\View\Layout->_renderContainer('content', false) called at [vendor/magento/framework/View/Layout.php:535]
#34 Magento\Framework\View\Layout->renderNonCachedElement('content') called at [vendor/magento/framework/View/Layout.php:488]
#35 Magento\Framework\View\Layout->renderElement('content', false) called at [vendor/magento/framework/View/Layout.php:585]
#36 Magento\Framework\View\Layout->_renderContainer('main', false) called at [vendor/magento/framework/View/Layout.php:535]
#37 Magento\Framework\View\Layout->renderNonCachedElement('main') called at [vendor/magento/framework/View/Layout.php:488]
#38 Magento\Framework\View\Layout->renderElement('main', false) called at [vendor/magento/framework/View/Layout.php:585]
#39 Magento\Framework\View\Layout->_renderContainer('columns', false) called at [vendor/magento/framework/View/Layout.php:535]
#40 Magento\Framework\View\Layout->renderNonCachedElement('columns') called at [vendor/magento/framework/View/Layout.php:488]
#41 Magento\Framework\View\Layout->renderElement('columns', false) called at [vendor/magento/framework/View/Layout.php:585]
#42 Magento\Framework\View\Layout->_renderContainer('main.content', false) called at [vendor/magento/framework/View/Layout.php:535]
#43 Magento\Framework\View\Layout->renderNonCachedElement('main.content') called at [vendor/magento/framework/View/Layout.php:488]
#44 Magento\Framework\View\Layout->renderElement('main.content', false) called at [vendor/magento/framework/View/Layout.php:585]
#45 Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:535]
#46 Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') called at [vendor/magento/framework/View/Layout.php:488]
#47 Magento\Framework\View\Layout->renderElement('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:585]
#48 Magento\Framework\View\Layout->_renderContainer('root', false) called at [vendor/magento/framework/View/Layout.php:535]
#49 Magento\Framework\View\Layout->renderNonCachedElement('root') called at [vendor/magento/framework/View/Layout.php:488]
#50 Magento\Framework\View\Layout->renderElement('root') called at [vendor/magento/framework/View/Layout.php:954]
#51 Magento\Framework\View\Layout->getOutput() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#52 Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#53 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#54 Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', array(), array(array('layout-model-cac...'))) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:52]
#55 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:258]
#56 Magento\Framework\View\Result\Page->render(&Magento\Framework\App\Response\Http\Interceptor#0000000057c1ba5d0000000016bd0ad6#) called at [vendor/magento/framework/View/Result/Layout.php:171]
#57 Magento\Framework\View\Result\Layout->renderResult(&Magento\Framework\App\Response\Http\Interceptor#0000000057c1ba5d0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#58 Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#0000000057c1ba5d0000000016bd0ad6#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#59 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#0000000057c1ba5d0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#60 Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#0000000057c1ba5d0000000016bd0ad6#), array(array('result-messages', 'result-builtin-c...', 'result-varnish-c...'), array('pageLayoutDefaul...'))) called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:39]
#61 Magento\Framework\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#0000000057c1ba5d0000000016bd0ad6#) called at [vendor/magento/framework/App/View.php:221]
#62 Magento\Framework\App\View->renderLayout() called at [vendor/magento/module-catalog-search/Controller/Result/Index.php:138]
#63 Magento\CatalogSearch\Controller\Result\Index->getCacheableResult(&Magento\CatalogSearch\Helper\Data\Interceptor#0000000057c1beec0000000016bd0ad6#, &Magento\Search\Model\Query#0000000057c1beee0000000016bd0ad6#, NULL) called at [vendor/magento/module-catalog-search/Controller/Result/Index.php:108]
#64 Magento\CatalogSearch\Controller\Result\Index->execute() called at [vendor/magento/framework/App/Action/Action.php:108]
#65 Magento\Framework\App\Action\Action->dispatch(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#66 Magento\CatalogSearch\Controller\Result\Index\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#67 Magento\CatalogSearch\Controller\Result\Index\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/module-customer-segment/Model/App/Action/ContextPlugin.php:81]
#68 Magento\CustomerSegment\Model\App\Action\ContextPlugin->aroundDispatch(&Magento\CatalogSearch\Controller\Result\Index\Interceptor#0000000057c1b8a30000000016bd0ad6#, &Closure#0000000057c1b8a10000000016bd0ad6#, &Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#69 Magento\CatalogSearch\Controller\Result\Index\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/module-company/Plugin/Framework/App/Action/AbstractActionPlugin.php:65]
#70 Magento\Company\Plugin\Framework\App\Action\AbstractActionPlugin->aroundDispatch(&Magento\CatalogSearch\Controller\Result\Index\Interceptor#0000000057c1b8a30000000016bd0ad6#, &Closure#0000000057c1b8a10000000016bd0ad6#, &Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#71 Magento\CatalogSearch\Controller\Result\Index\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#72 Magento\CatalogSearch\Controller\Result\Index\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#), NULL) called at [generated/code/Magento/CatalogSearch/Controller/Result/Index/Interceptor.php:26]
#73 Magento\CatalogSearch\Controller\Result\Index\Interceptor->dispatch(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/App/FrontController.php:159]
#74 Magento\Framework\App\FrontController->processRequest(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#, &Magento\CatalogSearch\Controller\Result\Index\Interceptor#0000000057c1b8a30000000016bd0ad6#) called at [vendor/magento/framework/App/FrontController.php:99]
#75 Magento\Framework\App\FrontController->dispatch(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#76 Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', array(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#77 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94]
#78 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(&Magento\Framework\App\FrontController\Interceptor#0000000057c1bbb50000000016bd0ad6#, &Closure#0000000057c1bba80000000016bd0ad6#, &Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#79 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69]
#80 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(&Magento\Framework\App\FrontController\Interceptor#0000000057c1bbb50000000016bd0ad6#, &Closure#0000000057c1bba80000000016bd0ad6#, &Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:135]
#81 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#82 Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', array(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#), NULL) called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#83 Magento\Framework\App\FrontController\Interceptor->dispatch(&Magento\Framework\App\Request\Http#0000000057c1baba0000000016bd0ad6#) called at [vendor/magento/framework/App/Http.php:136]
#84 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:258]
#85 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#0000000057c1ba5b0000000016bd0ad6#) called at [index.php:39]
</pre>
bsuravech commented 4 years ago

Hello @drpayyne !

The module's purpose is the help with backend rendering by replacing the results from elasticsearch with the ones returned by Algolia. With that being the case, the attributes in the layered navigation rendered in the frontend are trying to be returned on the frontend. Are there any product attributes set to display as a filter in Magento that aren't set as facet attributes for Algolia?

I'm reviewing the module now for a fix. Will follow up with a PR or an update as soon as we learn more. Let us know about your settings! Thanks!

drpayyne commented 4 years ago

So this doesn’t involve the flows of indexing or Algolia quick search?

Sure, I’ll check my settings and get back to you, @bsuravech.

drpayyne commented 4 years ago

Hi @bsuravech, I ran a query in Magento to check the number of filterable product attributes using the query SELECT attribute_code FROM eav_attribute WHERE attribute_id IN( SELECT attribute_id FROMcatalog_eav_attributeWHERE is_filterable_in_search = 1 ) and got the count as 222. Whereas we have only 9 attributes configured as facets under Magento Admin > Stores > Configuration > Algolia Search > Instant Search Results Page > Facets. Is this what you had asked or have I misunderstood? Thanks.