Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
80a04ca893 | |||
93f739c79e |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiclient.xyz/elasticsearch",
|
"name": "@apiclient.xyz/elasticsearch",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "log to elasticsearch in a kibana compatible format",
|
"description": "log to elasticsearch in a kibana compatible format",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiclient.xyz/elasticsearch',
|
name: '@apiclient.xyz/elasticsearch',
|
||||||
version: '2.0.2',
|
version: '2.0.3',
|
||||||
description: 'log to elasticsearch in a kibana compatible format'
|
description: 'log to elasticsearch in a kibana compatible format'
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,6 @@ export class ElasticDoc {
|
|||||||
|
|
||||||
async pipeDocument(optionsArg: { docId: string; timestamp?: string | number; doc: any }) {
|
async pipeDocument(optionsArg: { docId: string; timestamp?: string | number; doc: any }) {
|
||||||
// If 'onlyNew' is true, compare the document timestamp with the latest timestamp
|
// If 'onlyNew' is true, compare the document timestamp with the latest timestamp
|
||||||
if (this.onlyNew) {
|
|
||||||
if (this.latestTimestamp && optionsArg.timestamp <= this.latestTimestamp) {
|
|
||||||
// Omit the document
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.ensureIndexExists(optionsArg.doc);
|
await this.ensureIndexExists(optionsArg.doc);
|
||||||
|
|
||||||
@ -104,11 +98,18 @@ export class ElasticDoc {
|
|||||||
...(optionsArg.timestamp && { '@timestamp': optionsArg.timestamp }),
|
...(optionsArg.timestamp && { '@timestamp': optionsArg.timestamp }),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (this.onlyNew) {
|
||||||
|
if (this.latestTimestamp && optionsArg.timestamp <= this.latestTimestamp) {
|
||||||
|
// Omit the document
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
await this.client.index({
|
await this.client.index({
|
||||||
index: this.index,
|
index: this.index,
|
||||||
id: optionsArg.docId,
|
id: optionsArg.docId,
|
||||||
body: documentBody,
|
body: documentBody,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
this.sessionDocs.add(optionsArg.docId);
|
this.sessionDocs.add(optionsArg.docId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user