M
M
Mikhailo Poberezhny2017-04-18 22:38:19
elasticsearch
Mikhailo Poberezhny, 2017-04-18 22:38:19

How to sort in elasticsearch?

I have a Users table, in elastic I make a selection on it.
I have a field in each object that contains an array of dates:

{
  _id: <user id>,
  dates: [..., {dataFrom: <dateFrom>, dateTo: <dateTo>}]
}

You need to sort by the dateFrom key of the last object in the dates array.
Help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2017-04-19
@leahch

Somehow your data is wrong for this. It would be better to break each entry into separate documents: id, dateFrom, dateTo. And the problem would be solved automatically.
Well, as an option, do sorting outside the elastic after the selection.
And another option is to duplicate entries in a separate index for separate documents, as I wrote above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question