Find Healthy Foods by Nutrient Ratios
The new entity class query operators like FilteredEntityClass, SortedEntityClass and ExtendedEntityClass symbolically represent queries, they do not evaluate on their own. They can be nested to form complicated queries. Only when asked for the value of a property (EntityValue) or the list of entities (EntityList) is the query finally evaluated.
Now find the refried beans with the highest protein-to-fat ratio. Start with an implicitly defined EntityClass of the type "Food".
Add a property that computes the protein-to-fat ratio.
Filter by entities for which the protein-to-fat ratio is a number.
Finally, sort by the new property in decreasing order and take the first (that is, the largest) 10.
Now you can extract the protein-to-fat ratio and format the result as an Association.