Answer the question
In order to leave comments, you need to log in
How to sort products differently depending on category in Elasticsearch?
There is a catalog, which is built through a bunch of MySql + Elasticsearch (MySql as the main storage, Elasticsearch - as a system for filtering products that need to be shown in categories).
Additionally:
$params = [
'index' => 'products_cards',
'body' => [
'mappings' => [
'properties' => [
'price' => [
'type' => 'float'
],
'id_brand' => [
'type' => 'integer'
],
'categories' => [
'type' => 'integer'
],
'tags' => [
'type' => 'integer'
],
'prop' => [
'type' => 'object',
'properties' => [
'weight' => [
'type' => 'integer',
],
'material' => [
'type' => 'keyword',
],
]
],
],
]
]
];
Answer the question
In order to leave comments, you need to log in
Set different sortings in the code for different conditions. Search does not care about such things at all and its task is to produce relevant values. This is not a database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question