expose indexRoot value to documents

This commit is contained in:
simon987 2023-10-08 21:00:03 -04:00
parent 8299237ea0
commit b8c905bd64
3 changed files with 16 additions and 17 deletions

View File

@ -33,18 +33,6 @@ class Sist2Api {
getSist2Info() { getSist2Info() {
return axios.get(`${this.baseUrl}i`).then(resp => { return axios.get(`${this.baseUrl}i`).then(resp => {
const indices = resp.data.indices;
resp.data.indices = indices.map(idx => {
return {
id: idx.id,
name: idx.name,
timestamp: idx.timestamp,
version: idx.version,
models: idx.models,
};
});
this.sist2Info = resp.data; this.sist2Info = resp.data;
return resp.data; return resp.data;
@ -155,6 +143,12 @@ class Sist2Api {
} }
} }
_getIndexRoot(indexId) {
console.log(indexId)
console.log(this.sist2Info.indices.find(idx => idx.id === indexId))
return this.sist2Info.indices.find(idx => idx.id === indexId).root;
}
esQuery(query) { esQuery(query) {
return axios.post(`${this.baseUrl}es`, query).then(resp => { return axios.post(`${this.baseUrl}es`, query).then(resp => {
const res = resp.data; const res = resp.data;
@ -163,6 +157,7 @@ class Sist2Api {
res.hits.hits.forEach((hit) => { res.hits.hits.forEach((hit) => {
hit["_source"]["name"] = strUnescape(hit["_source"]["name"]); hit["_source"]["name"] = strUnescape(hit["_source"]["name"]);
hit["_source"]["path"] = strUnescape(hit["_source"]["path"]); hit["_source"]["path"] = strUnescape(hit["_source"]["path"]);
hit["_source"]["indexRoot"] = this._getIndexRoot(hit["_source"]["index"]);
this.setHitProps(hit); this.setHitProps(hit);
this.setHitTags(hit); this.setHitTags(hit);

View File

@ -51,11 +51,11 @@
#include <ctype.h> #include <ctype.h>
#include "git_hash.h" #include "git_hash.h"
#define VERSION "3.3.4" #define VERSION "3.3.5"
static const char *const Version = VERSION; static const char *const Version = VERSION;
static const int VersionMajor = 3; static const int VersionMajor = 3;
static const int VersionMinor = 3; static const int VersionMinor = 3;
static const int VersionPatch = 4; static const int VersionPatch = 5;
#ifndef SIST_PLATFORM #ifndef SIST_PLATFORM
#define SIST_PLATFORM unknown #define SIST_PLATFORM unknown

View File

@ -368,6 +368,10 @@ void index_info(struct mg_connection *nc) {
cJSON_AddNumberToObject(idx_json, "timestamp", (double) idx->desc.timestamp); cJSON_AddNumberToObject(idx_json, "timestamp", (double) idx->desc.timestamp);
cJSON_AddItemToArray(arr, idx_json); cJSON_AddItemToArray(arr, idx_json);
#ifdef SIST_DEBUG_INFO
cJSON_AddStringToObject(idx_json, "root", idx->desc.root);
#endif
cJSON *models = database_get_models(idx->db); cJSON *models = database_get_models(idx->db);
cJSON_AddItemToObject(idx_json, "models", models); cJSON_AddItemToObject(idx_json, "models", models);
} }