|
694 | 694 |
|
695 | 695 | var coretype_map = { |
696 | 696 | "string" : "string", |
| 697 | + "byte" : "number", |
| 698 | + "short" : "number", |
697 | 699 | "long" : "number", |
698 | 700 | "integer" : "number", |
699 | 701 | "float" : "number", |
|
748 | 750 |
|
749 | 751 | function createField( mapping, index, type, path, name ) { |
750 | 752 | var dpath = [ index, type ].concat( path ).join( "." ); |
751 | | - var field_name = mapping.index_name || name; |
| 753 | + var field_name = mapping.index_name || path.join( "." ); |
752 | 754 | var field = paths[ dpath ] = fields[ field_name ] || $.extend({ |
753 | 755 | field_name : field_name, |
754 | 756 | core_type : coretype_map[ mapping.type ], |
|
856 | 858 | from: 0, |
857 | 859 | size: this.config.size, |
858 | 860 | sort: [], |
859 | | - facets: {}, |
| 861 | + aggs: {}, |
860 | 862 | version: true |
861 | 863 | }; |
862 | 864 | this.defaultClause = this.addClause(); |
|
1005 | 1007 | this.defaultClause = this.addClause(); |
1006 | 1008 | } |
1007 | 1009 | }, |
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; |
1013 | 1015 | }, |
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]; |
1017 | 1019 | }, |
1018 | 1020 | _setClause: function(value, field, op, bool) { |
1019 | 1021 | var clause = {}, query = {}; |
|
1144 | 1146 | from: 0, |
1145 | 1147 | size: this.config.size, |
1146 | 1148 | sort: [], |
1147 | | - facets: {} |
| 1149 | + aggs: {} |
1148 | 1150 | }; |
1149 | 1151 | this.defaultClause = this.addClause(); |
1150 | 1152 | }, |
|
1189 | 1191 | filter["missing"] = missing |
1190 | 1192 | query["filter"] = filter; |
1191 | 1193 | } else { |
1192 | | - query[field] = value; |
| 1194 | + query[field.substring(field.indexOf(".")+1)] = value; |
1193 | 1195 | } |
1194 | 1196 | clause[op] = query; |
1195 | 1197 | this.search.query.bool[bool].push(clause); |
|
2078 | 2080 | this.attach( parent ); |
2079 | 2081 | }, |
2080 | 2082 | _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 ); |
2082 | 2086 | this._downloadLink.show(); |
2083 | 2087 | }, |
2084 | 2088 | _parseResults: function( results ) { |
|
2421 | 2425 | } |
2422 | 2426 | }, |
2423 | 2427 | 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]; |
2435 | 2429 | }, |
2436 | 2430 | _selectAlias_handler: function(jEv) { |
2437 | 2431 | var indices = (jEv.target.selectedIndex === 0) ? [] : this.metadata.getIndices($(jEv.target).val()); |
|
2632 | 2626 | ] }; |
2633 | 2627 | }, |
2634 | 2628 | _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); }); |
2636 | 2632 | return { tag: "DIV", cls: "uiQueryFilter-section uiQueryFilter-filters", children: [ |
2637 | 2633 | { tag: "HEADER", text: i18n.text("QueryFilter-Header-Fields") }, |
2638 | 2634 | { tag: "DIV", children: fields.map( function(name ) { |
|
3209 | 3205 | ); }, |
3210 | 3206 | _indexHeader_template: function( index ) { |
3211 | 3207 | 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" ) ); |
3214 | 3210 | return index.name ? { tag: "TH", cls: (closed ? "close" : ""), children: [ |
3215 | 3211 | { tag: "H3", text: index.name }, |
3216 | 3212 | { tag: "DIV", text: line1 }, |
|
3585 | 3581 | }.bind(this)); |
3586 | 3582 | this.query.search.size = 0; |
3587 | 3583 | this.query.on("results", this._stat_handler); |
3588 | | - this.query.on("results", this._facet_handler); |
| 3584 | + this.query.on("results", this._aggs_handler); |
3589 | 3585 | this.buildHistogram(); |
3590 | 3586 | }, |
3591 | 3587 | 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 } |
3595 | 3590 | }); |
3596 | 3591 | this.query.query(); |
3597 | | - this.query.removeFacet(this.statFacet); |
| 3592 | + this.query.removeAggs(this.statAggs); |
3598 | 3593 | }, |
3599 | 3594 | _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]; |
3602 | 3597 | // here we are calculating the approximate range that will give us less than 121 columns |
3603 | 3598 | var rangeNames = [ "year", "year", "month", "day", "hour", "minute" ]; |
3604 | 3599 | var rangeFactors = [100000, 12, 30, 24, 60, 60000 ]; |
|
3610 | 3605 | this.intervalRange *= factor; |
3611 | 3606 | range = range / factor; |
3612 | 3607 | } while(range > 70); |
3613 | | - this.dateFacet = this.query.addFacet({ |
| 3608 | + this.dateAggs = this.query.addAggs({ |
3614 | 3609 | date_histogram : { |
3615 | 3610 | field: this.config.spec.field_name, |
3616 | | - interval: this.intervalName, |
3617 | | - global: true |
| 3611 | + interval: this.intervalName |
3618 | 3612 | } |
3619 | 3613 | }); |
3620 | 3614 | this.query.query(); |
3621 | | - this.query.removeFacet(this.dateFacet); |
| 3615 | + this.query.removeAggs(this.dateAggs); |
3622 | 3616 | }, |
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; } |
3625 | 3619 | var buckets = [], range = this.intervalRange; |
3626 | 3620 | var min = Math.floor(this.stats.min / range) * range; |
3627 | 3621 | 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; |
3630 | 3624 | }, this); |
3631 | 3625 | for(var i = 0; i < buckets.length; i++) { |
3632 | 3626 | buckets[i] = buckets[i] || 0; |
|
3653 | 3647 | }, |
3654 | 3648 | _main_template: function() { return ( |
3655 | 3649 | { tag: "DIV", cls: "uiDateHistogram loading", css: { height: "50px" }, children: [ |
3656 | | - i18n.text("General.LoadingFacets") |
| 3650 | + i18n.text("General.LoadingAggs") |
3657 | 3651 | ] } |
3658 | 3652 | ); } |
3659 | 3653 | }); |
|
3935 | 3929 | ops = ["missing"]; |
3936 | 3930 | } else if(spec.type === 'ip') { |
3937 | 3931 | ops = ["term", "range", "fuzzy", "query_string", "missing"]; |
| 3932 | + } else if(spec.type === 'boolean') { |
| 3933 | + ops = ["term"] |
3938 | 3934 | } |
3939 | 3935 | select.after({ tag: "SELECT", cls: "op", onchange: this._changeQueryOp_handler, children: ops.map(ut.option_template) }); |
3940 | 3936 | select.next().change(); |
|
3985 | 3981 |
|
3986 | 3982 | _range_template: function() { |
3987 | 3983 | 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) }, |
3989 | 3985 | { 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) }, |
3991 | 3987 | { tag: "INPUT", type: "text", cls: "highqual" } |
3992 | 3988 | ]}; |
3993 | 3989 | }, |
|
4016 | 4012 | this.update(); |
4017 | 4013 | }, |
4018 | 4014 | update: function() { |
4019 | | - this.cluster.get( "_status", this._update_handler ); |
| 4015 | + this.cluster.get( "_stats", this._update_handler ); |
4020 | 4016 | }, |
4021 | 4017 |
|
4022 | 4018 | _update_handler: function(data) { |
|
4043 | 4039 | }, |
4044 | 4040 |
|
4045 | 4041 | _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 ) }; |
4047 | 4043 | } |
4048 | 4044 | }); |
4049 | 4045 |
|
|
4066 | 4062 | var quicks = [ |
4067 | 4063 | { text: i18n.text("Nav.Info"), path: "" }, |
4068 | 4064 | { 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" }, |
4072 | 4068 | { text: i18n.text("Nav.ClusterState"), path: "_cluster/state" }, |
4073 | 4069 | { text: i18n.text("Nav.ClusterHealth"), path: "_cluster/health" }, |
4074 | 4070 | { text: i18n.text("Nav.Templates"), path: "_template" } |
|
4216 | 4212 | { tag: "TD", children: [ |
4217 | 4213 | { tag: "H3", text: index.name } |
4218 | 4214 | ] }, |
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 ) } |
4221 | 4217 | ] } |
4222 | 4218 | ); }, |
4223 | 4219 | _main_template: function() { |
|
0 commit comments