Hello,
I'm trying to create a runtime field which takes a multi-value long field and converts it to a multi-value string field. This way I can perform a regex search on it. The following search works, but only for fields only with 100 values or less:
{"runtime_mappings": {
"numbers_to_string": {
"type": "keyword",
"script": {
"source": "if (doc.containsKey('numbers')) {int count = 0; for (item in doc['numbers']) { if (count < 100) {emit(item.toString()); count++} }}"
}
}
},
"fields": [
"numbers_to_string"
],
"query": {
"bool": {"must": [
{"regexp": {"numbers_to_string": {"value": ".*123.*"}}}
]}
},
"_source": ["numbers_to_string"]
}
if I increase the cap above 100 I get a max emits error. How can I get around this?
An alternative approach I considered was using a runtime "text" field and separating the numbers by a space. But, I get the following error:
{
"type" : "mapper_parsing_exception",
"reason" : "No handler for type [text] declared on runtime field [numbers_to_string]"
}
Any insight on this would be helpful as well