Skip to content

Commit

Permalink
Fix explain issues on newer versions of ES
Browse files Browse the repository at this point in the history
  • Loading branch information
worleydl committed Oct 7, 2022
1 parent a6c1a40 commit 0ada699
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions services/esUrlSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ angular.module('o19s.splainer-search')
* for an ES document.
*
*/
function buildDocUrl (uri, doc) {
function buildDocUrl (uri, doc, addExplain) {
var index = doc._index;
var type = doc._type;
var id = doc._id;

var url = self.buildBaseUrl(uri);
url = url + '/' + index + '/' + type + '/' + id;

if (type) {
url = url + '/' + index + '/' + type + '/' + id + (addExplain ? '/_explain' : '');
} else {
url = url + '/' + index + '/' + (addExplain ? '_explain/' : '') + id;
}

return url;
}
Expand All @@ -80,13 +85,12 @@ angular.module('o19s.splainer-search')
* Builds ES URL of the form [protocol]://[host][:port]/[index]/[type]/[id]/_explain
* for an ES document.
*
* For newer versions of ES the format is as doc types are deprecated:
* [protocol]://[host][:port]/[index]/_explain/[id]
*
*/
function buildExplainUrl (uri, doc) {
var docUrl = self.buildDocUrl(uri, doc);

var url = docUrl + '/_explain';

return url;
return buildDocUrl(uri, doc, true);
}

/**
Expand Down

0 comments on commit 0ada699

Please sign in to comment.