Is there a way to return multiple fields instead of one in elasticsearch?

782 Views Asked by At
  "aggs": {
    "dest": {
      "terms": {
        "field": "dest.raw",
        "size": 20,
        "order": {
          "_count": "desc"
        }
      }
    },
    "src": {
      "terms": {
        "field": "src.raw",
        "size": 20,
        "order": {
          "_count": "desc"
        }
      }
    }

How do I run 1 terms, instead of having to run it 2 or more times? When I run it 2 times, the array it returns have different objects in them because I'm guessing this is async.

for example, if each terms return an array with 20 values in it, dest[0] might not be from the same object as src[0].

Ideally, I want to do something like this, but it doesn't work. How would I go about doing this?

 "aggs": {
   "top": {
     "terms": {
       "fields": ["dest.raw", "src.raw"],
       "size": 20,
       "order": {
         "_count": "desc"
       }
     }
   }
 }
0

There are 0 best solutions below