shopinvader / locomotive-shopinvader

LocomotiveCMS Plugin for Shopinvader
https://shopinvader.com
MIT License
12 stars 15 forks source link

[IMP] elasticsearsh: Allows to specify default sort order #43

Closed lmignon closed 5 years ago

lmignon commented 5 years ago

the value into the site configurations could be { 'my_index_name'= [{'name.keyword': 'asc'}]}

sebastienbeau commented 5 years ago

@thibaultrey @lmignon I think it's better to define the sort at elastic index level. Indeed Elastic have the concept of "index sorting" (Algolia have the same concept) https://www.elastic.co/fr/blog/index-sorting-elasticsearch-6-0 The main idea is that the record are physical ordered in the index, and so doing a request avoid to read all matching document. See documentation here: https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-index-sorting.html So I think it's better in performance and in practice to configure this in the schema (Odoo already push it) and not at the request level

lmignon commented 5 years ago

@sebastienbeau I've read the same part of the documentation but I've another understanding of the way it work. Index sorting is a way to tell Elasticsearch how to order the documents on disk. This order is not the one used to return the record by default; This order will improve the performance if you query the index with the same sort criteria. Indeed, in such a case, elastic knows that the documents are stored in the same order as the requested one and don't need to load all the documents to perform the ordering. That means that you must always specify the expected sort order when querying elasticsearh... All the tests done seems to valid my understanding of the index sorting into Elasticsearch