parent
c298c19177
commit
eb956e7c09
|
@ -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<String, String> entry : settings.getAsMap().entrySet()) {
|
||||
builder.field(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -157,7 +157,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
@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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> values = newArrayList();
|
||||
List<Object> 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);
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue