42 lines
789 B
Plaintext
42 lines
789 B
Plaintext
// This file is autogenerated, DO NOT EDIT
|
|
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
|
|
|
[source, js]
|
|
----
|
|
const response = await client.search({
|
|
index: "sales",
|
|
runtime_mappings: {
|
|
"price.euros": {
|
|
type: "double",
|
|
script: {
|
|
source:
|
|
"\n emit(doc['price'].value * params.conversion_rate)\n ",
|
|
params: {
|
|
conversion_rate: 0.835526591,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
aggs: {
|
|
price_ranges: {
|
|
range: {
|
|
field: "price.euros",
|
|
ranges: [
|
|
{
|
|
to: 100,
|
|
},
|
|
{
|
|
from: 100,
|
|
to: 200,
|
|
},
|
|
{
|
|
from: 200,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
});
|
|
console.log(response);
|
|
----
|