Script_field not return others document fields


(Luiz Zamboni) #1

hi , when i use query this

{ "query": { "match_all": {} }, "script_fields": { "status": { "script_file": "status", "lang": "groovy", "params": {} } } }

and the status.groovy is

String status = null; for(Object c : _source.concurrents){ if(_source.new_price < c.new_price ){ status = 'winning' }else if(_source.new_price > c.new_price ){ status = 'losing' } }; if(status == null){ if(_source.concurrents.size == 0){ status = 'unique' }else{ status = 'equal' } }; return status;

the result is:
`
...
"hits": [
{
"_index": "products",
"_type": "product",
"_id": "4095",
"_score": 1,
"fields": {
"status": [
"equal"
]
}
}

well, i want to recover a indexed document plus, this adicional "status" field, it is possibile ? how ?

`


(system) #2