With the latest updates to the cheddar frame work significant changes have been made to support the use of expressions with document search engines.
Expressions can be used to calculate values at query time and then use those values to further improve your query eg. sort by distance from given location.
To utilise this new function simply construct a "SearchOptions" containing your expression and optional sort ordering and include it in your request to the search engine:
Map<String, String> expr = new HashMap<String, String>();
final SortOrder sortOrder = new SortOrder();
sortOrder.addSortingOption(new SortingOption("distance", Direction.ASCENDING));
options = new SearchOptions().withExpressions(expr).withSortOrder(sortOrder);
searchResponse = documentSearchEngine.search(query, start, size,Document.class, options);
Future enhancements plan to allow the caller to retrieve the results of the expressions along with the search results.