Skip to content

Commit

Permalink
Support range queries for publication date facet search (see #8)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Jan 26, 2017
1 parent d71b7aa commit a006a20
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/resources/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ public static String buildQueryString(String q, String... values) {
String fieldValue = values[i];
String fieldName = fieldValue.contains("http")
? FIELDS[i].replace(".label", ".id") : FIELDS[i];
if (fieldName.toLowerCase().endsWith("date")
&& fieldValue.matches("\\d{1,4}-\\d{1,4}")) {
String[] fromTo = fieldValue.split("-");
fieldValue = String.format("[%s TO %s]", fromTo[0], fromTo[1]);
}
if (!fieldValue.isEmpty()) {
String complexQ = " AND (";
for (String v : fieldValue.replace(",AND", "").split(",")) {
Expand Down

0 comments on commit a006a20

Please sign in to comment.