Query to get all records until the sum of column less than or equal a value

HI,

Is there any way to find ids of document for which sum of field "salary" reach 10000?
I just want to fetch ids for which the total of salary is just less than or equal to 10000?

something like - https://stackoverflow.com/questions/21824383/query-to-get-all-records-until-the-sum-of-column-less-than-or-equal-a-value

Thank you in advance.

Can anyone get a time to look into this problem?

Read this and specifically the "Also be patient" part.

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

1 Like

@dadoonet I understood. Thanks.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

So provide an example dataset we can play from.

I want to get all the records in a table until the sum of a particular column is less than or equal to 'n'.

For SQL example:

Table: data

slno item price

1 item1 1000
2 item2 2000
3 item3 3000
4 item4 4000
5 item5 5000
6 item6 6000

I want to get all records from above table until the sum(price) is less than or equal to 10000

So, with the above table my result would be first 4 records.

As they are different documents, I don't see how you can do that.
I believe you need to do it on the client side, do the sum manually and if you don't have enough records, ask for a new page of records...

No idea on my end.

Ok.
Thank you for your time !!!

same thing is possible in SQL. So, i think ElasticSearch should support.

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