# Aggregate two collections on date field

**URL:** https://discuss.elastic.co/t/aggregate-two-collections-on-date-field/144760
**Category:** Elasticsearch
**Created:** [August 16, 2018, 5:25pm UTC](https://discuss.elastic.co/t/aggregate-two-collections-on-date-field/144760 "2018-08-16T17:25:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dpolicastro](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@dpolicastro](https://discuss.elastic.co/u/dpolicastro)
#### Post date: [August 16, 2018, 5:25pm UTC](https://discuss.elastic.co/t/aggregate-two-collections-on-date-field/144760/1 "2018-08-16T17:25:00Z")

</div>

Hello guys, I'm starting using Elasticsearch and I would like to know some things before I deep dive in it.

1. Is it possible to query two different indexes, and aggregate the data matching a specific date?

2. If the date format contains the date and the time, can I aggregate it by hour for example?

I know both solutions can be done on mongoDB using aggregations, but I want to start using ES.

Indexes:

```
holdings: [{
    name: "xpto", 
    quantity: 5,
    date: "2018-05-20 23:30:00"
}, {...}]

prices: [{
    name: "xpto", 
    price: 10000,
    date: "2018-05-20 23:10:00"
}, {...}]

```

I spect an output like that:

```
total_value: [{
    name: "xpto", 
    value: 50000,
    date: "2018-05-20 23:00:00"
}, {...}]

```

Note: I aggregate the data based on the hour.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [September 13, 2018, 5:36pm UTC](https://discuss.elastic.co/t/aggregate-two-collections-on-date-field/144760/2 "2018-09-13T17:36:53Z")

</div>

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