Updated examples
This commit is contained in:
@ -18,9 +18,12 @@
|
||||
*/
|
||||
|
||||
import { Client } from '../../'
|
||||
import { Q, A } from '../'
|
||||
import { Q, A, F } from '../'
|
||||
|
||||
async function run () {
|
||||
/**
|
||||
* Pure function API
|
||||
*/
|
||||
async function run1 () {
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
// get the day where the most commits were made
|
||||
@ -41,4 +44,30 @@ async function run () {
|
||||
console.log(body.aggregations)
|
||||
}
|
||||
|
||||
run().catch(console.log)
|
||||
/**
|
||||
* Fluent API
|
||||
*/
|
||||
async function run2 () {
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
// get the day where the most commits were made
|
||||
const { body } = await client.search({
|
||||
index: 'git',
|
||||
body: new F()
|
||||
.size(0)
|
||||
// 'day_most_commits' is the name of the aggregation
|
||||
.aggs(
|
||||
A.day_most_commits.dateHistogram({
|
||||
field: 'committed_date',
|
||||
interval: 'day',
|
||||
min_doc_count: 1,
|
||||
order: { _count: 'desc' }
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
console.log(body.aggregations)
|
||||
}
|
||||
|
||||
run1().catch(console.log)
|
||||
run2().catch(console.log)
|
||||
|
||||
Reference in New Issue
Block a user