Skip to content

Commit c05a6b7

Browse files
committed
Fix index Test Analyzer feature for ES versions after 5.x
1 parent 28d9351 commit c05a6b7

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

_site/app.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,9 +3151,19 @@
31513151
}).open();
31523152
},
31533153
_testAnalyser_handler: function(index) {
3154-
this.cluster.get(encodeURIComponent( index.name ) + "/_analyze?text=" + encodeURIComponent( prompt( i18n.text("IndexCommand.TextToAnalyze") ) ), function(r) {
3155-
alert(JSON.stringify(r, true, " "));
3156-
});
3154+
if(this.cluster._version_parts[0] <= 5) {
3155+
this.cluster.get(encodeURIComponent( index.name ) + "/_analyze?text=" + encodeURIComponent( prompt( i18n.text("IndexCommand.TextToAnalyze") ) ), function(r) {
3156+
new ui.JsonPanel({ json: r, title: "" });
3157+
});
3158+
} else {
3159+
var command = {
3160+
"analyzer" : prompt( i18n.text("IndexCommand.AnalyzerToUse") ),
3161+
"text": prompt( i18n.text("IndexCommand.TextToAnalyze") )
3162+
};
3163+
this.cluster.post(encodeURIComponent(index.name) + "/_analyze", JSON.stringify(command), function(r) {
3164+
new ui.JsonPanel({ json: r, title: "" });
3165+
});
3166+
}
31573167
},
31583168
_deleteIndexAction_handler: function(index) {
31593169
if( prompt( i18n.text("AliasForm.DeleteAliasMessage", i18n.text("Command.DELETE"), index.name ) ) === i18n.text("Command.DELETE") ) {

_site/lang/en_strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ i18n.setKeys({
5151
"IndexInfoMenu.Status": "Index Status",
5252
"IndexInfoMenu.Metadata": "Index Metadata",
5353
"IndexCommand.TextToAnalyze": "Text to Analyse",
54+
"IndexCommand.AnalyzerToUse": "Name of Analyzer (built-in or customized)",
5455
"IndexCommand.ShutdownMessage": "type ''{0}'' to shutdown {1}. Node can NOT be restarted from this interface",
5556
"IndexOverview.PageTitle": "Indices Overview",
5657
"IndexSelector.NameWithDocs": "{0} ({1} docs)",

src/app/lang/en_strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ i18n.setKeys({
5151
"IndexInfoMenu.Status": "Index Status",
5252
"IndexInfoMenu.Metadata": "Index Metadata",
5353
"IndexCommand.TextToAnalyze": "Text to Analyse",
54+
"IndexCommand.AnalyzerToUse": "Name of Analyzer (built-in or customized)",
5455
"IndexCommand.ShutdownMessage": "type ''{0}'' to shutdown {1}. Node can NOT be restarted from this interface",
5556
"IndexOverview.PageTitle": "Indices Overview",
5657
"IndexSelector.NameWithDocs": "{0} ({1} docs)",

src/app/ui/nodesView/nodesView.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,19 @@
101101
}).open();
102102
},
103103
_testAnalyser_handler: function(index) {
104-
this.cluster.get(encodeURIComponent( index.name ) + "/_analyze?text=" + encodeURIComponent( prompt( i18n.text("IndexCommand.TextToAnalyze") ) ), function(r) {
105-
alert(JSON.stringify(r, true, " "));
106-
});
104+
if(this.cluster._version_parts[0] <= 5) {
105+
this.cluster.get(encodeURIComponent( index.name ) + "/_analyze?text=" + encodeURIComponent( prompt( i18n.text("IndexCommand.TextToAnalyze") ) ), function(r) {
106+
new ui.JsonPanel({ json: r, title: "" });
107+
});
108+
} else {
109+
var command = {
110+
"analyzer" : prompt( i18n.text("IndexCommand.AnalyzerToUse") ),
111+
"text": prompt( i18n.text("IndexCommand.TextToAnalyze") )
112+
};
113+
this.cluster.post(encodeURIComponent(index.name) + "/_analyze", JSON.stringify(command), function(r) {
114+
new ui.JsonPanel({ json: r, title: "" });
115+
});
116+
}
107117
},
108118
_deleteIndexAction_handler: function(index) {
109119
if( prompt( i18n.text("AliasForm.DeleteAliasMessage", i18n.text("Command.DELETE"), index.name ) ) === i18n.text("Command.DELETE") ) {

0 commit comments

Comments
 (0)