# Return multiple 1-1 fields with aggregation

**URL:** <https://discuss.elastic.co/t/return-multiple-1-1-fields-with-aggregation/60748>\
**Category:** Elasticsearch\
**Created:** [September 16, 2016, 7:12pm UTC](https://discuss.elastic.co/t/return-multiple-1-1-fields-with-aggregation/60748 "2016-09-16T19:12:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amb44371](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@amb44371](https://discuss.elastic.co/u/amb44371)\
**Post date:** [September 16, 2016, 7:12pm UTC](https://discuss.elastic.co/t/return-multiple-1-1-fields-with-aggregation/60748/1 "2016-09-16T19:12:09Z")

</div>

I'm somewhat new to elastic search, so my apologies if any part of this doesn't make sense 🙂

I'm in need of the ability to get multiple one-to-one fields back from an aggregation. I understand the obvious reason why one would only be able to aggregate on a single field, but in this case I have a strictly enforced 1-1 relationship between the field I'm aggregating on and the other field I'm trying to get the value for.

This is how I'm currently accomplishing this, with a sub-aggregation:

```
"aggregations": {
    "example_aggregation": {
        "terms": {
            "size": 100,
            "field": "siteId"
        }
        "aggregations": {
            "siteTitle": {
                "terms": {
                    "field": "siteTitle"
                }
            }
        }
    }
}

```

Just to clarify, the 1-1 relationship that I'm talking about is between siteId and siteTitle. siteIds will only ever have one possible value for siteTitle, and vice-versa

The problem is that this is very slow. Without the sub-aggregation, results are returned about 7x faster.

Is there another way to accomplish this same thing? I'm using elastic search v. 1.5.2

Thanks in advance!

---

<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:** [July 5, 2017, 10:19pm UTC](https://discuss.elastic.co/t/return-multiple-1-1-fields-with-aggregation/60748/2 "2017-07-05T22:19:31Z")

</div>


