- Modified RangeQuery's toString() method to return a String that matches the syntax used in QueryParser.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149979 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2003-04-29 01:34:00 +00:00
parent bad5b34e31
commit f2099419e3
2 changed files with 12 additions and 12 deletions

View File

@ -156,7 +156,7 @@ public class RangeQuery extends Query
} }
buffer.append(inclusive ? "[" : "{"); buffer.append(inclusive ? "[" : "{");
buffer.append(lowerTerm != null ? lowerTerm.text() : "null"); buffer.append(lowerTerm != null ? lowerTerm.text() : "null");
buffer.append("-"); buffer.append(" TO ");
buffer.append(upperTerm != null ? upperTerm.text() : "null"); buffer.append(upperTerm != null ? upperTerm.text() : "null");
buffer.append(inclusive ? "]" : "}"); buffer.append(inclusive ? "]" : "}");
if (getBoost() != 1.0f) if (getBoost() != 1.0f)

View File

@ -305,16 +305,16 @@ public class TestQueryParser extends TestCase {
} }
public void testRange() throws Exception { public void testRange() throws Exception {
assertQueryEquals("[ a TO z]", null, "[a-z]"); assertQueryEquals("[ a TO z]", null, "[a TO z]");
assertTrue(getQuery("[ a TO z]", null) instanceof RangeQuery); assertTrue(getQuery("[ a TO z]", null) instanceof RangeQuery);
assertQueryEquals("[ a TO z ]", null, "[a-z]"); assertQueryEquals("[ a TO z ]", null, "[a TO z]");
assertQueryEquals("{ a TO z}", null, "{a-z}"); assertQueryEquals("{ a TO z}", null, "{a TO z}");
assertQueryEquals("{ a TO z }", null, "{a-z}"); assertQueryEquals("{ a TO z }", null, "{a TO z}");
assertQueryEquals("{ a TO z }^2.0", null, "{a-z}^2.0"); assertQueryEquals("{ a TO z }^2.0", null, "{a TO z}^2.0");
assertQueryEquals("[ a TO z] OR bar", null, "[a-z] bar"); assertQueryEquals("[ a TO z] OR bar", null, "[a TO z] bar");
assertQueryEquals("[ a TO z] AND bar", null, "+[a-z] +bar"); assertQueryEquals("[ a TO z] AND bar", null, "+[a TO z] +bar");
assertQueryEquals("( bar blar { a TO z}) ", null, "bar blar {a-z}"); assertQueryEquals("( bar blar { a TO z}) ", null, "bar blar {a TO z}");
assertQueryEquals("gack ( bar blar { a TO z}) ", null, "gack (bar blar {a-z})"); assertQueryEquals("gack ( bar blar { a TO z}) ", null, "gack (bar blar {a TO z})");
} }
public String getDate(String s) throws Exception { public String getDate(String s) throws Exception {
@ -333,9 +333,9 @@ public class TestQueryParser extends TestCase {
String startDate = getLocalizedDate(2002, 1, 1); String startDate = getLocalizedDate(2002, 1, 1);
String endDate = getLocalizedDate(2002, 1, 4); String endDate = getLocalizedDate(2002, 1, 4);
assertQueryEquals("[ " + startDate + " TO " + endDate + "]", null, assertQueryEquals("[ " + startDate + " TO " + endDate + "]", null,
"[" + getDate(startDate) + "-" + getDate(endDate) + "]"); "[" + getDate(startDate) + " TO " + getDate(endDate) + "]");
assertQueryEquals("{ " + startDate + " " + endDate + " }", null, assertQueryEquals("{ " + startDate + " " + endDate + " }", null,
"{" + getDate(startDate) + "-" + getDate(endDate) + "}"); "{" + getDate(startDate) + " TO " + getDate(endDate) + "}");
} }
public void testEscaped() throws Exception { public void testEscaped() throws Exception {