diff --git a/src/main/java/org/elasticsearch/cluster/ClusterState.java b/src/main/java/org/elasticsearch/cluster/ClusterState.java index ab660cc42c1..3559a769d72 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -209,6 +209,19 @@ public class ClusterState implements ToXContent { return this; } + @Override + public String toString() { + try { + XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint(); + builder.startObject(); + toXContent(builder, EMPTY_PARAMS); + builder.endObject(); + return builder.string(); + } catch (IOException e) { + return "{ \"error\" : \"" + e.getMessage() + "\"}"; + } + } + @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { if (!params.paramAsBoolean("filter_nodes", false)) { @@ -305,7 +318,10 @@ public class ClusterState implements ToXContent { builder.field("state", indexMetaData.state().toString().toLowerCase(Locale.ENGLISH)); builder.startObject("settings"); - Settings settings = settingsFilter.filterSettings(indexMetaData.settings()); + Settings settings = indexMetaData.settings(); + if (settingsFilter != null) { + settings = settingsFilter.filterSettings(indexMetaData.settings()); + } for (Map.Entry entry : settings.getAsMap().entrySet()) { builder.field(entry.getKey(), entry.getValue()); } diff --git a/src/main/java/org/elasticsearch/common/lucene/BytesRefs.java b/src/main/java/org/elasticsearch/common/lucene/BytesRefs.java index 3d57f85dfe0..37473eca1cd 100644 --- a/src/main/java/org/elasticsearch/common/lucene/BytesRefs.java +++ b/src/main/java/org/elasticsearch/common/lucene/BytesRefs.java @@ -25,6 +25,20 @@ import org.apache.lucene.util.BytesRef; */ public class BytesRefs { + /** + * Converts a value to a string, taking special care if its a {@link BytesRef} to call + * {@link org.apache.lucene.util.BytesRef#utf8ToString()}. + */ + public static String toString(Object value) { + if (value == null) { + return null; + } + if (value instanceof BytesRef) { + return ((BytesRef) value).utf8ToString(); + } + return value.toString(); + } + /** * Converts an object value to BytesRef. */ @@ -37,7 +51,7 @@ public class BytesRefs { } return new BytesRef(value.toString()); } - + public static BytesRef toBytesRef(Object value, BytesRef spare) { if (value == null) { return null; diff --git a/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java index 61e39690941..a1a45140baf 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java @@ -157,7 +157,7 @@ public class ByteFieldMapper extends NumberFieldMapper { @Override public BytesRef indexedValueForSearch(Object value) { BytesRef bytesRef = new BytesRef(); - NumericUtils.intToPrefixCoded(parseValue(value), precisionStep(), bytesRef); + NumericUtils.intToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java index 0d2bbc4d471..8234b288222 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java @@ -216,7 +216,7 @@ public class DateFieldMapper extends NumberFieldMapper { @Override public BytesRef indexedValueForSearch(Object value) { BytesRef bytesRef = new BytesRef(); - NumericUtils.longToPrefixCoded(parseValue(value), precisionStep(), bytesRef); + NumericUtils.longToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java index 49e0e60b02d..89d16309969 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java @@ -160,7 +160,7 @@ public class DoubleFieldMapper extends NumberFieldMapper { public BytesRef indexedValueForSearch(Object value) { long longValue = NumericUtils.doubleToSortableLong(parseValue(value)); BytesRef bytesRef = new BytesRef(); - NumericUtils.longToPrefixCoded(longValue, precisionStep(), bytesRef); + NumericUtils.longToPrefixCoded(longValue, 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java index de10210abde..2e1bb92bb98 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java @@ -159,7 +159,7 @@ public class FloatFieldMapper extends NumberFieldMapper { public BytesRef indexedValueForSearch(Object value) { int intValue = NumericUtils.floatToSortableInt(parseValue(value)); BytesRef bytesRef = new BytesRef(); - NumericUtils.intToPrefixCoded(intValue, precisionStep(), bytesRef); + NumericUtils.intToPrefixCoded(intValue, 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java index 12acc577c8f..811996500f0 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java @@ -158,7 +158,7 @@ public class IntegerFieldMapper extends NumberFieldMapper { @Override public BytesRef indexedValueForSearch(Object value) { BytesRef bytesRef = new BytesRef(); - NumericUtils.intToPrefixCoded(parseValue(value), precisionStep(), bytesRef); + NumericUtils.intToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java index 0235f05b8dd..135e12f2c73 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java @@ -159,7 +159,7 @@ public class LongFieldMapper extends NumberFieldMapper { @Override public BytesRef indexedValueForSearch(Object value) { BytesRef bytesRef = new BytesRef(); - NumericUtils.longToPrefixCoded(parseValue(value), precisionStep(), bytesRef); + NumericUtils.longToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java index b5ba9157048..c1fc88be058 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java @@ -159,7 +159,7 @@ public class ShortFieldMapper extends NumberFieldMapper { @Override public BytesRef indexedValueForSearch(Object value) { BytesRef bytesRef = new BytesRef(); - NumericUtils.intToPrefixCoded(parseValue(value), precisionStep(), bytesRef); + NumericUtils.intToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java index e6b50c6a633..1e374c5c61f 100644 --- a/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java @@ -196,7 +196,7 @@ public class IpFieldMapper extends NumberFieldMapper { @Override public BytesRef indexedValueForSearch(Object value) { BytesRef bytesRef = new BytesRef(); - NumericUtils.longToPrefixCoded(parseValue(value), precisionStep(), bytesRef); + NumericUtils.longToPrefixCoded(parseValue(value), 0, bytesRef); // 0 because of exact match return bytesRef; } diff --git a/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java b/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java index ac1c1d8f37e..ee723df538e 100644 --- a/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/TermsQueryParser.java @@ -25,6 +25,7 @@ import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.mapper.FieldMapper; @@ -67,7 +68,7 @@ public class TermsQueryParser implements QueryParser { boolean disableCoord = false; float boost = 1.0f; String minimumShouldMatch = null; - List values = newArrayList(); + List values = newArrayList(); String currentFieldName = null; XContentParser.Token token; @@ -77,7 +78,7 @@ public class TermsQueryParser implements QueryParser { } else if (token == XContentParser.Token.START_ARRAY) { fieldName = currentFieldName; while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { - String value = parser.text(); + Object value = parser.objectBytes(); if (value == null) { throw new QueryParsingException(parseContext.index(), "No value specified for terms query"); } @@ -116,11 +117,11 @@ public class TermsQueryParser implements QueryParser { try { BooleanQuery query = new BooleanQuery(disableCoord); - for (String value : values) { + for (Object value : values) { if (mapper != null) { query.add(new BooleanClause(mapper.termQuery(value, parseContext), BooleanClause.Occur.SHOULD)); } else { - query.add(new TermQuery(new Term(fieldName, value)), BooleanClause.Occur.SHOULD); + query.add(new TermQuery(new Term(fieldName, BytesRefs.toString(value))), BooleanClause.Occur.SHOULD); } } query.setBoost(boost); diff --git a/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java b/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java index f44c44c3ea9..476666fe127 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/query/SimpleQueryTests.java @@ -923,4 +923,133 @@ public class SimpleQueryTests extends AbstractNodesTests { assertThat(searchResponse.getHits().getTotalHits(), equalTo(2l)); assertThat(searchResponse.getHits().hits().length, equalTo(2)); } + + @Test + public void testNumericTermsAndRanges() throws Exception { + client.admin().indices().prepareDelete().execute().actionGet(); + client.admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 1)) + .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") + .startObject("num_byte").field("type", "byte").endObject() + .startObject("num_short").field("type", "short").endObject() + .startObject("num_integer").field("type", "integer").endObject() + .startObject("num_long").field("type", "long").endObject() + .startObject("num_float").field("type", "float").endObject() + .startObject("num_double").field("type", "double").endObject() + .endObject().endObject().endObject()) + .execute().actionGet(); + + client.prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject() + .field("num_byte", 1) + .field("num_short", 1) + .field("num_integer", 1) + .field("num_long", 1) + .field("num_float", 1) + .field("num_double", 1) + .endObject()) + .execute().actionGet(); + + client.prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject() + .field("num_byte", 2) + .field("num_short", 2) + .field("num_integer", 2) + .field("num_long", 2) + .field("num_float", 2) + .field("num_double", 2) + .endObject()) + .execute().actionGet(); + + client.prepareIndex("test", "type1", "17").setSource(jsonBuilder().startObject() + .field("num_byte", 17) + .field("num_short", 17) + .field("num_integer", 17) + .field("num_long", 17) + .field("num_float", 17) + .field("num_double", 17) + .endObject()) + .execute().actionGet(); + + client.admin().indices().prepareRefresh().execute().actionGet(); + + SearchResponse searchResponse; + + logger.info("--> term query on 1"); + searchResponse = client.prepareSearch("test").setQuery(termQuery("num_byte", 1)).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termQuery("num_short", 1)).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termQuery("num_integer", 1)).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termQuery("num_long", 1)).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termQuery("num_float", 1)).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termQuery("num_double", 1)).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + + logger.info("--> terms query on 1"); + searchResponse = client.prepareSearch("test").setQuery(termsQuery("num_byte", new int[]{1})).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termsQuery("num_short", new int[]{1})).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termsQuery("num_integer", new int[]{1})).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termsQuery("num_long", new int[]{1})).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termsQuery("num_float", new double[]{1})).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(termsQuery("num_double", new double[]{1})).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + + logger.info("--> term filter on 1"); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termFilter("num_byte", 1))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termFilter("num_short", 1))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termFilter("num_integer", 1))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termFilter("num_long", 1))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termFilter("num_float", 1))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termFilter("num_double", 1))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + + logger.info("--> terms filter on 1"); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsFilter("num_byte", new int[]{1}))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsFilter("num_short", new int[]{1}))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsFilter("num_integer", new int[]{1}))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsFilter("num_long", new int[]{1}))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsFilter("num_float", new int[]{1}))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + searchResponse = client.prepareSearch("test").setQuery(filteredQuery(matchAllQuery(), termsFilter("num_double", new int[]{1}))).execute().actionGet(); + assertThat(searchResponse.getHits().getTotalHits(), equalTo(1l)); + assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1")); + } } diff --git a/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java index 23b3cbd8e39..79ad9c9ba9f 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/query/SimpleIndexQueryParserTests.java @@ -133,9 +133,9 @@ public class SimpleIndexQueryParserTests { return this.queryParser; } - private BytesRef longToPrefixCoded(long val) { + private BytesRef longToPrefixCoded(long val, int shift) { BytesRef bytesRef = new BytesRef(); - NumericUtils.longToPrefixCoded(val, NumericUtils.PRECISION_STEP_DEFAULT, bytesRef); + NumericUtils.longToPrefixCoded(val, shift, bytesRef); return bytesRef; } @@ -1414,7 +1414,7 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanTermQuery.class)); SpanTermQuery termQuery = (SpanTermQuery) parsedQuery; // since age is automatically registered in data, we encode it as numeric - assertThat(termQuery.getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); + assertThat(termQuery.getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); } @Test @@ -1425,7 +1425,7 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanTermQuery.class)); SpanTermQuery termQuery = (SpanTermQuery) parsedQuery; // since age is automatically registered in data, we encode it as numeric - assertThat(termQuery.getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); + assertThat(termQuery.getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); } @Test @@ -1435,8 +1435,8 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanNotQuery.class)); SpanNotQuery spanNotQuery = (SpanNotQuery) parsedQuery; // since age is automatically registered in data, we encode it as numeric - assertThat(((SpanTermQuery) spanNotQuery.getInclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); + assertThat(((SpanTermQuery) spanNotQuery.getInclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); } @Test @@ -1447,8 +1447,8 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanNotQuery.class)); SpanNotQuery spanNotQuery = (SpanNotQuery) parsedQuery; // since age is automatically registered in data, we encode it as numeric - assertThat(((SpanTermQuery) spanNotQuery.getInclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); + assertThat(((SpanTermQuery) spanNotQuery.getInclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); } @Test @@ -1458,7 +1458,7 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanFirstQuery.class)); SpanFirstQuery spanFirstQuery = (SpanFirstQuery) parsedQuery; // since age is automatically registered in data, we encode it as numeric - assertThat(((SpanTermQuery) spanFirstQuery.getMatch()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); + assertThat(((SpanTermQuery) spanFirstQuery.getMatch()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); assertThat(spanFirstQuery.getEnd(), equalTo(12)); } @@ -1470,7 +1470,7 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanFirstQuery.class)); SpanFirstQuery spanFirstQuery = (SpanFirstQuery) parsedQuery; // since age is automatically registered in data, we encode it as numeric - assertThat(((SpanTermQuery) spanFirstQuery.getMatch()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); + assertThat(((SpanTermQuery) spanFirstQuery.getMatch()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); assertThat(spanFirstQuery.getEnd(), equalTo(12)); } @@ -1481,9 +1481,9 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanNearQuery.class)); SpanNearQuery spanNearQuery = (SpanNearQuery) parsedQuery; assertThat(spanNearQuery.getClauses().length, equalTo(3)); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36)))); + assertThat(((SpanTermQuery) spanNearQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); + assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36, 0)))); assertThat(spanNearQuery.isInOrder(), equalTo(false)); } @@ -1495,9 +1495,9 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanNearQuery.class)); SpanNearQuery spanNearQuery = (SpanNearQuery) parsedQuery; assertThat(spanNearQuery.getClauses().length, equalTo(3)); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36)))); + assertThat(((SpanTermQuery) spanNearQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); + assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36, 0)))); assertThat(spanNearQuery.isInOrder(), equalTo(false)); } @@ -1508,9 +1508,9 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanOrQuery.class)); SpanOrQuery spanOrQuery = (SpanOrQuery) parsedQuery; assertThat(spanOrQuery.getClauses().length, equalTo(3)); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36, 0)))); } @Test @@ -1521,9 +1521,9 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanOrQuery.class)); SpanOrQuery spanOrQuery = (SpanOrQuery) parsedQuery; assertThat(spanOrQuery.getClauses().length, equalTo(3)); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36, 0)))); } @Test @@ -1534,9 +1534,9 @@ public class SimpleIndexQueryParserTests { assertThat(parsedQuery, instanceOf(SpanOrQuery.class)); SpanOrQuery spanOrQuery = (SpanOrQuery) parsedQuery; assertThat(spanOrQuery.getClauses().length, equalTo(3)); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[0]).getTerm(), equalTo(new Term("age", longToPrefixCoded(34, 0)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", longToPrefixCoded(35, 0)))); + assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", longToPrefixCoded(36, 0)))); } @Test