Permalink
Browse files

Allow dash in field name (but not at start). (Closes #154)

  • Loading branch information...
1 parent 8cb75b7 commit 3f203786257eb385b07601a0b9180148872c8bcb Robert Newson committed Mar 7, 2012
@@ -26,7 +26,7 @@
public final class TypedField {
- private static Pattern PATTERN = Pattern.compile("^([\\w_.]+)(<([\\w]+)>)?$");
+ private static Pattern PATTERN = Pattern.compile("^(\\w[\\w_.-]*)(<([\\w]+)>)?$");
private final String name;
@@ -7,6 +7,7 @@
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
import org.junit.Before;
import org.junit.Test;
@@ -70,6 +71,12 @@ public void dateTimeTimeZoneRangeQuery() throws Exception {
assertRange(q, Long.class, time("2000-01-01T00:00:00-0100"), time("2010-02-04T00:00:00-0100"));
}
+ @Test
+ public void fieldNameWithDashes() throws Exception {
+ final Query q = parser.parse("foo-bar:baz");
+ assertThat(q, is(TermQuery.class));
+ }
+
private long time(final String str) throws ParseException {
return FieldType.toDate(str);
}

0 comments on commit 3f20378

Please sign in to comment.