Find sum of values in deduplicated docs


(Altvec) #1

Hi,

I have an index with a lot of documents, some of them contains the same value for the same field, for example:

doc1:

{
    "play_begin": "2015-10-26",
    "play_end": "2015-10-26",
    "price": 5,
    "name": "test",
    "account": 826719,
    "session_id": 1437636558,
    "service_begin": "2015-10-26",
    "service_end": "2015-10-29"
}

doc2:

{
    "play_begin": "2015-10-27",
    "play_end": "2015-10-27",
    "price": 5,
    "name": "test",
    "account": 826719,
    "session_id": 1437636558,
    "service_begin": "2015-10-26",
    "service_end": "2015-10-29"
}

doc3:

{
    "play_begin": "2015-10-27",
    "play_end": "2015-10-27",
    "price": 10,
    "name": "test2",
    "account": 826719,
    "session_id": 1437636558,
    "service_begin": "2015-10-26",
    "service_end": "2015-10-29"
}

I need to deduplicate docs by fields 'account', 'service_begin', 'service_end', 'name' and find sum of values in the 'price' field. What's the proper way to complete this? Is it possible?

Thanks to anyone that replies.


(system) #2