My index has around 170 Million documents. An example document would be like :
{
"_index" : "ppdata",
"_type" : "_doc",
"_id" : "E-cA_H8BvtbXwHDqN7ne",
"_score" : 1.0,
"_source" : {
"gender" : 0,
"age" : 0,
"carrier" : "vodafone",
"placecategory" : "Financial Institution",
"brandsvisited" : "JPMC Bank",
"behavior" : 0,
"polygonid" : 1574
}
The following are the mapping for the index:
{
"ppdata" : {
"mappings" : {
"dynamic" : "false",
"properties" : {
"age" : {
"type" : "integer"
},
"brandsvisited" : {
"type" : "text",
"analyzer" : "standard"
},
"carrier" : {
"type" : "keyword"
},
"gender" : {
"type" : "integer"
},
"behavior" : {
"type" : "text",
"analyzer" : "standard"
},
"placecategory" : {
"type" : "text",
"analyzer" : "standard"
},
"polygonid" : {
"type" : "integer"
}
}
}
}
}
In this the field behavior is defined as text
- however the data has 0
in it.
In this I am trying to update the behavior
field with tag BFSI Consumer
- if the document has a tag Bank
in brandsvisited
or Financial
in placecategory
. I have used the following curl script
curl -X POST "http://localhost:9200/ppdata/_update_by_query?conflicts=proceed&pretty" -H 'Content-Type: application/json' -d'
{
"script": {
"source": "ctx._source.behavior += \",BFSI Consumers\"",
"lang": "painless"
},
"query": {
"bool" : {
"should" : [
{ "match" : {"brandsvisited" : "Bank"} },
{ "match" : {"placecategory" : "Financial"} }
]
}
}
}
'
This is working in a smaller version of the index where I do not have 0
value in behavior
field. However it fails in my primary database. The following is the error:
{
"error" : {
"root_cause" : [
{
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx._source.behavior += \",BFSI Consumers\"",
" ^---- HERE"
],
"script" : "ctx._source.behavior += \",BFSI Consumers\"",
"lang" : "painless",
"position" : {
"offset" : 11,
"start" : 0,
"end" : 44
}
}
],
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"ctx._source.behavior += \",BFSI Consumers\"",
" ^---- HERE"
],
"script" : "ctx._source.behavior += \",BFSI Consumers\"",
"lang" : "painless",
"position" : {
"offset" : 11,
"start" : 0,
"end" : 44
},
"caused_by" : {
"type" : "class_cast_exception",
"reason" : "cannot implicitly cast def [int] to java.lang.String"
}
},
"status" : 400
}