extended date support (month+day) for collection queries
diff --git a/src/main/antlr/CollectionQuery.g4 b/src/main/antlr/CollectionQuery.g4
index 2c6b29b..226e065 100644
--- a/src/main/antlr/CollectionQuery.g4
+++ b/src/main/antlr/CollectionQuery.g4
@@ -22,10 +22,12 @@
OR : '|' | 'OR' | 'or' | 'ODER' | 'oder' ;
QMARK : '?';
SLASH : '/';
+DASH : '-';
WS : ( ' ' | '\t' | '\r' | '\n' )+ -> skip ;
fragment NO_RE : ~[ \t\/];
fragment ALPHABET : ~('\t' | ' ' | '/' | '*' | '?' | '+' | '{' | '}' | '[' | ']'
| '(' | ')' | '|' | '"' | ',' | ':' | '\'' | '\\' | '!' | '=' | '~' | '&' | '^' | '<' | '>' );
+DIGIT : [0-9];
NUMBER : [0-9]+;
NL : [\r\n] -> skip;
@@ -54,7 +56,11 @@
*/
regex
-: REGEX
+: REGEX
+;
+
+date
+: DIGIT DIGIT DIGIT DIGIT (DASH DIGIT DIGIT (DASH DIGIT DIGIT)?)?
;
conj
@@ -69,17 +75,19 @@
;
field
-: WORD
+: WORD
;
value
: WORD
| NUMBER
+| date
| '"' (WORD ws*)+'"'
| regex
;
+
relation
: (expr|exprGroup) conj (expr|exprGroup|relation)
//| LRB relation RRB
diff --git a/src/test/java/CollectionQueryTreeTest.java b/src/test/java/CollectionQueryTreeTest.java
index a367c26..aef9d49 100644
--- a/src/test/java/CollectionQueryTreeTest.java
+++ b/src/test/java/CollectionQueryTreeTest.java
@@ -215,6 +215,26 @@
cqt.process(query);
map = cqt.getRequestMap().toString();
assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "pubDate>=1990-05";
+ expected =
+ "{@type=korap:filter, filter=" +
+ "{@type=korap:doc, key=pubDate, value=1990-05, match=match:geq}" +
+ "}";
+ cqt = new CollectionQueryTree();
+ cqt.process(query);
+ map = cqt.getRequestMap().toString();
+ assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
+
+ query = "pubDate>=1990-05-01";
+ expected =
+ "{@type=korap:filter, filter=" +
+ "{@type=korap:doc, key=pubDate, value=1990-05-01, match=match:geq}" +
+ "}";
+ cqt = new CollectionQueryTree();
+ cqt.process(query);
+ map = cqt.getRequestMap().toString();
+ assertEquals(expected.replaceAll(" ", ""), map.replaceAll(" ", ""));
}
@Test