0

I'm using elasticsearch 7.7 and I have product documents which are like following :

[
     {"id": 1, "title": "product 1", "status": "available"},
     {"id": 2, "title": "product 2", "status": "will_be_available_soon"},
     {"id": 3, "title": "product 3", "status": "not_available"},
     {"id": 4, "title": "product 4", "status": "never_will_be_available_again"},
]

In my search queries I want to sort my products in a way that first I see available products, then I want to see will_be_available_soon products and after that not_available and of course at last never_will_be_available_again. and for products with the same status I want to sort based on their matching score.

Majid Abdolhosseini
  • 2,191
  • 4
  • 31
  • 59

1 Answers1

0

You can run a custom query script. Have a look on this discussion: https://discuss.elastic.co/t/sorting-or-ordering-by-specific-values/67244/2 Another option is the score but might be an issue in a future.

Tiago Mateus
  • 356
  • 4
  • 17