Skip to content

Instantly share code, notes, and snippets.

@scampi
Last active December 2, 2016 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scampi/aa99faa7cbf9bac36d24e58325718f33 to your computer and use it in GitHub Desktop.
Save scampi/aa99faa7cbf9bac36d24e58325718f33 to your computer and use it in GitHub Desktop.

Data

Doc 1

{
   "foo": [
      {
         "bar": "one"
      },
      {
         "bar": "two"
      }
   ],
   "num": 1
}

Doc 2

{
   "foo": {
      "bar": [
         "two",
         "three"
      ]
   },
   "num": 2
}

foo.bar.keyword

{
 "1": {
  "hits": {
   "total": 2,
   "max_score": null,
   "hits": [
    {
     "_index": "array",
     "_type": "Array",
     "_id": "AVjAY62CECh9prBPbven",
     "_score": null,
     "_source": {
      "foo": {
       "bar": [
        "two",
        "three"
       ]
      }
     },
     "fields": {
      "foo.bar.keyword": [
       "three",
       "two"
      ]
     },
     "sort": [
      "Array"
     ]
    }
   ]
  }
 },
 "doc_count": 2
}

And the call to "agg.vis.indexPattern.flattenHit(hits[0])[agg.params.field.name]" returns me: ["three", "two"]

foo.bar

{
 "1": {
  "hits": {
   "total": 2,
   "max_score": null,
   "hits": [
    {
     "_index": "array",
     "_type": "Array",
     "_id": "AVjAY62CECh9prBPbven",
     "_score": null,
     "_source": {
      "foo": {
       "bar": [
        "two",
        "three"
       ]
      }
     },
     "sort": [
      "Array"
     ]
    }
   ]
  }
 },
 "doc_count": 2
}

And the call to "agg.vis.indexPattern.flattenHit(hits[0])[agg.params.field.name]" returns me: ["three", "two"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment