How to optimize regexp filter

Thanks @Mark_Harwood

Running the following gave me "504 Gateway Time-out", any suggestions?

I think you are right there seems to be tons of different tagv.raw values in the index now. Is there any way to avoid running regx on all of them?

curl localhost:9200/myindex/_search?size=0  -d'
{
  "aggs": {
    "type_count": {
      "cardinality": {
        "field": "tagv.raw"
      }
    }
  }
}'