Hello, new to elastic here.
I am trying to run this:
GET /test/_search
{
"query": {
"match": {
"doc_type": "test"
}
},
"sort": {
"_script" : {
"type" : "number",
"script" : {
"lang": "painless",
"source": "doc['price'].value + doc['price'].value"
},
"order" : "desc"
}
}
}
and I am getting this:
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:65)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:27)",
"doc['price'].value + doc['price'].value",
" ^---- HERE"
],
"script" : "doc['price'].value + doc['price'].value",
"lang" : "painless",
"position" : {
"offset" : 4,
"start" : 0,
"end" : 39
},
"caused_by" : {
"type" : "illegal_argument_exception",
"reason" : "No field found for [price] in mapping"
}
this is part of the mapping (from _mapping request)
{
"test": {
"mappings": {
"properties": {
"doc": {
"properties": {
"itemId": {
"type": "long"
},
"price": {
"type": "float"
}
},
"doc_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
My mapping seems correct, for what I am trying to do.
I have searched the internet and this forum for an answer, with no luck.
I am sorry if what I am trying may seem useless, but it's only a learning test.
I am using version 7.12
Thanks in advanced