Solr & Lucene at Etsy provides concise summaries of Gregg Donovan's experience using Solr and Lucene at Etsy and TheLadders, including optimizations made to maximize performance out of the box, techniques for low-level hacking, and when each approach is best applied. Key points covered are maximizing Solr functionality, continuous deployment, cheap performance wins, and tools for low-level hacking.
77. MoneyFieldType.java:
@Override
public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2,
final boolean minInclusive, final boolean maxInclusive) {
final MoneyValue p1 = MoneyValue.parse(part1, defaultCurrency);
final MoneyValue p2 = MoneyValue.parse(part2, defaultCurrency);
if (!p1.getCurrencyCode().equals(p2.getCurrencyCode())) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
new ParseException("Cannot parse range query " + part1 + " to " + part2 +
": range queries only supported when upper and lower bound have same
currency."));
}
String currencyCode = p1.getCurrencyCode();
final MoneyValueSource vs = new MoneyValueSource(field, currencyCode, parser);
return new SolrConstantScoreQuery(new ValueSourceRangeFilter(vs,
p1.getAmount() + "", p2.getAmount() + "", minInclusive, maxInclusive));
}