forked from kuzzleio/kourou
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.ts
37 lines (28 loc) · 858 Bytes
/
get.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { flags } from '@oclif/command'
import { Client } from '@elastic/elasticsearch'
import { Kommand } from '../../../common'
export default class EsGet extends Kommand {
static initSdk = false
static description = 'Gets a document from ES'
static flags = {
help: flags.help(),
node: flags.string({
char: 'n',
description: 'Elasticsearch server URL',
default: 'http://localhost:9200',
}),
}
static args = [
{ name: 'index', description: 'ES Index name', required: true },
{ name: 'id', description: 'Document ID', required: true }
]
async runSafe() {
const esClient = new Client({ node: this.flags.node })
const esRequest = {
index: this.args.index,
id: this.args.id
}
const { body } = await esClient.get(esRequest)
this.log(JSON.stringify(body, null, 2))
}
}