Merge branch 'develop'

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2024-12-27 09:56:20 +07:00
commit cbd7bbfdae
2 changed files with 17 additions and 1 deletions

View file

@ -64,6 +64,7 @@ export class LogController extends Controller {
"host",
"responseCode",
"output",
"userName",
"rootId",
].map((v) => ({
wildcard: { [`${v}.keyword`]: `*${search}*` },

View file

@ -52,6 +52,8 @@ export class ReportController extends Controller {
const queryData = await elasticsearch.search({
index: ELASTICSEARCH_INDEX,
scroll: '1m', // เวลาที่ scroll session จะคงอยู่
size: 10000,
query: {
bool: {
must: [
@ -68,6 +70,7 @@ export class ReportController extends Controller {
"host",
"responseCode",
"output",
"userName",
"rootId",
].map((v) => ({
wildcard: { [`${v}.keyword`]: `*${search}*` },
@ -118,6 +121,18 @@ export class ReportController extends Controller {
},
sort: [{ startTimeStamp: sort }],
});
let scrollId = queryData._scroll_id;
let results = queryData.hits.hits;
// ดึงข้อมูลถัดไป
const nextBatch = await elasticsearch.scroll({
scroll_id: scrollId,
scroll: '1m',
});
// เก็บข้อมูลทั้งหมดใน results
results = results.concat(nextBatch.hits.hits);
interface DocumentSource {
startTimeStamp: Date;
userName: string;
@ -128,7 +143,7 @@ export class ReportController extends Controller {
logType: string;
responseDescription: string;
}
const raw_data = queryData.hits.hits.map((x) => {
const raw_data = results.map((x) => {
const source = x._source as DocumentSource;
return {
id: x._id,