Function_score with nested query - syntax building


#1

Hi,

I want to add custom scoring to an already existing query but I'm struggling to generate correct syntax. Would someone be able to advice?

If my base query is:

{
"query": {
"bool": {
"must": [
{
"bool": {
"should": []
}
},
{
"range": {
"createdAt": {
"gte": "0",
"lte": "now"
}
}
},
{
"nested": {
"path": "dates",
"query": {
"bool": {
"must": [
{
"range": {
"dates.start": {
"lte": "2018-03-03T23:59:59Z"
}
}
},
{
"range": {
"dates.end": {
"gte": "2018-03-03T00:00:00Z"
}
}
}
]
}
}
}
}
],
"filter": {
"exists": {
"field": "groupingId"
}
}
}
}
}

And function score is to be calculated using fields from the nested query (dates.start and dates.end) then where would syntax for function score need to go to make the overall syntax a valid one?

P.S. There obviously are examples in ES docs, but I find them very simplistic. Is there anywhere with examples of more complicated queries so that they can be followed to build your own?


(system) #2

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