spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.9k stars 1.33k forks source link

Scipted query #2968

Open p-migda opened 4 weeks ago

p-migda commented 4 weeks ago

Hi, Is there any possible way to make something like this using criteria query without runtime or scripted field?

GET index/_search { "query": { "bool": { "must": [ { "nested": { "path": "date", "query": { "bool": { "filter": { "script": { "script": """ ZonedDateTime date = doc['date.date'].value; ZonedDateTime now = params['now']; return date.isBefore(now) """ } } } } } }, { "bool": { "must": [ { "match": { "fieldName": "value" } } ] } } ] } } }

I'm thinking about method something like that criteria.addScriptedQuery(String script, HashMap<String, Object> params); Do you think it is possible to make something like this or maybe it is possible already?

edit: Or run stored script on es in query?

sothawo commented 3 weeks ago

Currently this is not possible. This will need some investigation of how it might be integrated int the critera API