# Transform api gives unsupported aggregation type \[multi\_terms\]

**URL:** <https://discuss.elastic.co/t/transform-api-gives-unsupported-aggregation-type-multi-terms/274616>\
**Category:** Elasticsearch\
**Created:** [June 1, 2021, 10:45am UTC](https://discuss.elastic.co/t/transform-api-gives-unsupported-aggregation-type-multi-terms/274616 "2021-06-01T10:45:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [June 1, 2021, 10:45am UTC](https://discuss.elastic.co/t/transform-api-gives-unsupported-aggregation-type-multi-terms/274616/1 "2021-06-01T10:45:21Z")

</div>

Below is my query for getting distinct values of the fields.

```auto
{
  "size": 0,
  "aggs": {
    "unique_pair": {
      "multi_terms": {
        "terms": [
          {
            "field": "username"
          },
          {
            "field": "city"
          }
        ]
      }
    }
  }
}

```

I want to move the results to another index. I follow this [How to sum of fields in elasticsearch and move another index](https://stackoverflow.com/questions/66353599/how-to-sum-of-fields-in-elasticsearch-and-move-another-index/66354448#66354448)

```auto
PUT _transform/person_city
{
  "source": {
    "index": "person",
    "query": {
      "match_all": {}
      }
    }
  },
  "pivot": {
    "group_by": {
      "username": {
        "terms": {
          "field": "username"
        }
      }
    },
    "aggregations": {
    "unique_pair": {
      "multi_terms": {
        "terms": [
          {
            "field": "username"
          },
          {
            "field": "city"
          }
        ]
      }
    }
  }
  },
  "dest": {
    "index": "person_city"
  }
}

```

But when i run the query i get unsupported aggregation type [multi\_terms]

How can i get **SQL DISTINCT Pair of Values in Elasticsearch**. Like below,

```auto
SELECT distinct username, city from country_table

```

**and move results to another index ?**

---

<div class="post-metadata">

**Author:** ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)\
**Post date:** [June 7, 2021, 9:25am UTC](https://discuss.elastic.co/t/transform-api-gives-unsupported-aggregation-type-multi-terms/274616/2 "2021-06-07T09:25:58Z")

</div>

You can group by multiple columns like this:

```auto
"pivot": {
    "group_by": {
      "username": {
        "terms": {
          "field": "username"
        }
      },
      "city": {
        "terms": {
          "field": "city"
        }
      }
    },

```

Transform does not support all aggregations, like `multi_terms`, however I think this is not necessary in your case.

However, transform requires at least 1 aggregation, the simplest one in this case is e.g. `value_count` on one of the group by fields.

Good to know: If your data can have missing data, that means e.g. a `null` value for `city`, set `missing_bucket` to `true`.

---

<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, 2021, 9:26am UTC](https://discuss.elastic.co/t/transform-api-gives-unsupported-aggregation-type-multi-terms/274616/3 "2021-07-05T09:26:04Z")

</div>

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