Sorting in facets


(Martin Bednář) #1

Hi,

When I use custom facets (based on imotov/elasticsearch-facet-script), are
data in mapping phase sorted, when I use sort:{} in query ?
Or how can I get sorted data in mapping phase ?

Thx Bedy

--


(Igor Motov) #2

No, it's not sorted. Moreover, mappers are running on individual shards and
possible different nodes, so they don't even see all data. If you want data
sorted, you would have to sort it yourself in mappers and then merge sort
results in the reducer.

On Wednesday, October 31, 2012 10:34:23 AM UTC-4, Martin Bednář wrote:

Hi,

When I use custom facets (based on imotov/elasticsearch-facet-script),
are data in mapping phase sorted, when I use sort:{} in query ?
Or how can I get sorted data in mapping phase ?

Thx Bedy

--


(Martin Bednář) #3

Hi Igor,

I have data on shards distributed using _routing attribute, so it guarantee that data with same key are only on that shard, right ?
But there will be also data with different _routing value, and I need order it by this attribute and process during mapping phase in that order.

Example: I have something like this, routed by cuid attribute:

{ "cuid":"A", "price":1," amount":20}
{ "cuid":"B", "price":2," amount":20}
{ "cuid":"C", "price":3," amount":20}
{ "cuid":"A", "price":4," amount":20}
{ "cuid":"C", "price":5," amount":20}
{ "cuid":"A", "price":6," amount":20}

After distribution it's stored on shard 1 and 3 for example:

Shard1:
{ "cuid":"A", "price":1," amount":20}
{ "cuid":"B", "price":2," amount":20}
{ "cuid":"A", "price":4," amount":20}
{ "cuid":"A", "price":6," amount":20}

Shard2:
{ "cuid":"C", "price":3," amount":20}
{ "cuid":"C", "price":5," amount":20}

And I need process it during mapping as:
Shard1:
{ "cuid":"A", "price":1," amount":20}
{ "cuid":"A", "price":4," amount":20}
{ "cuid":"A", "price":6," amount":20}
{ "cuid":"B", "price":2," amount":20}

Shard2:
{ "cuid":"C", "price":3," amount":20}
{ "cuid":"C", "price":5," amount":20}

Are there some possibility to do that?
And thanks for facet-script plugin, I'm just waiting for something like this.

Thx Bedy

    1. 2012 v 22:24, Igor Motov imotov@gmail.com:

No, it's not sorted. Moreover, mappers are running on individual shards and possible different nodes, so they don't even see all data. If you want data sorted, you would have to sort it yourself in mappers and then merge sort results in the reducer.

On Wednesday, October 31, 2012 10:34:23 AM UTC-4, Martin Bednář wrote:
Hi,

When I use custom facets (based on imotov/elasticsearch-facet-script), are data in mapping phase sorted, when I use sort:{} in query ?
Or how can I get sorted data in mapping phase ?

Thx Bedy

--

--


(Igor Motov) #4

I think you will have to collect all data during mapping phase and then
sort and process it in the combine phase. I can't really think of any other
way to do it.

On Wednesday, October 31, 2012 7:51:58 PM UTC-4, Martin Bednář wrote:

Hi Igor,

I have data on shards distributed using _routing attribute, so it
guarantee that data with same key are only on that shard, right ?
But there will be also data with different _routing value, and I need
order it by this attribute and process during mapping phase in that order.

Example: I have something like this, routed by cuid attribute:

{ "cuid":"A", "price":1," amount":20}
{ "cuid":"B", "price":2," amount":20}
{ "cuid":"C", "price":3," amount":20}
{ "cuid":"A", "price":4," amount":20}
{ "cuid":"C", "price":5," amount":20}
{ "cuid":"A", "price":6," amount":20}

After distribution it's stored on shard 1 and 3 for example:

Shard1:
{ "cuid":"A", "price":1," amount":20}
{ "cuid":"B", "price":2," amount":20}
{ "cuid":"A", "price":4," amount":20}
{ "cuid":"A", "price":6," amount":20}

Shard2:
{ "cuid":"C", "price":3," amount":20}
{ "cuid":"C", "price":5," amount":20}

And I need process it during mapping as:
Shard1:
{ "cuid":"A", "price":1," amount":20}
{ "cuid":"A", "price":4," amount":20}
{ "cuid":"A", "price":6," amount":20}
{ "cuid":"B", "price":2," amount":20}

Shard2:
{ "cuid":"C", "price":3," amount":20}
{ "cuid":"C", "price":5," amount":20}

Are there some possibility to do that?
And thanks for facet-script plugin, I'm just waiting for something like
this.

Thx Bedy

    1. 2012 v 22:24, Igor Motov <imo...@gmail.com <javascript:>>:

No, it's not sorted. Moreover, mappers are running on individual shards
and possible different nodes, so they don't even see all data. If you want
data sorted, you would have to sort it yourself in mappers and then merge
sort results in the reducer.

On Wednesday, October 31, 2012 10:34:23 AM UTC-4, Martin Bednář wrote:

Hi,

When I use custom facets (based on imotov/elasticsearch-facet-script),
are data in mapping phase sorted, when I use sort:{} in query ?
Or how can I get sorted data in mapping phase ?

Thx Bedy

--

--


(system) #5