Skip to content

Latest commit

 

History

History
139 lines (116 loc) · 4.17 KB

histo.org

File metadata and controls

139 lines (116 loc) · 4.17 KB

Histogram tests

Test Data

First, you need to index some test data:

DELETE /test
{}

POST /test/doc/
{"price": 10, "type": "widget"}

POST /test/doc/
{"price": 15, "type": "cog"}

POST /test/doc/
{"price": 55, "type": "widget"}

POST /test/doc/
{"price": 61, "type": "foo"}

POST /test/doc/
{"price": 70, "type": "foo"}

POST /test/doc/
{"price": 99, "type": "foo"}

POST /test/doc/
{"price": 160, "type": "foo"}

POST /test/doc/
{"price": 170, "type": "eggplant"}

POST /test/doc/
{"price": 1, "type": "eggplant"}

POST /test/doc/
{"price": 12, "type": "eggplant"}

POST /test/doc/
{"price": 112, "type": "eggplant"}

POST /test/doc/
{"price": 99, "type": "eggplant"}

Histogram org-table

POST /test/doc/_search
{
  "aggs" : {
    "prices" : {
      "histogram" : {
        "field" : "price",
        "interval" : 20,
        "min_doc_count": 0
      }
    }
  },
  "size": 0
}
keydocument count
04
200
401
602
802
1001
1200
1400
1602

Which can then be passed into something like Gnuplot:

plot data using 1:2 with lines
POST /test/doc/_search
{
  "aggs" : {
    "my_terms_agg" : {
      "terms" : {
        "field" : "type"
      }
    }
  },
  "size": 0
}
keydocument count
eggplant5
foo4
widget2
cog1