Hello,
I created a script field "attempt complaint" which takes the values >= -78 from another field "Contrainte"
Can anyone tell how I can fixe that?
Hello,
I created a script field "attempt complaint" which takes the values >= -78 from another field "Contrainte"
Can anyone tell how I can fixe that?
Hi @inchirah,
The script is failing because on the first line you have =!
instead of !=
.
Thank for your answer, but I still get the same error
What does Kibana display when you click "Get help with the syntax and preview the results of your script" and then "Preview results". It will show the underlying error there.
Here is the error:
{
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"if (doc['Contrainte'].value != null) { \r\n ",
" ^---- HERE"
],
"script": "if (doc['Contrainte'].value != null) { \r\n if (doc['Contrainte'].value >= -78){\r\n return\"value\";\r\n }\r\n \r\n}\r\nelse { return null }",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "moov_dogbo_2g_test",
"node": "5efdWBMvQiaV5SfQDCpnIw",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"if (doc['Contrainte'].value != null) { \r\n ",
" ^---- HERE"
],
"script": "if (doc['Contrainte'].value != null) { \r\n if (doc['Contrainte'].value >= -78){\r\n return\"value\";\r\n }\r\n \r\n}\r\nelse { return null }",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "No field found for [Contrainte] in mapping with types []"
}
}
}
]
}
It looks like it's complaining about the field Contrainte
not existing (No field found for [Contrainte] in mapping with types []
). What is the mapping for that field?
Sorry I put the wrong error
Here is the error related to that script and here is the mappin of my index
{
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.index.fielddata.ScriptDocValues$Doubles.get(ScriptDocValues.java:249)",
"org.elasticsearch.index.fielddata.ScriptDocValues$Doubles.getValue(ScriptDocValues.java:243)",
"if(doc['Contrainte'].value != null){\n ",
" ^---- HERE"
],
"script": "if(doc['Contrainte'].value != null){\n if (doc['Contrainte'].value >= -78){\n return \"value\"\n }\n}\nelse {return null}",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "couverture_2g",
"node": "4nrIqQuNTuGPNsups5bdzQ",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.index.fielddata.ScriptDocValues$Doubles.get(ScriptDocValues.java:249)",
"org.elasticsearch.index.fielddata.ScriptDocValues$Doubles.getValue(ScriptDocValues.java:243)",
"if(doc['Contrainte'].value != null){\n ",
" ^---- HERE"
],
"script": "if(doc['Contrainte'].value != null){\n if (doc['Contrainte'].value >= -78){\n return \"value\"\n }\n}\nelse {return null}",
"lang": "painless",
"caused_by": {
"type": "illegal_state_exception",
"reason": "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"
}
}
}
]
}
{
"mapping": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Contrainte": {
"type": "float"
},
"Distance": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Latitude": {
"type": "float"
},
"Longitude": {
"type": "float"
},
"Message": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"Time": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"location": {
"type": "float"
},
"message": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"path": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
I really apperciate your help.
Not a problem, I'm seeing A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!
. I believe instead of checking for null
, you can replace the whole if
condition with doc[<field>].size()>0
or a combination of the two.
Unfortunatly your solution didn't work either .
Could you think of something else to help me and I wonder if the word "doc" is a keyword used with all indices.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.