<p dir="auto">I came across this while trying to see the English analyzer, but I forgot to change <code class="notranslate">tokenizer</code> to <code class="notranslate">analyzer</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="GET /_analyze
{
  &quot;tokenizer&quot; : &quot;english&quot;,
  &quot;text&quot; : &quot;whatever&quot;
}"><pre class="notranslate"><code class="notranslate">GET /_analyze
{
  "tokenizer" : "english",
  "text" : "whatever"
}
</code></pre></div>
<p dir="auto">The only error that comes out of Elasticsearch (tested on 2.2.0 and 2.1.1) is an obscure one:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2016-03-15 14:52:11,050][ERROR][transport                ] [Jessica Drew] failed to handle exception for action [indices:admin/analyze[s]], handler [org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1@4ffecb71]
java.lang.NullPointerException
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.perform(TransportSingleShardAction.java:195)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.access$700(TransportSingleShardAction.java:115)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1.handleException(TransportSingleShardAction.java:174)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:821)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:799)
    at org.elasticsearch.transport.TransportService$4.onFailure(TransportService.java:361)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)"><pre class="notranslate"><code class="notranslate">[2016-03-15 14:52:11,050][ERROR][transport                ] [Jessica Drew] failed to handle exception for action [indices:admin/analyze[s]], handler [org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1@4ffecb71]
java.lang.NullPointerException
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.perform(TransportSingleShardAction.java:195)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.access$700(TransportSingleShardAction.java:115)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1.handleException(TransportSingleShardAction.java:174)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:821)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:799)
    at org.elasticsearch.transport.TransportService$4.onFailure(TransportService.java:361)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
</code></pre></div>
<p dir="auto">Worse still, it never actually closes the connection so the request hangs, awaiting a response (probably indicating a secondary bug in this code path).</p>
<p dir="auto">This is basically the opposite of how the histogram currently acts: fixed interval and dynamic number of buckets.</p>
<p dir="auto">My use case is that I would like to build a price range style aggregation for filtering products:</p>
<p dir="auto">$0 - $100<br>
$101 - $200<br>
$201 - $300<br>
$301 - $400<br>
$401 - $500</p>
<p dir="auto">While you can do this with the range agg. if you know in advance the lower and upper bounds of all your prices, I can't see a way to do this dynamically based off the current query. The range agg also suffers from other shortcomings such as generating buckets that may contain no documents.</p>
<p dir="auto">Ideally, I'd like to be able to specify the number of ranges / buckets I want (eg. 5) with a dynamic interval calculated by the aggregation.</p>
<p dir="auto"><code class="notranslate">min_doc_count</code> could also come into affect here to ensure that either we don't generate buckets that don't contain any products (eg <code class="notranslate">min_doc_count: 0</code>) and in which case the number of buckets just becomes a maximum number of potential buckets, rather than a guaranteed amount.</p>