🔎 Elasticsearch endpoints for you know, search
This commit is contained in:
@@ -190,10 +190,11 @@ export default class ImportService extends Service {
|
||||
comicMetadata.sourcedMetadata.comicvine.volumeInformation =
|
||||
volumeDetails.results;
|
||||
}
|
||||
return new Promise(async (resolve, reject) => {
|
||||
Comic.create(ctx.params, (error, data) => {
|
||||
return await Comic.create(
|
||||
ctx.params,
|
||||
(error, data) => {
|
||||
if (data) {
|
||||
resolve(data);
|
||||
return data;
|
||||
} else if (error) {
|
||||
console.log("data", data);
|
||||
console.log("error", error);
|
||||
@@ -204,8 +205,9 @@ export default class ImportService extends Service {
|
||||
error
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
},
|
||||
applyComicVineMetadata: {
|
||||
@@ -484,14 +486,15 @@ export default class ImportService extends Service {
|
||||
issues: [
|
||||
{
|
||||
$match: {
|
||||
"sourcedMetadata.comicvine": {
|
||||
$gt: {},
|
||||
},
|
||||
"sourcedMetadata.comicvine.volumeInformation":
|
||||
{
|
||||
$gt: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: "$sourcedMetadata.comicvine",
|
||||
_id: "$sourcedMetadata.comicvine.volumeInformation",
|
||||
data: { $push: "$$ROOT._id" },
|
||||
},
|
||||
},
|
||||
|
||||
@@ -102,8 +102,7 @@ export default class QueueService extends Service {
|
||||
acquisition: {
|
||||
wanted: false,
|
||||
}
|
||||
},
|
||||
{}
|
||||
}
|
||||
);
|
||||
return Promise.resolve({
|
||||
dbImportResult,
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
|
||||
import { DbMixin } from "../mixins/db.mixin";
|
||||
import Comic from "../models/comic.model";
|
||||
import { flatten, isEmpty, isUndefined } from "lodash";
|
||||
import { flatten, isEmpty, isUndefined, map } from "lodash";
|
||||
import { eSClient } from "../models/comic.model";
|
||||
const s = eSClient.helpers.msearch();
|
||||
|
||||
@@ -52,11 +52,11 @@ export default class SettingsService extends Service {
|
||||
body: queries,
|
||||
});
|
||||
|
||||
body.responses.forEach((match) => {
|
||||
body.results.forEach((match) => {
|
||||
console.log(match.hits.hits);
|
||||
});
|
||||
|
||||
return body.responses;
|
||||
return body.results;
|
||||
},
|
||||
},
|
||||
issue: {
|
||||
@@ -68,11 +68,16 @@ export default class SettingsService extends Service {
|
||||
volumeName: string;
|
||||
issueNumber: string;
|
||||
};
|
||||
pagination: {
|
||||
size: number;
|
||||
from: number,
|
||||
};
|
||||
}>
|
||||
) => {
|
||||
console.log(ctx.params.query);
|
||||
console.log(ctx.params);
|
||||
const { query, pagination } = ctx.params;
|
||||
let eSQuery = {};
|
||||
if (isEmpty(ctx.params.query)) {
|
||||
if (isEmpty(query)) {
|
||||
Object.assign(eSQuery, {
|
||||
match_all: {},
|
||||
});
|
||||
@@ -80,24 +85,23 @@ export default class SettingsService extends Service {
|
||||
Object.assign(eSQuery, {
|
||||
match: {
|
||||
"rawFileDetails.name":
|
||||
ctx.params.query.volumeName,
|
||||
query.volumeName,
|
||||
},
|
||||
});
|
||||
}
|
||||
console.log("eSQuery", eSQuery);
|
||||
console.log(query);
|
||||
const result = await eSClient.search(
|
||||
{
|
||||
index: "comics",
|
||||
body: {
|
||||
query: eSQuery,
|
||||
},
|
||||
size: 50,
|
||||
...pagination,
|
||||
},
|
||||
{ hydrate: true }
|
||||
);
|
||||
console.log(result.body)
|
||||
const { hits } = result.body;
|
||||
return hits;
|
||||
|
||||
return result;
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user