Skip to content

Commit 8fe463f

Browse files
committed
Merge pull request #218 from philipskokoh/ES2-support
Fix ES2.0 breaking errors
2 parents 5b200a0 + a156b89 commit 8fe463f

File tree

20 files changed

+123
-131
lines changed

20 files changed

+123
-131
lines changed

_site/app.js

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@
694694

695695
var coretype_map = {
696696
"string" : "string",
697+
"byte" : "number",
698+
"short" : "number",
697699
"long" : "number",
698700
"integer" : "number",
699701
"float" : "number",
@@ -748,7 +750,7 @@
748750

749751
function createField( mapping, index, type, path, name ) {
750752
var dpath = [ index, type ].concat( path ).join( "." );
751-
var field_name = mapping.index_name || name;
753+
var field_name = mapping.index_name || path.join( "." );
752754
var field = paths[ dpath ] = fields[ field_name ] || $.extend({
753755
field_name : field_name,
754756
core_type : coretype_map[ mapping.type ],
@@ -856,7 +858,7 @@
856858
from: 0,
857859
size: this.config.size,
858860
sort: [],
859-
facets: {},
861+
aggs: {},
860862
version: true
861863
};
862864
this.defaultClause = this.addClause();
@@ -1005,15 +1007,15 @@
10051007
this.defaultClause = this.addClause();
10061008
}
10071009
},
1008-
addFacet: function(facet) {
1009-
var facetId = "f-" + this.refuid++;
1010-
this.search.facets[facetId] = facet;
1011-
this.refmap[facetId] = { facetId: facetId, facet: facet };
1012-
return facetId;
1010+
addAggs: function(aggs) {
1011+
var aggsId = "f-" + this.refuid++;
1012+
this.search.aggs[aggsId] = aggs;
1013+
this.refmap[aggsId] = { aggsId: aggsId, aggs: aggs };
1014+
return aggsId;
10131015
},
1014-
removeFacet: function(facetId) {
1015-
delete this.search.facets[facetId];
1016-
delete this.refmap[facetId];
1016+
removeAggs: function(aggsId) {
1017+
delete this.search.aggs[aggsId];
1018+
delete this.refmap[aggsId];
10171019
},
10181020
_setClause: function(value, field, op, bool) {
10191021
var clause = {}, query = {};
@@ -1144,7 +1146,7 @@
11441146
from: 0,
11451147
size: this.config.size,
11461148
sort: [],
1147-
facets: {}
1149+
aggs: {}
11481150
};
11491151
this.defaultClause = this.addClause();
11501152
},
@@ -1189,7 +1191,7 @@
11891191
filter["missing"] = missing
11901192
query["filter"] = filter;
11911193
} else {
1192-
query[field] = value;
1194+
query[field.substring(field.indexOf(".")+1)] = value;
11931195
}
11941196
clause[op] = query;
11951197
this.search.query.bool[bool].push(clause);
@@ -2078,7 +2080,9 @@
20782080
this.attach( parent );
20792081
},
20802082
_downloadLinkGenerator_handler: function() {
2081-
this._downloadLink.attr("href", "data:text/csv;chatset=utf-8," + window.encodeURIComponent( this._csvText ) );
2083+
var csvData = new Blob( [ this._csvText ], { type: 'text/csv' });
2084+
var csvURL = URL.createObjectURL( csvData );
2085+
this._downloadLink.attr( "href", csvURL );
20822086
this._downloadLink.show();
20832087
},
20842088
_parseResults: function( results ) {
@@ -2421,17 +2425,7 @@
24212425
}
24222426
},
24232427
getSpec: function(fieldName) {
2424-
var fieldNameParts = fieldName.split('.');
2425-
var namePart = 0;
2426-
var spec = this.metadata.fields[fieldNameParts[namePart]];
2427-
while (typeof spec.fields !== "undefined") {
2428-
namePart++;
2429-
if (typeof spec.fields[fieldNameParts[namePart]] === "undefined") {
2430-
break;
2431-
}
2432-
spec = spec.fields[fieldNameParts[namePart]];
2433-
}
2434-
return spec;
2428+
return this.metadata.fields[fieldName];
24352429
},
24362430
_selectAlias_handler: function(jEv) {
24372431
var indices = (jEv.target.selectedIndex === 0) ? [] : this.metadata.getIndices($(jEv.target).val());
@@ -2632,7 +2626,9 @@
26322626
] };
26332627
},
26342628
_filters_template: function() {
2635-
var fields = Object.keys( this.metadata.fields ).sort();
2629+
var _metadataFields = this.metadata.fields;
2630+
var fields = Object.keys( _metadataFields ).sort()
2631+
.filter(function(d) { return (_metadataFields[d].core_type !== undefined); });
26362632
return { tag: "DIV", cls: "uiQueryFilter-section uiQueryFilter-filters", children: [
26372633
{ tag: "HEADER", text: i18n.text("QueryFilter-Header-Fields") },
26382634
{ tag: "DIV", children: fields.map( function(name ) {
@@ -3209,8 +3205,8 @@
32093205
); },
32103206
_indexHeader_template: function( index ) {
32113207
var closed = index.state === "close";
3212-
var line1 = closed ? "index: close" : ( "size: " + (index.status && index.status.total ? ut.byteSize_template( index.status.total.store.size_in_bytes ) + " (" + ut.byteSize_template( index.status.total.store.size_in_bytes ) + ")" : "unknown" ) );
3213-
var line2 = closed ? "\u00A0" : ( "docs: " + (index.status && index.status.total && index.status.total.docs ? index.status.total.docs.count.toLocaleString() + " (" + (index.status.total.docs.count + index.status.total.docs.deleted).toLocaleString() + ")" : "unknown" ) );
3208+
var line1 = closed ? "index: close" : ( "size: " + (index.status && index.status.primaries && index.status.total ? ut.byteSize_template( index.status.primaries.store.size_in_bytes ) + " (" + ut.byteSize_template( index.status.total.store.size_in_bytes ) + ")" : "unknown" ) );
3209+
var line2 = closed ? "\u00A0" : ( "docs: " + (index.status && index.status.primaries && index.status.primaries.docs && index.status.total && index.status.total.docs ? index.status.primaries.docs.count.toLocaleString() + " (" + (index.status.total.docs.count + index.status.total.docs.deleted).toLocaleString() + ")" : "unknown" ) );
32143210
return index.name ? { tag: "TH", cls: (closed ? "close" : ""), children: [
32153211
{ tag: "H3", text: index.name },
32163212
{ tag: "DIV", text: line1 },
@@ -3585,20 +3581,19 @@
35853581
}.bind(this));
35863582
this.query.search.size = 0;
35873583
this.query.on("results", this._stat_handler);
3588-
this.query.on("results", this._facet_handler);
3584+
this.query.on("results", this._aggs_handler);
35893585
this.buildHistogram();
35903586
},
35913587
buildHistogram: function(query) {
3592-
this.statFacet = this.query.addFacet({
3593-
statistical: { field: this.config.spec.field_name },
3594-
global: true
3588+
this.statAggs = this.query.addAggs({
3589+
stats: { field: this.config.spec.field_name }
35953590
});
35963591
this.query.query();
3597-
this.query.removeFacet(this.statFacet);
3592+
this.query.removeAggs(this.statAggs);
35983593
},
35993594
_stat_handler: function(query, results) {
3600-
if(! results.facets[this.statFacet]) { return; }
3601-
this.stats = results.facets[this.statFacet];
3595+
if(! results.aggregations[this.statAggs]) { return; }
3596+
this.stats = results.aggregations[this.statAggs];
36023597
// here we are calculating the approximate range that will give us less than 121 columns
36033598
var rangeNames = [ "year", "year", "month", "day", "hour", "minute" ];
36043599
var rangeFactors = [100000, 12, 30, 24, 60, 60000 ];
@@ -3610,23 +3605,22 @@
36103605
this.intervalRange *= factor;
36113606
range = range / factor;
36123607
} while(range > 70);
3613-
this.dateFacet = this.query.addFacet({
3608+
this.dateAggs = this.query.addAggs({
36143609
date_histogram : {
36153610
field: this.config.spec.field_name,
3616-
interval: this.intervalName,
3617-
global: true
3611+
interval: this.intervalName
36183612
}
36193613
});
36203614
this.query.query();
3621-
this.query.removeFacet(this.dateFacet);
3615+
this.query.removeAggs(this.dateAggs);
36223616
},
3623-
_facet_handler: function(query, results) {
3624-
if(! results.facets[this.dateFacet]) { return; }
3617+
_aggs_handler: function(query, results) {
3618+
if(! results.aggregations[this.dateAggs]) { return; }
36253619
var buckets = [], range = this.intervalRange;
36263620
var min = Math.floor(this.stats.min / range) * range;
36273621
var prec = [ "year", "month", "day", "hour", "minute", "second" ].indexOf(this.intervalName);
3628-
results.facets[this.dateFacet].entries.forEach(function(entry) {
3629-
buckets[parseInt((entry.time - min) / range , 10)] = entry.count;
3622+
results.aggregations[this.dateAggs].buckets.forEach(function(entry) {
3623+
buckets[parseInt((entry.key - min) / range , 10)] = entry.doc_count;
36303624
}, this);
36313625
for(var i = 0; i < buckets.length; i++) {
36323626
buckets[i] = buckets[i] || 0;
@@ -3653,7 +3647,7 @@
36533647
},
36543648
_main_template: function() { return (
36553649
{ tag: "DIV", cls: "uiDateHistogram loading", css: { height: "50px" }, children: [
3656-
i18n.text("General.LoadingFacets")
3650+
i18n.text("General.LoadingAggs")
36573651
] }
36583652
); }
36593653
});
@@ -3935,6 +3929,8 @@
39353929
ops = ["missing"];
39363930
} else if(spec.type === 'ip') {
39373931
ops = ["term", "range", "fuzzy", "query_string", "missing"];
3932+
} else if(spec.type === 'boolean') {
3933+
ops = ["term"]
39383934
}
39393935
select.after({ tag: "SELECT", cls: "op", onchange: this._changeQueryOp_handler, children: ops.map(ut.option_template) });
39403936
select.next().change();
@@ -3985,9 +3981,9 @@
39853981

39863982
_range_template: function() {
39873983
return { tag: "SPAN", cls: "range", children: [
3988-
{ tag: "SELECT", cls: "lowop", children: ["from", "gt", "gte"].map(ut.option_template) },
3984+
{ tag: "SELECT", cls: "lowop", children: ["gt", "gte"].map(ut.option_template) },
39893985
{ tag: "INPUT", type: "text", cls: "lowqual" },
3990-
{ tag: "SELECT", cls: "highop", children: ["to", "lt", "lte"].map(ut.option_template) },
3986+
{ tag: "SELECT", cls: "highop", children: ["lt", "lte"].map(ut.option_template) },
39913987
{ tag: "INPUT", type: "text", cls: "highqual" }
39923988
]};
39933989
},
@@ -4016,7 +4012,7 @@
40164012
this.update();
40174013
},
40184014
update: function() {
4019-
this.cluster.get( "_status", this._update_handler );
4015+
this.cluster.get( "_stats", this._update_handler );
40204016
},
40214017

40224018
_update_handler: function(data) {
@@ -4043,7 +4039,7 @@
40434039
},
40444040

40454041
_option_template: function(name, index) {
4046-
return { tag: "OPTION", value: name, text: i18n.text("IndexSelector.NameWithDocs", name, index.docs.num_docs ) };
4042+
return { tag: "OPTION", value: name, text: i18n.text("IndexSelector.NameWithDocs", name, index.primaries.docs.count ) };
40474043
}
40484044
});
40494045

@@ -4066,9 +4062,9 @@
40664062
var quicks = [
40674063
{ text: i18n.text("Nav.Info"), path: "" },
40684064
{ text: i18n.text("Nav.Status"), path: "_stats" },
4069-
{ text: i18n.text("Nav.NodeStats"), path: "_cluster/nodes/stats" },
4070-
{ text: i18n.text("Nav.ClusterNodes"), path: "_cluster/nodes" },
4071-
{ text: i18n.text("Nav.Plugins"), path: "_nodes/plugin" },
4065+
{ text: i18n.text("Nav.NodeStats"), path: "_nodes/stats" },
4066+
{ text: i18n.text("Nav.ClusterNodes"), path: "_nodes" },
4067+
{ text: i18n.text("Nav.Plugins"), path: "_nodes/plugins" },
40724068
{ text: i18n.text("Nav.ClusterState"), path: "_cluster/state" },
40734069
{ text: i18n.text("Nav.ClusterHealth"), path: "_cluster/health" },
40744070
{ text: i18n.text("Nav.Templates"), path: "_template" }
@@ -4216,8 +4212,8 @@
42164212
{ tag: "TD", children: [
42174213
{ tag: "H3", text: index.name }
42184214
] },
4219-
{ tag: "TD", text: ut.byteSize_template( index.state.index.primary_size_in_bytes ) + "/" + ut.byteSize_template( index.state.index.size_in_bytes ) },
4220-
{ tag: "TD", text: ut.count_template( index.state.docs.num_docs ) }
4215+
{ tag: "TD", text: ut.byteSize_template( index.state.primaries.store.size_in_bytes ) + "/" + ut.byteSize_template( index.state.total.store.size_in_bytes ) },
4216+
{ tag: "TD", text: ut.count_template( index.state.primaries.docs.count ) }
42214217
] }
42224218
); },
42234219
_main_template: function() {

_site/lang/en_strings.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n.setKeys({
22
"General.Elasticsearch": "Elasticsearch",
3-
"General.LoadingFacets": "Loading Facets...",
3+
"General.LoadingAggs": "Loading Aggregations...",
44
"General.Searching": "Searching...",
55
"General.Search": "Search",
66
"General.Help": "Help",
@@ -63,13 +63,13 @@ i18n.setKeys({
6363
"Nav.Browser": "Browser",
6464
"Nav.ClusterHealth": "Cluster Health",
6565
"Nav.ClusterState": "Cluster State",
66-
"Nav.ClusterNodes": "Cluster Nodes",
66+
"Nav.ClusterNodes": "Nodes Info",
6767
"Nav.Info": "Info",
68-
"Nav.NodeStats": "Node Stats",
68+
"Nav.NodeStats": "Nodes Stats",
6969
"Nav.Overview": "Overview",
7070
"Nav.Indices": "Indices",
7171
"Nav.Plugins": "Plugins",
72-
"Nav.Status": "Status",
72+
"Nav.Status": "Indices Stats",
7373
"Nav.Templates": "Templates",
7474
"Nav.StructuredQuery": "Structured Query",
7575
"NodeActionsMenu.Title": "Actions",

_site/lang/fr_strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n.setKeys({
22
// "General.Elasticsearch": "Elasticsearch",
3-
"General.LoadingFacets" : "Chargement des facettes...",
3+
"General.LoadingAggs" : "Chargement des facettes...",
44
"General.Searching": "Recherche en cours...",
55
"General.Search": "Recherche",
66
"General.Help": "Aide",

_site/lang/pt_strings.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n.setKeys({
22
"General.Elasticsearch": "Elasticsearch",
3-
"General.LoadingFacets": "Carregando Facetas...",
3+
"General.LoadingAggs": "Carregando Facetas...",
44
"General.Searching": "Buscando...",
55
"General.Search": "Busca",
66
"General.Help": "Ajuda",
@@ -51,7 +51,7 @@ i18n.setKeys({
5151
"IndexInfoMenu.Metadata": "Metadados do índice",
5252
"IndexCommand.TextToAnalyze": "Texto para analizar",
5353
"IndexCommand.ShutdownMessage": "digite ''{0}'' para desligar {1}. Nó NÃO PODE ser reiniciado à partir dessa interface",
54-
"IndexOverview.PageTitle": "Visão Geral dos Índices",
54+
"IndexOverview.PageTitle": "Visão geral dos índices",
5555
"IndexSelector.NameWithDocs": "{0} ({1} documentoss)",
5656
"IndexSelector.SearchIndexForDocs": "Busca {0} por documentos onde:",
5757
"FilterBrowser.OutputType": "Resultados: {0}",
@@ -77,14 +77,14 @@ i18n.setKeys({
7777
"NodeInfoMenu.Title": "Informações",
7878
"NodeInfoMenu.ClusterNodeInfo": "Informações do Nó do Cluster",
7979
"NodeInfoMenu.NodeStats": "Estatísticas do Nó",
80-
"NodeType.Client": "Nó Cliente",
80+
"NodeType.Client": "Nó cliente",
8181
"NodeType.Coord": "Coordenador",
82-
"NodeType.Master": "Nó Mestre",
83-
"NodeType.Tribe": "Nó Tribo",
84-
"NodeType.Worker": "Nó Trabalhador",
85-
"NodeType.Unassigned": "Não Atribuido",
82+
"NodeType.Master": "Nó mestre",
83+
"NodeType.Tribe": "Nó tribo",
84+
"NodeType.Worker": "Nó trabalhador",
85+
"NodeType.Unassigned": "Não atribuido",
8686
"OptimizeForm.OptimizeIndex": "Otimizar {0}",
87-
"OptimizeForm.MaxSegments": "Num. Máximo De Segmentos",
87+
"OptimizeForm.MaxSegments": "# Máximo De Segmentos",
8888
"OptimizeForm.ExpungeDeletes": "Apenas Expurgar Exclusões",
8989
"OptimizeForm.FlushAfter": "Flush após Otimizar",
9090
"OptimizeForm.WaitForMerge": "Esperar Por Merge",
@@ -94,9 +94,9 @@ i18n.setKeys({
9494
"Output.CSV": "CSV",
9595
"Output.ShowSource": "Mostrar consulta original",
9696
"Preference.SortCluster": "Ordenar Cluster",
97-
"Sort.ByName": "Por Nome",
98-
"Sort.ByAddress": "Por Endereço",
99-
"Sort.ByType": "Por Tipo",
97+
"Sort.ByName": "Por nome",
98+
"Sort.ByAddress": "Por endereço",
99+
"Sort.ByType": "Por tipo",
100100
"Preference.ViewAliases": "Ver Alias",
101101
"ViewAliases.Grouped": "Agrupado",
102102
"ViewAliases.List": "Lista",
@@ -114,8 +114,8 @@ i18n.setKeys({
114114
"StructuredQuery.ShowRawJson": "Mostrar JSON bruto"
115115
});
116116

117-
i18n.setKeys({
118-
"AnyRequest.TransformerHelp" : "\
117+
i18n.setKeys({
118+
"AnyRequest.TransformerHelp" : "\
119119
<p>O Transformador de Resultados pode ser usado para transformar os resultados de uma consulta de json bruto para um formato mais útil.</p>\
120120
<p>O transformador deve possuir o corpo de uma função javascript. O retorno da função se torna o novo valor passado para o json printer</p>\
121121
<p>Exemplo:<br>\
@@ -133,7 +133,7 @@ i18n.setKeys({
133133
<code>var la = [ root.nodes[Object.keys(root.nodes)[0]].os.load_average[0] ]; return prev ? la.concat(prev) : la;</code> irá retornar a carga média no primeiro nó do cluster no último minuto\
134134
Essa informação pode ser inserida no Gráfico para fazer um gráfico de carga do nó\
135135
"
136-
});
136+
});
137137

138138
i18n.setKeys({
139139
"AnyRequest.DisplayOptionsHelp" : "\

_site/lang/zh_strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n.setKeys({
22
"General.Elasticsearch": "Elasticsearch",
3-
"General.LoadingFacets": "加载聚合查询...",
3+
"General.LoadingAggs": "加载聚合查询...",
44
"General.Searching": "搜索中...",
55
"General.Search": "搜索",
66
"General.Help": "帮助",

src/app/data/boolQuery.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from: 0,
1717
size: this.config.size,
1818
sort: [],
19-
facets: {}
19+
aggs: {}
2020
};
2121
this.defaultClause = this.addClause();
2222
},
@@ -61,7 +61,7 @@
6161
filter["missing"] = missing
6262
query["filter"] = filter;
6363
} else {
64-
query[field] = value;
64+
query[field.substring(field.indexOf(".")+1)] = value;
6565
}
6666
clause[op] = query;
6767
this.search.query.bool[bool].push(clause);

src/app/data/metaData.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848

4949
var coretype_map = {
5050
"string" : "string",
51+
"byte" : "number",
52+
"short" : "number",
5153
"long" : "number",
5254
"integer" : "number",
5355
"float" : "number",
@@ -102,7 +104,7 @@
102104

103105
function createField( mapping, index, type, path, name ) {
104106
var dpath = [ index, type ].concat( path ).join( "." );
105-
var field_name = mapping.index_name || name;
107+
var field_name = mapping.index_name || path.join( "." );
106108
var field = paths[ dpath ] = fields[ field_name ] || $.extend({
107109
field_name : field_name,
108110
core_type : coretype_map[ mapping.type ],

0 commit comments

Comments
 (0)