Transform api gives unsupported aggregation type [multi_terms]

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

{
  "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

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,

SELECT distinct username, city from country_table

and move results to another index ?

You can group by multiple columns like this:

"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.

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