Get all attribute keys and key values within specific search

I have this "articles" and attributes:

-----------------------------

name = galaxy note

attributes
   type = phone
   weight = 140gm

-----------------------------

name = shirt

attributes
   type = clothing
   size = m

-----------------------------

name = iphone x

attributes
   type = phone
   screen size = 6.5 inch

-----------------------------

(See  GET   /catalog/article/_search  below... )

With which request can I retrieve all attribute keys available within the current search, result like:

  • type
  • weight
  • size
  • screen size

With which request can I retrieve all attribute values available within the current search for a specific attribute key, result like when retrieving 'type':

  • phone (2)
  • clothing (1)

Or even better and easier a request where I get these 2 combined back within a current search:

  • type
    • phone (2)
    • clothing (1)
  • weight
    • 140gm (1)
  • size
    • m (1)
  • screen size
    • 6.5 inch (1)
GET     /catalog/article/_search


{
  "hits": {
    "hits": [
      {
        "_score": 1,
        "_type": "article",
        "_id": "POczfGsBETE745IKleND",
        "_source": {
          "attributes": [
            {
              "key": "type",
              "value": "phone"
            },
            {
              "key": "weight",
              "value": "140gm"
            }
          ],
          "price": 123,
          "name": "galaxy note"
        },
        "_index": "catalog"
      },
      {
        "_score": 1,
        "_type": "article",
        "_id": "1gTQgGsBOIP8-uDJcAWg",
        "_source": {
          "attributes": [
            {
              "key": "type",
              "value": "clothing"
            },
            {
              "key": "size",
              "value": "m"
            }
          ],
          "price": 123,
          "name": "shirt"
        },
        "_index": "catalog"
      },
      {
        "_score": 1,
        "_type": "article",
        "_id": "Pef1kmsBETE745IKaeM1",
        "_source": {
          "attributes": [
            {
              "key": "type",
              "value": "phone"
            },
            {
              "key": "screen size",
              "value": "6.5 inch"
            }
          ],
          "price": 599,
          "name": "iphone x"
        },
        "_index": "catalog"
      }
    ],
    "total": {
      "relation": "eq",
      "value": 3
    },
    "max_score": 1
  },
  "_shards": {
    "successful": 1,
    "failed": 0,
    "skipped": 0,
    "total": 1
  },
  "took": 3,
  "timed_out": false
}

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