Hello,
i am investigating the integration of ElasticSearch and am following the documentation and the example of explicit mapping. I created index, where I want to map fields as smallest Integer - the value will be always in range 0…100 - because the documentation claims that this would be beneficial in performance. Lets throw an example:
PUT /profile/
{
"mappings": {
"properties": {
"ag": { "type": "byte" },
"gn": { "type": "byte" },
"d": { "type": "boolean" }
}
}
}
But then when I use this JavaScript client in the Cloud Code and want to pass values that are as Number I get an error. Example:
async function(profile, newDocument) { //PrsProfile, Bool
const result = await esClient.index({
id: profile.id,
index: 'profile',
type: ((newDocument == true) ? 'create' : 'index'),
body: {
ag: profile.get("ag"), // <-- this is Number of value 36, but elastic expects byte type
gn: profile.get("gn"), // <-- this is Number of value 0, but elastic expects byte type
d: profile.get("d")
}
})
return (`Hello world + ${result}`);
Error: mapping update rejected by primary
java.lang.IllegalArgumentException: mapper [ag] cannot be changed from type [byte] to [long]
using dynamic mapping is working fine, because it maps as long
Am I correct that it is not possible to use Cloud Code function and pass “byte” or “integer” type in that body header? Or is there a way how to pass Integer?
Trying it through Int8Array this way also don’t work:
var ageIntArr = new Int8Array(1);
ageIntArr[0] = 30;
const result = await esClient.index({
id: profile.id,
index: 'profile',
type: ((newDocument == true) ? 'create' : 'index'),
body: {
ag: ageIntArr[0]
}
})
Thank you!