How to run a DSL query in scripted filed

I am tried to create a scripted filed that return me a number with all the executed queries
I try to execute my query in scripted filed in kibana
help me plz to fix it or something else how to do that

"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": [
{
"geo_distance": {
"distance": "1000km",
"geoLocation": {
"lat": "doc['Latitude'].value",
"lon": "doc['Longitude'].value"
}
}
},
{
"range": {
"map_date": {
"gte": "now-3w/w",
"lte": "now/w"
}
}
}
]
}
}

I can't run it in the DSL console because I don't know how to access the filed values like this: doc['filed'].value
any Suggestions?

Are you trying to create a scripted field with a DSL query? If so that can't be done. You can only use Painless in the scripting box.

Or did you create a scripted field and trying to utilize it in a DSL query? If so then you just use the field name you gave it when you created the field.

in the scripted filed I can access to exist fields value like this: doc['filed'].value
how can I do this In normal DSL ?
I tried for each point in my fields to execute the geo_distance and the range query and count it to a
new field.
any suggestion how to do it? :pray:

Ahh ok.

Short answer is you can't. If you read the scripted fields documentation you can use these in Discover, KQL, and Visualizations.

If you do a normal DSL query you will see the scripted field does not exist.

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