Skip to content

Commit 11492b8

Browse files
committed
Tests: fix RangeQueryBuilderTest, only use timestamp when date mapper is available
Also renaming field names to 'mapped_<fieldtype>' to avoid misunderstandings in error messages.
1 parent 5cdb1e6 commit 11492b8

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

core/src/test/java/org/elasticsearch/index/query/BaseQueryTestCase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@
7676
@Ignore
7777
public abstract class BaseQueryTestCase<QB extends QueryBuilder<QB>> extends ElasticsearchTestCase {
7878

79-
protected static final String OBJECT_FIELD_NAME = "object";
80-
protected static final String DATE_FIELD_NAME = "age";
81-
protected static final String INT_FIELD_NAME = "price";
82-
protected static final String STRING_FIELD_NAME = "text";
83-
protected static final String DOUBLE_FIELD_NAME = "double";
84-
protected static final String BOOLEAN_FIELD_NAME = "boolean";
79+
protected static final String OBJECT_FIELD_NAME = "mapped_object";
80+
protected static final String DATE_FIELD_NAME = "mapped_date";
81+
protected static final String INT_FIELD_NAME = "mapped_int";
82+
protected static final String STRING_FIELD_NAME = "mapped_string";
83+
protected static final String DOUBLE_FIELD_NAME = "mapped_double";
84+
protected static final String BOOLEAN_FIELD_NAME = "mapped_boolean";
8585
protected static final String[] mappedFieldNames = new String[] { DATE_FIELD_NAME, INT_FIELD_NAME, STRING_FIELD_NAME,
8686
DOUBLE_FIELD_NAME, BOOLEAN_FIELD_NAME, OBJECT_FIELD_NAME };
8787

core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ protected RangeQueryBuilder createTestQueryBuilder() {
6363
query = new RangeQueryBuilder(DATE_FIELD_NAME);
6464
query.from(new DateTime(System.currentTimeMillis() - randomIntBetween(0, 1000000)).toString());
6565
query.to(new DateTime(System.currentTimeMillis() + randomIntBetween(0, 1000000)).toString());
66-
// Use timestamp option then we have a date mapper, otherwise we would trigger exception.
67-
// There is a separate test for that.
68-
if (createContext().fieldMapper(DATE_FIELD_NAME) != null) {
66+
// Create timestamp option only then we have a date mapper, otherwise we could trigger exception.
67+
if (createContext().mapperService().smartNameFieldType(DATE_FIELD_NAME) != null) {
6968
if (randomBoolean()) {
7069
query.timeZone(TIMEZONE_IDS.get(randomIntBetween(0, TIMEZONE_IDS.size() - 1)));
7170
}

0 commit comments

Comments
 (0)