Custom sorting

I have documents like:

POST /your-index-name/_doc/1
{
  "bbCategories": ["Shirts"],
  "otherField": "value1"
}

POST /your-index-name/_doc/2
{
  "bbCategories": ["Trousers"],
  "otherField": "value2"
}

POST /your-index-name/_doc/3
{
  "bbCategories": ["Dresses"],
  "otherField": "value3"
}
POST /your-index-name/_doc/4
{
  "bbCategories": ["Shirts"],
  "otherField": "value4"
}

POST /your-index-name/_doc/5
{
  "bbCategories": ["Shirts"],
  "otherField": "value5"
}
POST /your-index-name/_doc/6
{
  "bbCategories": ["Trousers"],
  "otherField": "value6"
}

POST /your-index-name/_doc/7
{
  "bbCategories": ["Trousers"],
  "otherField": "value7"
}
POST /your-index-name/_doc/8
{
  "bbCategories": ["Dresses"],
  "otherField": "value8"
}

POST /your-index-name/_doc/9
{
  "bbCategories": ["Dresses"],
  "otherField": "value9"
}

I want to sort my elastic results by field 'bbCategories', but in specific way.

The results should have next order:
Shirts1, Trousers1, Dresses1, Shirts2, Trousers2, Dresses2, Shirts3, Trousers3, Dresses3.

The question: is it possible to achieve? I tried to create sort script, but seams that elastic can't save the conditions.

What did you try? And how the order should be computed? What is the exact rule?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.