We work for a real estate company that has its own website and database of properties listed for sale. For each property, we have some common fields (eg. id, title, rooms, square meters of space) that are present for all properties, and some fields that don't appear for all (eg. heat system, septic tank, etc).
For our first task, we receive a common filter, which is a JSON of fields that we need to match exactly, returning only their ids.
Ok, these filters are pretty inflexible, and people are very unlikely to filter things that precisely (who wants to see houses built in 2003 exactly?).
For the next part, we need to extend the filters to get an extra "modifier": for string typed fields, if we filter by "fieldname__contains", we should return these entries that has the specified string as part of the target field (eg. "name__contains": "ideal" should match "ideal house" and "ideal flat"). For strings that are numbers, we should handle the "__gte" and "__lte" suffixes, meaning lower than equal and greater than equal.
Ignore the booleans and the "area" field for now. If any of those ignored fields are passed, we should just match them exactly. The "old style" filtering should still work (with the exact attribute matches).

Now that we are able to filter entries based on ranges, we need to do some aggregates. Besides the usuallistings and filters, we need to also be able to receive an object aggregate, which will have a single property and a single value.
Possible values:
  • average: [the name of some numeric field] - when passed, we need to only return the average value of the specified field (eg. for average: price we will return the average price for the filtered entries.
  • max: [the name of some numeric field] - the maximum value
  • min: [the name of some numeric field] - the minimum value
  • median: [the name of some numeric field] - the median value of the values
  • total_characters: [the name of some string field] - the total character count

You can generate new examples on demand, to test with your code. The examples are generated randomly. Change the part you want to generate examples for, and a new example will be generated and displayed below.