Last active
May 18, 2017 09:28
-
-
Save romuald/d4ca3a7532c8d9b25c6c72022b68e6ab to your computer and use it in GitHub Desktop.
Fix Kibana 3 terms_stats with low document counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fix Kibana 3 terms_stats | |
// @namespace http://chivil.com/ | |
// @version 1.0 | |
// @description Try fixing Kibana 3 terms_stats queries not being accurate with low document count | |
// @author Romuald Brunet <[email protected]> | |
// @match -your-kibana-url- | |
// @grant none | |
// ==/UserScript== | |
(function(original_send) { | |
// Works for me, but might not work for you | |
// See https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-facets-terms-stats-facet.html#search-facets-terms-stats-facet | |
var shard_size = 2000; | |
window.XMLHttpRequest.prototype.send = function(data) { | |
// Overwrite the shard_size in the terms_stats queries only | |
try { | |
var copy = JSON.parse(data); | |
copy.facets.terms.terms_stats.shard_size = shard_size; | |
data = JSON.stringify(copy); | |
console.log("Patched a XHR terms_stats.shard_size to " + shard_size); | |
} catch (e) { | |
// Ignore errors, no terms_stats in the XMLHttpRequest (probably) | |
} | |
return original_send.call(this, data); | |
}; | |
})(window.XMLHttpRequest.prototype.send); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment