Smile-SA / elasticsuite

Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
https://elasticsuite.io
Open Software License 3.0
760 stars 336 forks source link

Amount of products loaded in the collection based on search criterias #3295

Closed Thomsath closed 2 weeks ago

Thomsath commented 3 weeks ago

Issue When we are on a search page matching 1000 products related to the criterias, the Elasticsuite module will request this 1000 entity ids (basically a SQL request with joins filtered on product entity_id). We believe that is bad for performances because we will only display to the user 30 products per page.

Question The aim of this post is to know if it's normal that the module request this big collection ?

Scenario I m on a product listing where 1000 products has been matching the conditions of search, on the first page. And the products listing allow displaying products 30 products per page.

Goal The Elasticsuite module request 0 to 30 products related to these criterias, and not the entire 1000 products collection, because we will display to the user only 30 products in page 1 (30 / page). On page 2, it will request the 30 next products, and so on.

Additional Information Ideally, we would like to sort the products by price.

Environment

Best regards,

romainruaud commented 3 weeks ago

Hi @Thomsath

Elasticsuite requests the amount of products that is set in the pagination :

Depending if you're using Luma-based theme or GraphQl, can you check what you have in the PageSize in your case ? This should never be 1000 but should reflect the actual page size.

Regards

Thomsath commented 2 weeks ago

Hi,

Thank for this answer. Is the $from value here https://github.com/Smile-SA/elasticsuite/blob/2.11.x/src/module-elasticsuite-catalog/Model/ResourceModel/Product/Fulltext/Collection.php#L684 related to the page number ?

Or the offset of products ?

Best regards,

romainruaud commented 2 weeks ago

It's exactly the way Elasticsearch uses it : https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html

Regards

Thomsath commented 2 weeks ago

Hi,

Thank you, it's more clear now. So I think if I would like to sort products per prices (on a 1000 collection products) and with 30 products per page it's something that the module can do on a Luma theme ?

romainruaud commented 2 weeks ago

yes, definitely, it works out-of-the-box.

You can check https://demo.magento-elastic-suite.io/ or install the plugin by yourself.

Regards

Thomsath commented 2 weeks ago

Ok, thanks for these asnwers.

Best regards,