With the latest updates to the cheddar frame work significant changes have been made to support the use of expressions with document search engines.

Cheddar gets expressive

Robin Smith -  12 Dec, 2014

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>();
expr.put("distance", "haversin(53.456,"0.123456",location.latitude,location.longitude)");
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.

Subscribe to this blog

Use of this website and/or subscribing to this blog constitutes acceptance of the travel.cloud Privacy Policy.

Comments