66 lines
1018 B
Plaintext
66 lines
1018 B
Plaintext
// This file is autogenerated, DO NOT EDIT
|
|
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
|
|
|
[source, js]
|
|
----
|
|
const response0 = await client.indices.create({
|
|
index: 'my_index',
|
|
body: {
|
|
mappings: {
|
|
properties: {
|
|
city: {
|
|
type: 'text',
|
|
fields: {
|
|
raw: {
|
|
type: 'keyword'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
console.log(response0)
|
|
|
|
const response1 = await client.index({
|
|
index: 'my_index',
|
|
id: '1',
|
|
body: {
|
|
city: 'New York'
|
|
}
|
|
})
|
|
console.log(response1)
|
|
|
|
const response2 = await client.index({
|
|
index: 'my_index',
|
|
id: '2',
|
|
body: {
|
|
city: 'York'
|
|
}
|
|
})
|
|
console.log(response2)
|
|
|
|
const response3 = await client.search({
|
|
index: 'my_index',
|
|
body: {
|
|
query: {
|
|
match: {
|
|
city: 'york'
|
|
}
|
|
},
|
|
sort: {
|
|
'city.raw': 'asc'
|
|
},
|
|
aggs: {
|
|
Cities: {
|
|
terms: {
|
|
field: 'city.raw'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
console.log(response3)
|
|
----
|
|
|