🤯 Added a ES indice delete endpoint
This commit is contained in:
@@ -547,25 +547,25 @@ export default class ImportService extends Service {
|
|||||||
flushDB: {
|
flushDB: {
|
||||||
rest: "POST /flushDB",
|
rest: "POST /flushDB",
|
||||||
params: {},
|
params: {},
|
||||||
async handler(ctx: Context<{}>) {
|
handler: async (ctx: Context<{}>) => {
|
||||||
return await Comic.collection
|
return await Comic.collection
|
||||||
.drop()
|
.drop()
|
||||||
.then((data) => {
|
.then(async (data) => {
|
||||||
console.info(data);
|
console.info(data);
|
||||||
const foo = fsExtra.emptyDirSync(
|
const coversFolderDeleteResult = fsExtra.emptyDirSync(
|
||||||
path.resolve(`${USERDATA_DIRECTORY}/covers`)
|
path.resolve(`${USERDATA_DIRECTORY}/covers`)
|
||||||
);
|
);
|
||||||
const foo2 = fsExtra.emptyDirSync(
|
const expandedFolderDeleteResult = fsExtra.emptyDirSync(
|
||||||
path.resolve(
|
path.resolve(
|
||||||
`${USERDATA_DIRECTORY}/expanded`
|
`${USERDATA_DIRECTORY}/expanded`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return { data, foo, foo2 };
|
const eSIndicesDeleteResult = await ctx.broker.call("search.deleteElasticSearchIndices", {});
|
||||||
|
return { data, coversFolderDeleteResult, expandedFolderDeleteResult, eSIndicesDeleteResult };
|
||||||
})
|
})
|
||||||
.catch((error) => error);
|
.catch((error) => error);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
unrarArchive: {
|
unrarArchive: {
|
||||||
rest: "POST /unrarArchive",
|
rest: "POST /unrarArchive",
|
||||||
params: {},
|
params: {},
|
||||||
|
|||||||
@@ -69,38 +69,55 @@ export default class SettingsService extends Service {
|
|||||||
};
|
};
|
||||||
pagination: {
|
pagination: {
|
||||||
size: number;
|
size: number;
|
||||||
from: number,
|
from: number;
|
||||||
};
|
};
|
||||||
}>
|
}>
|
||||||
) => {
|
) => {
|
||||||
console.log(ctx.params);
|
try {
|
||||||
const { query, pagination } = ctx.params;
|
console.log(ctx.params);
|
||||||
let eSQuery = {};
|
const { query, pagination } = ctx.params;
|
||||||
if (isEmpty(query)) {
|
let eSQuery = {};
|
||||||
Object.assign(eSQuery, {
|
if (isEmpty(query)) {
|
||||||
match_all: {},
|
Object.assign(eSQuery, {
|
||||||
});
|
match_all: {},
|
||||||
} else {
|
});
|
||||||
Object.assign(eSQuery, {
|
} else {
|
||||||
multi_match: {
|
Object.assign(eSQuery, {
|
||||||
fields: ["rawFileDetails.name", "sourcedMetadata.comicvine.name", "sourcedMetadata.comicvine.volumeInformation.name"],
|
multi_match: {
|
||||||
query: query.volumeName,
|
fields: [
|
||||||
|
"rawFileDetails.name",
|
||||||
|
"sourcedMetadata.comicvine.name",
|
||||||
|
"sourcedMetadata.comicvine.volumeInformation.name",
|
||||||
|
],
|
||||||
|
query: query.volumeName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log(query);
|
||||||
|
const result = await eSClient.search(
|
||||||
|
{
|
||||||
|
index: "comics",
|
||||||
|
body: {
|
||||||
|
query: eSQuery,
|
||||||
|
},
|
||||||
|
...pagination,
|
||||||
},
|
},
|
||||||
});
|
{ hydrate: true }
|
||||||
}
|
);
|
||||||
console.log(query);
|
|
||||||
const result = await eSClient.search(
|
|
||||||
{
|
|
||||||
index: "comics",
|
|
||||||
body: {
|
|
||||||
query: eSQuery,
|
|
||||||
},
|
|
||||||
...pagination,
|
|
||||||
},
|
|
||||||
{ hydrate: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
return new Errors.MoleculerClientError("Failed to return data", 404, "ElasticSearch error", error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
deleteElasticSearchIndices: {
|
||||||
|
rest: "GET /deleteElasticSearchIndices",
|
||||||
|
params: {},
|
||||||
|
handler: async (ctx: Context<{}>) => {
|
||||||
|
return await eSClient.indices.delete({
|
||||||
|
index: "comics",
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user