diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java index 33e1730ddb9..36b8a414882 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/all/SimpleAllMapperTests.java @@ -50,7 +50,7 @@ public class SimpleAllMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - AllField field = (AllField) doc.getFieldable("_all"); + AllField field = (AllField) doc.getField("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); assertThat(allEntries.fields().size(), equalTo(3)); assertThat(allEntries.fields().contains("address.last.location"), equalTo(true)); @@ -66,7 +66,7 @@ public class SimpleAllMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - AllField field = (AllField) doc.getFieldable("_all"); + AllField field = (AllField) doc.getField("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); assertThat(allEntries.fields().size(), equalTo(3)); assertThat(allEntries.fields().contains("address.last.location"), equalTo(true)); @@ -82,7 +82,7 @@ public class SimpleAllMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - AllField field = (AllField) doc.getFieldable("_all"); + AllField field = (AllField) doc.getField("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); assertThat(allEntries.fields().size(), equalTo(3)); assertThat(allEntries.fields().contains("address.last.location"), equalTo(true)); @@ -105,7 +105,7 @@ public class SimpleAllMapperTests { byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = builtDocMapper.parse(new BytesArray(json)).rootDoc(); - AllField field = (AllField) doc.getFieldable("_all"); + AllField field = (AllField) doc.getField("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); assertThat(allEntries.fields().size(), equalTo(3)); assertThat(allEntries.fields().contains("address.last.location"), equalTo(true)); @@ -119,7 +119,7 @@ public class SimpleAllMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - AllField field = (AllField) doc.getFieldable("_all"); + AllField field = (AllField) doc.getField("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); assertThat(allEntries.fields().size(), equalTo(2)); assertThat(allEntries.fields().contains("name.last"), equalTo(true)); @@ -140,7 +140,7 @@ public class SimpleAllMapperTests { byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/all/test1.json"); Document doc = builtDocMapper.parse(new BytesArray(json)).rootDoc(); - AllField field = (AllField) doc.getFieldable("_all"); + AllField field = (AllField) doc.getField("_all"); AllEntries allEntries = ((AllTokenStream) field.tokenStreamValue()).allEntries(); assertThat(allEntries.fields().size(), equalTo(2)); assertThat(allEntries.fields().contains("name.last"), equalTo(true)); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java index f9cf7687e00..072e612bdcc 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/compound/CompoundTypesTests.java @@ -49,7 +49,7 @@ public class CompoundTypesTests { .bytes()); assertThat(doc.rootDoc().get("field1"), equalTo("value1")); - assertThat((double) doc.rootDoc().getFieldable("field1").getBoost(), closeTo(1.0d, 0.000001d)); + assertThat((double) doc.rootDoc().getField("field1").boost(), closeTo(1.0d, 0.000001d)); assertThat(doc.rootDoc().get("field2"), equalTo("value2")); doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder() @@ -59,7 +59,7 @@ public class CompoundTypesTests { .bytes()); assertThat(doc.rootDoc().get("field1"), equalTo("value1")); - assertThat((double) doc.rootDoc().getFieldable("field1").getBoost(), closeTo(2.0d, 0.000001d)); + assertThat((double) doc.rootDoc().getField("field1").boost(), closeTo(2.0d, 0.000001d)); assertThat(doc.rootDoc().get("field2"), equalTo("value2")); doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder() @@ -69,7 +69,7 @@ public class CompoundTypesTests { .bytes()); assertThat(doc.rootDoc().get("field1"), equalTo("value1")); - assertThat((double) doc.rootDoc().getFieldable("field1").getBoost(), closeTo(1.0d, 0.000001d)); + assertThat((double) doc.rootDoc().getField("field1").boost(), closeTo(1.0d, 0.000001d)); assertThat(doc.rootDoc().get("field2"), equalTo("value2")); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java index 0ec0c025db7..4da6a1c0847 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/date/SimpleDateMappingTests.java @@ -78,7 +78,7 @@ public class SimpleDateMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("date_field").tokenStreamValue(), notNullValue()); + assertThat(doc.rootDoc().getField("date_field").tokenStream(defaultMapper.indexAnalyzer()), notNullValue()); } @Test @@ -119,8 +119,8 @@ public class SimpleDateMappingTests { .field("field2", "2010-01-01") .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field1"), nullValue()); - assertThat(doc.rootDoc().getFieldable("field2"), notNullValue()); + assertThat(doc.rootDoc().getField("field1"), nullValue()); + assertThat(doc.rootDoc().getField("field2"), notNullValue()); try { defaultMapper.parse("type", "1", XContentFactory.jsonBuilder() @@ -151,7 +151,7 @@ public class SimpleDateMappingTests { .field("field3", "a") .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field3"), nullValue()); + assertThat(doc.rootDoc().getField("field3"), nullValue()); // This should still throw an exception, since field2 is specifically set to ignore_malformed=false try { diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java index f115c161bec..cdfbfa9502f 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/GenericStoreDynamicTemplateTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.test.unit.index.mapper.dynamictemplate.genericstore; import org.apache.lucene.document.Document; -import org.apache.lucene.document.Fieldable; +import org.apache.lucene.index.IndexableField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMappers; @@ -44,18 +44,18 @@ public class GenericStoreDynamicTemplateTests { byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/genericstore/test-data.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(true)); FieldMappers fieldMappers = docMapper.mappers().fullName("name"); assertThat(fieldMappers.mappers().size(), equalTo(1)); assertThat(fieldMappers.mapper().stored(), equalTo(true)); - f = doc.getFieldable("age"); + f = doc.getField("age"); assertThat(f.name(), equalTo("age")); - assertThat(f.isStored(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(true)); fieldMappers = docMapper.mappers().fullName("age"); assertThat(fieldMappers.mappers().size(), equalTo(1)); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java index b4583809ec2..72574f87f3d 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/PathMatchDynamicTemplateTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.test.unit.index.mapper.dynamictemplate.pathmatch; import org.apache.lucene.document.Document; -import org.apache.lucene.document.Fieldable; +import org.apache.lucene.index.IndexableField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.index.field.data.strings.StringFieldDataType; import org.elasticsearch.index.mapper.DocumentMapper; @@ -46,26 +46,26 @@ public class PathMatchDynamicTemplateTests { byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/pathmatch/test-data.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); assertThat(f.stringValue(), equalTo("top_level")); - assertThat(f.isStored(), equalTo(false)); + assertThat(f.fieldType().stored(), equalTo(false)); FieldMappers fieldMappers = docMapper.mappers().fullName("name"); assertThat(fieldMappers.mappers().size(), equalTo(1)); assertThat(fieldMappers.mapper().stored(), equalTo(false)); - f = doc.getFieldable("obj1.name"); + f = doc.getField("obj1.name"); assertThat(f.name(), equalTo("obj1.name")); - assertThat(f.isStored(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(true)); fieldMappers = docMapper.mappers().fullName("obj1.name"); assertThat(fieldMappers.mappers().size(), equalTo(1)); assertThat(fieldMappers.mapper().stored(), equalTo(true)); - f = doc.getFieldable("obj1.obj2.name"); + f = doc.getField("obj1.obj2.name"); assertThat(f.name(), equalTo("obj1.obj2.name")); - assertThat(f.isStored(), equalTo(false)); + assertThat(f.fieldType().stored(), equalTo(false)); fieldMappers = docMapper.mappers().fullName("obj1.obj2.name"); assertThat(fieldMappers.mappers().size(), equalTo(1)); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java index d9a0f63e718..b360b905d47 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/SimpleDynamicTemplatesTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.test.unit.index.mapper.dynamictemplate.simple; import org.apache.lucene.document.Document; -import org.apache.lucene.document.Fieldable; +import org.apache.lucene.index.IndexableField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMappers; @@ -44,47 +44,47 @@ public class SimpleDynamicTemplatesTests { byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(false)); FieldMappers fieldMappers = docMapper.mappers().fullName("name"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi1"); + f = doc.getField("multi1"); assertThat(f.name(), equalTo("multi1")); assertThat(f.stringValue(), equalTo("multi 1")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(true)); fieldMappers = docMapper.mappers().fullName("multi1"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi1.org"); + f = doc.getField("multi1.org"); assertThat(f.name(), equalTo("multi1.org")); assertThat(f.stringValue(), equalTo("multi 1")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(false)); fieldMappers = docMapper.mappers().fullName("multi1.org"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi2"); + f = doc.getField("multi2"); assertThat(f.name(), equalTo("multi2")); assertThat(f.stringValue(), equalTo("multi 2")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(true)); fieldMappers = docMapper.mappers().fullName("multi2"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi2.org"); + f = doc.getField("multi2.org"); assertThat(f.name(), equalTo("multi2.org")); assertThat(f.stringValue(), equalTo("multi 2")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(false)); fieldMappers = docMapper.mappers().fullName("multi2.org"); assertThat(fieldMappers.mappers().size(), equalTo(1)); @@ -100,47 +100,47 @@ public class SimpleDynamicTemplatesTests { byte[] json = copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/dynamictemplate/simple/test-data.json"); Document doc = docMapper.parse(new BytesArray(json)).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(false)); FieldMappers fieldMappers = docMapper.mappers().fullName("name"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi1"); + f = doc.getField("multi1"); assertThat(f.name(), equalTo("multi1")); assertThat(f.stringValue(), equalTo("multi 1")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(true)); fieldMappers = docMapper.mappers().fullName("multi1"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi1.org"); + f = doc.getField("multi1.org"); assertThat(f.name(), equalTo("multi1.org")); assertThat(f.stringValue(), equalTo("multi 1")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(false)); fieldMappers = docMapper.mappers().fullName("multi1.org"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi2"); + f = doc.getField("multi2"); assertThat(f.name(), equalTo("multi2")); assertThat(f.stringValue(), equalTo("multi 2")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(true)); fieldMappers = docMapper.mappers().fullName("multi2"); assertThat(fieldMappers.mappers().size(), equalTo(1)); - f = doc.getFieldable("multi2.org"); + f = doc.getField("multi2.org"); assertThat(f.name(), equalTo("multi2.org")); assertThat(f.stringValue(), equalTo("multi 2")); - assertThat(f.isIndexed(), equalTo(true)); - assertThat(f.isTokenized(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); + assertThat(f.fieldType().tokenized(), equalTo(false)); fieldMappers = docMapper.mappers().fullName("multi2.org"); assertThat(fieldMappers.mappers().size(), equalTo(1)); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/GeohashMappingGeoPointTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/GeohashMappingGeoPointTests.java index 64feebec0b1..cde370494ee 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/GeohashMappingGeoPointTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/GeohashMappingGeoPointTests.java @@ -48,8 +48,8 @@ public class GeohashMappingGeoPointTests { .endObject() .bytes()); - MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lat"), nullValue()); - MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lon"), nullValue()); + MatcherAssert.assertThat(doc.rootDoc().getField("point.lat"), nullValue()); + MatcherAssert.assertThat(doc.rootDoc().getField("point.lon"), nullValue()); MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -67,8 +67,8 @@ public class GeohashMappingGeoPointTests { .endObject() .bytes()); - MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lat"), nullValue()); - MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lon"), nullValue()); + MatcherAssert.assertThat(doc.rootDoc().getField("point.lat"), nullValue()); + MatcherAssert.assertThat(doc.rootDoc().getField("point.lon"), nullValue()); MatcherAssert.assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -86,8 +86,8 @@ public class GeohashMappingGeoPointTests { .endObject() .bytes()); - MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lat"), nullValue()); - MatcherAssert.assertThat(doc.rootDoc().getFieldable("point.lon"), nullValue()); + MatcherAssert.assertThat(doc.rootDoc().getField("point.lat"), nullValue()); + MatcherAssert.assertThat(doc.rootDoc().getField("point.lon"), nullValue()); MatcherAssert.assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3))); MatcherAssert.assertThat(doc.rootDoc().get("point"), notNullValue()); } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonAndGeohashMappingGeoPointTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonAndGeohashMappingGeoPointTests.java index 66418c25780..84fd2a3605b 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonAndGeohashMappingGeoPointTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonAndGeohashMappingGeoPointTests.java @@ -49,8 +49,8 @@ public class LatLonAndGeohashMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3))); } @@ -68,8 +68,8 @@ public class LatLonAndGeohashMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3))); } @@ -87,8 +87,8 @@ public class LatLonAndGeohashMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); assertThat(doc.rootDoc().get("point.geohash"), equalTo(GeoHashUtils.encode(1.2, 1.3))); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonMappingGeoPointTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonMappingGeoPointTests.java index 0e926803326..17ea9f5eb21 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonMappingGeoPointTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/geo/LatLonMappingGeoPointTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.test.unit.index.mapper.geo; +import org.apache.lucene.util.BytesRef; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.common.Numbers; import org.elasticsearch.common.xcontent.XContentFactory; @@ -185,11 +186,11 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), nullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), nullValue()); - assertThat(doc.rootDoc().getFieldable("point.geohash"), nullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat").binaryValue(), nullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon").binaryValue(), nullValue()); + assertThat(doc.rootDoc().getField("point.geohash"), nullValue()); assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -207,11 +208,11 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2))); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3))); - assertThat(doc.rootDoc().getFieldable("point.geohash"), nullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getField("point.lat").binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.2))); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getField("point.lon").binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.3))); + assertThat(doc.rootDoc().getField("point.geohash"), nullValue()); assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -232,14 +233,14 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldables("point.lat").length, equalTo(2)); - assertThat(doc.rootDoc().getFieldables("point.lon").length, equalTo(2)); - assertThat(doc.rootDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2))); - assertThat(doc.rootDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3))); - assertThat(doc.rootDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3")); - assertThat(doc.rootDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4))); - assertThat(doc.rootDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5))); - assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5")); + assertThat(doc.rootDoc().getFields("point.lat").length, equalTo(2)); + assertThat(doc.rootDoc().getFields("point.lon").length, equalTo(2)); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lat")[0].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.2))); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lon")[0].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.3))); + assertThat(doc.rootDoc().getFields("point")[0].stringValue(), equalTo("1.2,1.3")); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lat")[1].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.4))); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lon")[1].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.5))); + assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5")); } @Test @@ -256,8 +257,8 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -275,10 +276,10 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2))); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3))); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getField("point.lat").binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.2))); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getField("point.lon").binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.3))); assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -299,14 +300,14 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldables("point.lat").length, equalTo(2)); - assertThat(doc.rootDoc().getFieldables("point.lon").length, equalTo(2)); - assertThat(doc.rootDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2))); - assertThat(doc.rootDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3))); - assertThat(doc.rootDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3")); - assertThat(doc.rootDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4))); - assertThat(doc.rootDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5))); - assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5")); + assertThat(doc.rootDoc().getFields("point.lat").length, equalTo(2)); + assertThat(doc.rootDoc().getFields("point.lon").length, equalTo(2)); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lat")[0].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.2))); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lon")[0].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.3))); + assertThat(doc.rootDoc().getFields("point")[0].stringValue(), equalTo("1.2,1.3")); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lat")[1].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.4))); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lon")[1].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.5))); + assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5")); } @Test @@ -323,8 +324,8 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); assertThat(doc.rootDoc().get("point"), notNullValue()); } @@ -342,10 +343,10 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), nullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), nullValue()); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lat").binaryValue(), nullValue()); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); + assertThat(doc.rootDoc().getField("point.lon").binaryValue(), nullValue()); assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -363,10 +364,10 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("point.lat"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lat").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2))); - assertThat(doc.rootDoc().getFieldable("point.lon"), notNullValue()); - assertThat(doc.rootDoc().getFieldable("point.lon").getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3))); + assertThat(doc.rootDoc().getField("point.lat"), notNullValue()); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getField("point.lat").binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.2))); + assertThat(doc.rootDoc().getField("point.lon"), notNullValue()); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getField("point.lon").binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.3))); assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3")); } @@ -387,13 +388,13 @@ public class LatLonMappingGeoPointTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldables("point.lat").length, equalTo(2)); - assertThat(doc.rootDoc().getFieldables("point.lon").length, equalTo(2)); - assertThat(doc.rootDoc().getFieldables("point.lat")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.2))); - assertThat(doc.rootDoc().getFieldables("point.lon")[0].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.3))); - assertThat(doc.rootDoc().getFieldables("point")[0].stringValue(), equalTo("1.2,1.3")); - assertThat(doc.rootDoc().getFieldables("point.lat")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.4))); - assertThat(doc.rootDoc().getFieldables("point.lon")[1].getBinaryValue(), equalTo(Numbers.doubleToBytes(1.5))); - assertThat(doc.rootDoc().getFieldables("point")[1].stringValue(), equalTo("1.4,1.5")); + assertThat(doc.rootDoc().getFields("point.lat").length, equalTo(2)); + assertThat(doc.rootDoc().getFields("point.lon").length, equalTo(2)); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lat")[0].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.2))); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lon")[0].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.3))); + assertThat(doc.rootDoc().getFields("point")[0].stringValue(), equalTo("1.2,1.3")); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lat")[1].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.4))); + assertThat(BytesRef.deepCopyOf(doc.rootDoc().getFields("point.lon")[1].binaryValue()).bytes, equalTo(Numbers.doubleToBytes(1.5))); + assertThat(doc.rootDoc().getFields("point")[1].stringValue(), equalTo("1.4,1.5")); } } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java index 73b16756bf6..2a6a79804df 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/index/IndexTypeMapperTests.java @@ -43,7 +43,7 @@ public class IndexTypeMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); IndexFieldMapper indexMapper = docMapper.rootMapper(IndexFieldMapper.class); assertThat(indexMapper.enabled(), equalTo(true)); - assertThat(indexMapper.store(), equalTo(Field.Store.YES)); + assertThat(indexMapper.stored(), equalTo(true)); assertThat(docMapper.mappers().indexName("_index").mapper(), instanceOf(IndexFieldMapper.class)); ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder() @@ -64,7 +64,7 @@ public class IndexTypeMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); IndexFieldMapper indexMapper = docMapper.rootMapper(IndexFieldMapper.class); assertThat(indexMapper.enabled(), equalTo(false)); - assertThat(indexMapper.store(), equalTo(Field.Store.YES)); + assertThat(indexMapper.stored(), equalTo(true)); ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder() .startObject() @@ -83,7 +83,7 @@ public class IndexTypeMapperTests { DocumentMapper docMapper = MapperTests.newParser().parse(mapping); IndexFieldMapper indexMapper = docMapper.rootMapper(IndexFieldMapper.class); assertThat(indexMapper.enabled(), equalTo(false)); - assertThat(indexMapper.store(), equalTo(Field.Store.NO)); + assertThat(indexMapper.stored(), equalTo(false)); ParsedDocument doc = docMapper.parse("type", "1", XContentFactory.jsonBuilder() .startObject() diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java index b895d750c2f..375600eb3b9 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/MultiFieldTests.java @@ -20,8 +20,7 @@ package org.elasticsearch.test.unit.index.mapper.multifield; import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.Fieldable; +import org.apache.lucene.index.IndexableField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.index.mapper.DocumentMapper; @@ -48,28 +47,28 @@ public class MultiFieldTests { BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json")); Document doc = docMapper.parse(json).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(true)); - assertThat(f.isIndexed(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(true)); - f = doc.getFieldable("name.indexed"); + f = doc.getField("name.indexed"); assertThat(f.name(), equalTo("name.indexed")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(false)); - assertThat(f.isIndexed(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); - f = doc.getFieldable("name.not_indexed"); + f = doc.getField("name.not_indexed"); assertThat(f.name(), equalTo("name.not_indexed")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(true)); - assertThat(f.isIndexed(), equalTo(false)); + assertThat(f.fieldType().stored(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(false)); - f = doc.getFieldable("object1.multi1"); + f = doc.getField("object1.multi1"); assertThat(f.name(), equalTo("object1.multi1")); - f = doc.getFieldable("object1.multi1.string"); + f = doc.getField("object1.multi1.string"); assertThat(f.name(), equalTo("object1.multi1.string")); assertThat(f.stringValue(), equalTo("2010-01-01")); } @@ -80,9 +79,9 @@ public class MultiFieldTests { DocumentMapper builderDocMapper = doc("test", rootObject("person").add( multiField("name") - .add(stringField("name").store(Field.Store.YES)) - .add(stringField("indexed").index(Field.Index.ANALYZED)) - .add(stringField("not_indexed").index(Field.Index.NO).store(Field.Store.YES)) + .add(stringField("name").store(true)) + .add(stringField("indexed").index(true).tokenized(true)) + .add(stringField("not_indexed").index(false).store(true)) )).build(mapperParser); builderDocMapper.refreshSource(); @@ -95,22 +94,22 @@ public class MultiFieldTests { BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/test-data.json")); Document doc = docMapper.parse(json).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f.name(), equalTo("name")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(true)); - assertThat(f.isIndexed(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(true)); - f = doc.getFieldable("name.indexed"); + f = doc.getField("name.indexed"); assertThat(f.name(), equalTo("name.indexed")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(false)); - assertThat(f.isIndexed(), equalTo(true)); + assertThat(f.fieldType().stored(), equalTo(false)); + assertThat(f.fieldType().indexed(), equalTo(true)); - f = doc.getFieldable("name.not_indexed"); + f = doc.getField("name.not_indexed"); assertThat(f.name(), equalTo("name.not_indexed")); assertThat(f.stringValue(), equalTo("some name")); - assertThat(f.isStored(), equalTo(true)); - assertThat(f.isIndexed(), equalTo(false)); + assertThat(f.fieldType().stored(), equalTo(true)); + assertThat(f.fieldType().indexed(), equalTo(false)); } } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java index dd524000716..4ce7cc50bbe 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/multifield/merge/JavaMultiFieldMergeTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.test.unit.index.mapper.multifield.merge; import org.apache.lucene.document.Document; -import org.apache.lucene.document.Fieldable; +import org.apache.lucene.index.IndexableField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.index.mapper.DocumentMapper; @@ -54,9 +54,9 @@ public class JavaMultiFieldMergeTests { BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json")); Document doc = docMapper.parse(json).rootDoc(); - Fieldable f = doc.getFieldable("name"); + IndexableField f = doc.getField("name"); assertThat(f, notNullValue()); - f = doc.getFieldable("name.indexed"); + f = doc.getField("name.indexed"); assertThat(f, nullValue()); @@ -78,9 +78,9 @@ public class JavaMultiFieldMergeTests { json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-data.json")); doc = docMapper.parse(json).rootDoc(); - f = doc.getFieldable("name"); + f = doc.getField("name"); assertThat(f, notNullValue()); - f = doc.getFieldable("name.indexed"); + f = doc.getField("name.indexed"); assertThat(f, notNullValue()); mapping = copyToStringFromClasspath("/org/elasticsearch/test/unit/index/mapper/multifield/merge/test-mapping3.json"); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java index 131023f58ee..9abe6921d39 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/nested/NestedMappingTests.java @@ -261,8 +261,8 @@ public class NestedMappingTests { assertThat(doc.docs().get(5).get("nested1.nested2.field2"), equalTo("2")); assertThat(doc.docs().get(5).get("field"), nullValue()); assertThat(doc.docs().get(6).get("field"), equalTo("value")); - assertThat(doc.docs().get(6).getFieldables("nested1.field1").length, equalTo(2)); - assertThat(doc.docs().get(6).getFieldables("nested1.nested2.field2").length, equalTo(4)); + assertThat(doc.docs().get(6).getFields("nested1.field1").length, equalTo(2)); + assertThat(doc.docs().get(6).getFields("nested1.nested2.field2").length, equalTo(4)); } @Test @@ -314,6 +314,6 @@ public class NestedMappingTests { assertThat(doc.docs().get(5).get("field"), nullValue()); assertThat(doc.docs().get(6).get("field"), equalTo("value")); assertThat(doc.docs().get(6).get("nested1.field1"), nullValue()); - assertThat(doc.docs().get(6).getFieldables("nested1.nested2.field2").length, equalTo(4)); + assertThat(doc.docs().get(6).getFields("nested1.nested2.field2").length, equalTo(4)); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java index eba387eafac..222809fcf85 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/numeric/SimpleNumericTests.java @@ -98,8 +98,8 @@ public class SimpleNumericTests { .field("field2", "1") .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field1"), nullValue()); - assertThat(doc.rootDoc().getFieldable("field2"), notNullValue()); + assertThat(doc.rootDoc().getField("field1"), nullValue()); + assertThat(doc.rootDoc().getField("field2"), notNullValue()); try { defaultMapper.parse("type", "1", XContentFactory.jsonBuilder() @@ -130,7 +130,7 @@ public class SimpleNumericTests { .field("field3", "a") .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field3"), nullValue()); + assertThat(doc.rootDoc().getField("field3"), nullValue()); // This should still throw an exception, since field2 is specifically set to ignore_malformed=false try { diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java index f66c2d522d9..6249657950c 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/simple/SimpleMapperTests.java @@ -47,7 +47,7 @@ public class SimpleMapperTests { DocumentMapperParser mapperParser = MapperTests.newParser(); DocumentMapper docMapper = doc("test", rootObject("person") - .add(object("name").add(stringField("first").store(YES).index(Field.Index.NO))) + .add(object("name").add(stringField("first").store(true).index(false))) ).build(mapperParser); BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/test/unit/index/mapper/simple/test1.json")); diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java index 328b9c6ded4..87ddf2c80f8 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/size/SizeMappingTests.java @@ -47,8 +47,8 @@ public class SizeMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1")); - assertThat(doc.rootDoc().getFieldable("_size").isStored(), equalTo(false)); - assertThat(doc.rootDoc().getFieldable("_size").tokenStreamValue(), notNullValue()); + assertThat(doc.rootDoc().getField("_size").fieldType().stored(), equalTo(false)); + assertThat(doc.rootDoc().getField("_size").tokenStream(docMapper.indexAnalyzer()), notNullValue()); } @Test @@ -65,8 +65,8 @@ public class SizeMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1")); - assertThat(doc.rootDoc().getFieldable("_size").isStored(), equalTo(true)); - assertThat(doc.rootDoc().getFieldable("_size").tokenStreamValue(), notNullValue()); + assertThat(doc.rootDoc().getField("_size").fieldType().stored(), equalTo(true)); + assertThat(doc.rootDoc().getField("_size").tokenStream(docMapper.indexAnalyzer()), notNullValue()); } @Test @@ -83,7 +83,7 @@ public class SizeMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1")); - assertThat(doc.rootDoc().getFieldable("_size"), nullValue()); + assertThat(doc.rootDoc().getField("_size"), nullValue()); } @Test @@ -99,6 +99,6 @@ public class SizeMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1")); - assertThat(doc.rootDoc().getFieldable("_size"), nullValue()); + assertThat(doc.rootDoc().getField("_size"), nullValue()); } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java index 47b70ce2590..bb594106804 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/CompressSourceMappingTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.test.unit.index.mapper.source; +import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; @@ -46,8 +47,8 @@ public class CompressSourceMappingTests { .field("field1", "value1") .field("field2", "value2") .endObject().bytes()); - - assertThat(CompressorFactory.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(false)); + BytesRef bytes = doc.rootDoc().getBinaryValue("_source"); + assertThat(CompressorFactory.isCompressed(bytes.bytes, bytes.offset, bytes.length), equalTo(false)); } @Test @@ -63,7 +64,8 @@ public class CompressSourceMappingTests { .field("field2", "value2") .endObject().bytes()); - assertThat(CompressorFactory.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(true)); + BytesRef bytes = doc.rootDoc().getBinaryValue("_source"); + assertThat(CompressorFactory.isCompressed(bytes.bytes, bytes.offset, bytes.length), equalTo(true)); } @Test @@ -78,7 +80,8 @@ public class CompressSourceMappingTests { .field("field1", "value1") .endObject().bytes()); - assertThat(CompressorFactory.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(false)); + BytesRef bytes = doc.rootDoc().getBinaryValue("_source"); + assertThat(CompressorFactory.isCompressed(bytes.bytes, bytes.offset, bytes.length), equalTo(false)); doc = documentMapper.parse("type", "1", XContentFactory.jsonBuilder().startObject() .field("field1", "value1") @@ -88,6 +91,7 @@ public class CompressSourceMappingTests { .field("field2", "value2 xxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyy zzzzzzzzzzzzzzzzz") .endObject().bytes()); - assertThat(CompressorFactory.isCompressed(doc.rootDoc().getBinaryValue("_source")), equalTo(true)); + bytes = doc.rootDoc().getBinaryValue("_source"); + assertThat(CompressorFactory.isCompressed(bytes.bytes, bytes.offset, bytes.length), equalTo(true)); } } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java index ed2a3c5389f..18c64c45c87 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/source/DefaultSourceMappingTests.java @@ -19,7 +19,8 @@ package org.elasticsearch.test.unit.index.mapper.source; -import org.apache.lucene.document.Fieldable; +import org.apache.lucene.index.IndexableField; +import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; @@ -120,8 +121,8 @@ public class DefaultSourceMappingTests { .startObject("path2").field("field2", "value2").endObject() .endObject().bytes()); - Fieldable sourceField = doc.rootDoc().getFieldable("_source"); - Map sourceAsMap = XContentFactory.xContent(XContentType.JSON).createParser(sourceField.getBinaryValue(), sourceField.getBinaryOffset(), sourceField.getBinaryLength()).mapAndClose(); + IndexableField sourceField = doc.rootDoc().getField("_source"); + Map sourceAsMap = XContentFactory.xContent(XContentType.JSON).createParser(new BytesArray(sourceField.binaryValue())).mapAndClose(); assertThat(sourceAsMap.containsKey("path1"), equalTo(true)); assertThat(sourceAsMap.containsKey("path2"), equalTo(false)); } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/string/SimpleStringMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/string/SimpleStringMappingTests.java index 0d34893b451..7b7e0a50f76 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/string/SimpleStringMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/string/SimpleStringMappingTests.java @@ -48,7 +48,7 @@ public class SimpleStringMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field"), notNullValue()); + assertThat(doc.rootDoc().getField("field"), notNullValue()); doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder() .startObject() @@ -56,7 +56,7 @@ public class SimpleStringMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field"), notNullValue()); + assertThat(doc.rootDoc().getField("field"), notNullValue()); doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder() .startObject() @@ -64,7 +64,7 @@ public class SimpleStringMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field"), nullValue()); + assertThat(doc.rootDoc().getField("field"), nullValue()); } @Test @@ -81,8 +81,8 @@ public class SimpleStringMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field").getOmitNorms(), equalTo(false)); - assertThat(doc.rootDoc().getFieldable("field").getIndexOptions(), equalTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)); + assertThat(doc.rootDoc().getField("field").fieldType().omitNorms(), equalTo(false)); + assertThat(doc.rootDoc().getField("field").fieldType().indexOptions(), equalTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)); } @Test @@ -99,8 +99,8 @@ public class SimpleStringMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field").getOmitNorms(), equalTo(true)); - assertThat(doc.rootDoc().getFieldable("field").getIndexOptions(), equalTo(FieldInfo.IndexOptions.DOCS_ONLY)); + assertThat(doc.rootDoc().getField("field").fieldType().omitNorms(), equalTo(true)); + assertThat(doc.rootDoc().getField("field").fieldType().indexOptions(), equalTo(FieldInfo.IndexOptions.DOCS_ONLY)); // now test it explicitly set @@ -116,7 +116,7 @@ public class SimpleStringMappingTests { .endObject() .bytes()); - assertThat(doc.rootDoc().getFieldable("field").getOmitNorms(), equalTo(false)); - assertThat(doc.rootDoc().getFieldable("field").getIndexOptions(), equalTo(FieldInfo.IndexOptions.DOCS_AND_FREQS)); + assertThat(doc.rootDoc().getField("field").fieldType().omitNorms(), equalTo(false)); + assertThat(doc.rootDoc().getField("field").fieldType().indexOptions(), equalTo(FieldInfo.IndexOptions.DOCS_AND_FREQS)); } } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java index 4cf171b0ca1..be6311e3ea7 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/timestamp/TimestampMappingTests.java @@ -48,7 +48,7 @@ public class TimestampMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1").timestamp(1)); - assertThat(doc.rootDoc().getFieldable("_timestamp"), equalTo(null)); + assertThat(doc.rootDoc().getField("_timestamp"), equalTo(null)); } @Test @@ -64,9 +64,9 @@ public class TimestampMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1").timestamp(1)); - assertThat(doc.rootDoc().getFieldable("_timestamp").isStored(), equalTo(true)); - assertThat(doc.rootDoc().getFieldable("_timestamp").isIndexed(), equalTo(true)); - assertThat(doc.rootDoc().getFieldable("_timestamp").tokenStreamValue(), notNullValue()); + assertThat(doc.rootDoc().getField("_timestamp").fieldType().stored(), equalTo(true)); + assertThat(doc.rootDoc().getField("_timestamp").fieldType().indexed(), equalTo(true)); + assertThat(doc.rootDoc().getField("_timestamp").tokenStream(docMapper.indexAnalyzer()), notNullValue()); } @Test @@ -74,8 +74,8 @@ public class TimestampMappingTests { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.timestampFieldMapper().enabled(), equalTo(TimestampFieldMapper.Defaults.ENABLED)); - assertThat(docMapper.timestampFieldMapper().store(), equalTo(TimestampFieldMapper.Defaults.STORE)); - assertThat(docMapper.timestampFieldMapper().index(), equalTo(TimestampFieldMapper.Defaults.INDEX)); + assertThat(docMapper.timestampFieldMapper().stored(), equalTo(TimestampFieldMapper.Defaults.FIELD_TYPE.stored())); + assertThat(docMapper.timestampFieldMapper().indexed(), equalTo(TimestampFieldMapper.Defaults.FIELD_TYPE.indexed())); assertThat(docMapper.timestampFieldMapper().path(), equalTo(null)); assertThat(docMapper.timestampFieldMapper().dateTimeFormatter().format(), equalTo(TimestampFieldMapper.DEFAULT_DATE_TIME_FORMAT)); } @@ -91,8 +91,8 @@ public class TimestampMappingTests { .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.timestampFieldMapper().enabled(), equalTo(true)); - assertThat(docMapper.timestampFieldMapper().store(), equalTo(Field.Store.YES)); - assertThat(docMapper.timestampFieldMapper().index(), equalTo(Field.Index.NO)); + assertThat(docMapper.timestampFieldMapper().stored(), equalTo(true)); + assertThat(docMapper.timestampFieldMapper().indexed(), equalTo(false)); assertThat(docMapper.timestampFieldMapper().path(), equalTo("timestamp")); assertThat(docMapper.timestampFieldMapper().dateTimeFormatter().format(), equalTo("year")); } diff --git a/src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java b/src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java index ca11797cba5..afcfc5f367f 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/mapper/ttl/TTLMappingTests.java @@ -46,7 +46,7 @@ public class TTLMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1").ttl(Long.MAX_VALUE)); - assertThat(doc.rootDoc().getFieldable("_ttl"), equalTo(null)); + assertThat(doc.rootDoc().getField("_ttl"), equalTo(null)); } @Test @@ -62,9 +62,9 @@ public class TTLMappingTests { .bytes(); ParsedDocument doc = docMapper.parse(SourceToParse.source(source).type("type").id("1").ttl(Long.MAX_VALUE)); - assertThat(doc.rootDoc().getFieldable("_ttl").isStored(), equalTo(true)); - assertThat(doc.rootDoc().getFieldable("_ttl").isIndexed(), equalTo(true)); - assertThat(doc.rootDoc().getFieldable("_ttl").tokenStreamValue(), notNullValue()); + assertThat(doc.rootDoc().getField("_ttl").fieldType().stored(), equalTo(true)); + assertThat(doc.rootDoc().getField("_ttl").fieldType().indexed(), equalTo(true)); + assertThat(doc.rootDoc().getField("_ttl").tokenStream(docMapper.indexAnalyzer()), notNullValue()); } @Test @@ -72,8 +72,8 @@ public class TTLMappingTests { String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.TTLFieldMapper().enabled(), equalTo(TTLFieldMapper.Defaults.ENABLED)); - assertThat(docMapper.TTLFieldMapper().store(), equalTo(TTLFieldMapper.Defaults.STORE)); - assertThat(docMapper.TTLFieldMapper().index(), equalTo(TTLFieldMapper.Defaults.INDEX)); + assertThat(docMapper.TTLFieldMapper().stored(), equalTo(TTLFieldMapper.Defaults.FIELD_TYPE.stored())); + assertThat(docMapper.TTLFieldMapper().indexed(), equalTo(TTLFieldMapper.Defaults.FIELD_TYPE.indexed())); } @@ -86,7 +86,7 @@ public class TTLMappingTests { .endObject().endObject().string(); DocumentMapper docMapper = MapperTests.newParser().parse(mapping); assertThat(docMapper.TTLFieldMapper().enabled(), equalTo(true)); - assertThat(docMapper.TTLFieldMapper().store(), equalTo(Field.Store.NO)); - assertThat(docMapper.TTLFieldMapper().index(), equalTo(Field.Index.NO)); + assertThat(docMapper.TTLFieldMapper().stored(), equalTo(false)); + assertThat(docMapper.TTLFieldMapper().indexed(), equalTo(false)); } } \ No newline at end of file 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 2f78a6b9f76..7c5cc9f0ce7 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 @@ -20,8 +20,10 @@ package org.elasticsearch.test.unit.index.query; import org.apache.lucene.index.Term; +import org.apache.lucene.sandbox.queries.FuzzyLikeThisQuery; import org.apache.lucene.search.*; import org.apache.lucene.search.spans.*; +import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.NumericUtils; import org.elasticsearch.cluster.ClusterService; import org.elasticsearch.common.bytes.BytesArray; @@ -122,6 +124,12 @@ public class SimpleIndexQueryParserTests { return this.queryParser; } + private BytesRef longToPrefixCoded(long val) { + BytesRef bytesRef = new BytesRef(); + NumericUtils.longToPrefixCoded(val, 0, bytesRef); + return bytesRef; + } + @Test public void testQueryStringBuilder() throws Exception { IndexQueryParserService queryParser = queryParser(); @@ -1217,7 +1225,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", NumericUtils.longToPrefixCoded(34)))); + assertThat(termQuery.getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); } @Test @@ -1228,7 +1236,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", NumericUtils.longToPrefixCoded(34)))); + assertThat(termQuery.getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); } @Test @@ -1238,8 +1246,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); + assertThat(((SpanTermQuery) spanNotQuery.getInclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); + assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); } @Test @@ -1250,8 +1258,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); + assertThat(((SpanTermQuery) spanNotQuery.getInclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); + assertThat(((SpanTermQuery) spanNotQuery.getExclude()).getTerm(), equalTo(new Term("age", longToPrefixCoded(35)))); } @Test @@ -1261,7 +1269,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", NumericUtils.longToPrefixCoded(34)))); + assertThat(((SpanTermQuery) spanFirstQuery.getMatch()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); assertThat(spanFirstQuery.getEnd(), equalTo(12)); } @@ -1273,7 +1281,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", NumericUtils.longToPrefixCoded(34)))); + assertThat(((SpanTermQuery) spanFirstQuery.getMatch()).getTerm(), equalTo(new Term("age", longToPrefixCoded(34)))); assertThat(spanFirstQuery.getEnd(), equalTo(12)); } @@ -1284,9 +1292,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); + 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(spanNearQuery.isInOrder(), equalTo(false)); } @@ -1298,9 +1306,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanNearQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); + 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(spanNearQuery.isInOrder(), equalTo(false)); } @@ -1311,9 +1319,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); + 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)))); } @Test @@ -1324,9 +1332,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); + 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)))); } @Test @@ -1337,9 +1345,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", NumericUtils.longToPrefixCoded(34)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[1]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(35)))); - assertThat(((SpanTermQuery) spanOrQuery.getClauses()[2]).getTerm(), equalTo(new Term("age", NumericUtils.longToPrefixCoded(36)))); + 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)))); } @Test diff --git a/src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java b/src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java index 88ef0f53989..3bd2c9a9ae7 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/store/memory/SimpleByteBufferStoreTests.java @@ -19,10 +19,7 @@ package org.elasticsearch.test.unit.index.store.memory; -import org.apache.lucene.store.IndexInput; -import org.apache.lucene.store.IndexOutput; -import org.apache.lucene.store.Lock; -import org.apache.lucene.store.LockObtainFailedException; +import org.apache.lucene.store.*; import org.apache.lucene.store.bytebuffer.ByteBufferDirectory; import org.elasticsearch.cache.memory.ByteBufferCache; import org.testng.annotations.Test; @@ -121,7 +118,7 @@ public class SimpleByteBufferStoreTests { private void insertData(ByteBufferDirectory dir, int bufferSizeInBytes) throws IOException { byte[] test = new byte[]{1, 2, 3, 4, 5, 6, 7, 8}; - IndexOutput indexOutput = dir.createOutput("value1"); + IndexOutput indexOutput = dir.createOutput("value1", IOContext.DEFAULT); indexOutput.writeBytes(new byte[]{2, 4, 6, 7, 8}, 5); indexOutput.writeInt(-1); indexOutput.writeLong(10); @@ -145,7 +142,7 @@ public class SimpleByteBufferStoreTests { assertThat(dir.fileExists("value1"), equalTo(true)); assertThat(dir.fileLength("value1"), equalTo(38l)); - IndexInput indexInput = dir.openInput("value1"); + IndexInput indexInput = dir.openInput("value1", IOContext.DEFAULT); indexInput.readBytes(test, 0, 5); assertThat(test[0], equalTo((byte) 8)); assertThat(indexInput.readInt(), equalTo(-1)); @@ -170,7 +167,7 @@ public class SimpleByteBufferStoreTests { indexInput.close(); - indexInput = dir.openInput("value1"); + indexInput = dir.openInput("value1", IOContext.DEFAULT); // iterate over all the data for (int i = 0; i < 38; i++) { indexInput.readByte();