Stats facet

Mapping

{
  "id": { "type": "keyword" },
  "title": { "type": "text" },
  "price": { "type": "float" }
}

Documents

{
  "documents": [
    { "id": "1", "title": "Laptop HP 1", "price": 128.99 },
    { "id": "2", "title": "Laptop HP 2", "price": 520.0 },
    { "id": "3", "title": "Laptop HP 3", "price": 230.99 },
    { "id": "4", "title": "Laptop HP 4", "price": 768.64 },
    { "id": "5", "title": "Laptop Lenovo 1", "price": 800.2 },
    { "id": "6", "title": "Laptop Lenovo 2", "price": 999.999 },
    { "id": "7", "title": "Laptop Lenovo 3", "price": 1024.29 },
    { "id": "8", "title": "Laptop Lenovo 4", "price": 620.6 }
  ]
}

Query Configuration

{
  "description": "Computer stats query",
  "configuration": {
    "queryFields": {
      "title": 5
    },
    "match": "all",
    "selectFields": ["id"],
    "facets": [
      {
        "type": "stats",
        "key": "price",
        "label": "Price"
      }
    ]
  },
  "debugMode": true
}

Public Query

Request:

{
  "searchText": "laptop"
}

Response:

{
  "searchText": "laptop",
  "total": 8,
  "items": [
    /*...*/
  ],
  "facets": [
    {
      "key": "price",
      "label": "Price",
      "min": 128.99000549316406,
      "max": 1024.2900390625,
      "type": "stats"
    }
  ],
  "filters": {},
  "metadata": {}
}