How can create script field by using SQL or DSL instead of painless?

hi everyone, as i know Es support create script field, running_time filed while query by using painless. But can I create an script field like that by using SQL ?
Example: select case when col1 = 1 then 2 else 0 end as col 2
above, when I use query by SQL of ES it will create for me a col 2, but now I just want to call col 2 instead of create a computation for it.
-> select col 2
how can I do that ?
thanks and best regards

1 Like

You can not. You need to use Painless.

2 Likes

I into, elastic website. First writing on. I feel, SQL and DSL. Database using on, Elasticsearch, module. Thank you, discussion.

thanks for your answer. i have one more question, is there any tool convert from SQL to painless ?
EX: case when field1 = 'a' then 'b' else 'c' end.
-> painless: if (doc['field'] == 'a') { emit('b')} else {emit('c')}

Thanks and best regards.

No, there is not.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.