D
D
DamskiyUgodnik2020-09-19 18:32:35
elasticsearch
DamskiyUgodnik, 2020-09-19 18:32:35

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:

  • Product card - can be displayed in different categories
  • Product card - can have multiple tags
  • Goods ~50k
  • Categories ~3000


In elastic now it has something like this structure:

$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',
                        ],
                    ]
                ],
            ],

        ]
    ]
];


Everything is great with selections of products according to the necessary categories, tags and parameters. But there was a need to make their own sorting in each category.

Because with Elasticsearch the first experience (and in general there is very little experience with NoSql), no adequate solution comes to mind right off the bat.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2020-09-19
@inoise

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 question

Ask a Question

731 491 924 answers to any question