<p dir="auto">The <code class="notranslate">scripted_metric</code> aggregation is an expert level feature and has its own set of tradeoffs that need to be considered before reaching for it. Due to the fact that it uses scripts it is slow (when compared to other aggregations) especially as the complexity of the scripts increase. It also is not able to support certain functions, for example, you cannot sort a terms aggregation by the <code class="notranslate">scripted_metric</code> aggregation.</p>
<p dir="auto">I think we should therefore move the <code class="notranslate">scripted_metric</code> aggregation to a plugin (not a module) so when users reach for it, it is a more explicit that this is an expert level aggregation</p>
<p dir="auto">Hi,</p>
<p dir="auto">Sorry for the lousy title, but let me explain the problem I'm having.  I'm currently working on a project, and a part of this includes a search engine for addresses, which I have in elasticsearch.  What I'm trying to do is use fuzzy_like_this_field queries when a new character is entered in my search bar to generate autocomplete results and try to "guess" which of the (~1 million) addresses the user is typing.</p>
<p dir="auto">My issue is that I currently have a size limit on my query, as returning all of the results was both unnecessary and expensive, time-wise.  My issue, is that I often am not getting the "correct" result unless I return 1000 or more results from the query.  For example, if I enter "100 broad" in trying to search for "100 broadway" and I only return 200 results (about the max that I can do without it taking too long), 100 broadway is nowhere to be found, even though all of the returned results have a higher levenshtein distance than the result that I want.  I get "100 broadway" as the first result if I return 2000 results from my query, but it takes too long.  I can't even filter the results that got returned to bring the correct one to the top, because it's not being returned.</p>
<p dir="auto">Shouldn't putting a size limit of N on the query return the best N results, not a seemingly random subset of them?</p>
<p dir="auto">Sorry if this is poorly worded or too vague.</p>