Impossible to use scripts in nested filters?

Hello, everyone.

Currently using ES v1.7, I encounter the following behaviour :

Consider the following document structure, where products is a nested field

id : "string",
products : [
"price" : long,
"quantity" : long
]

I need to write a request that will bring back all documents where the value of my stock is supérior to a thresold, say 5000.

Thus, I write the following filter (using filter cause I don't care about scoring)

"nested" : {
"filter" : {
"script" : {
"script" : "doc['products.price'].values.sum() * doc['products.quantity'].values.sum()>5000"
}
},
"path" : "products"
}

But it does not work.
I really need the filter to be nested to avoid cross-matches .. Is there a proper way to proceed?

Thanks.

It's a tough question. Isn't there anyone that had to solve that roblem before?

Nested fields are separate documents in Lucene. So doc in one invocation of the script is just a single nested doc. There is no way to get access to all the nested docs at once.

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