Skip to content

Commit

Permalink
Fix IpFieldMapperTests
Browse files Browse the repository at this point in the history
I broke these tests as a side-effect for my fix to
DerivedFieldMapperQueryTests.

Signed-off-by: Michael Froh <[email protected]>
  • Loading branch information
msfroh committed Dec 19, 2024
1 parent 7ca821a commit df31192
Showing 1 changed file with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,13 @@ public void testDefaults() throws Exception {
ParsedDocument doc = mapper.parse(source(b -> b.field("field", "::1")));

IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(2, fields.length);
IndexableField pointField = fields[0];
assertEquals(1, pointField.fieldType().pointIndexDimensionCount());
assertEquals(16, pointField.fieldType().pointNumBytes());
assertFalse(pointField.fieldType().stored());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddresses.forString("::1"))), pointField.binaryValue());
IndexableField dvField = fields[1];
assertEquals(DocValuesType.SORTED_SET, dvField.fieldType().docValuesType());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddresses.forString("::1"))), dvField.binaryValue());
assertFalse(dvField.fieldType().stored());
assertEquals(1, fields.length);
IndexableField pointFieldAndDVField = fields[0];
assertEquals(1, pointFieldAndDVField.fieldType().pointIndexDimensionCount());
assertEquals(16, pointFieldAndDVField.fieldType().pointNumBytes());
assertFalse(pointFieldAndDVField.fieldType().stored());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddresses.forString("::1"))), pointFieldAndDVField.binaryValue());
assertEquals(DocValuesType.SORTED_SET, pointFieldAndDVField.fieldType().docValuesType());
}

public void testNotIndexed() throws Exception {
Expand Down Expand Up @@ -145,12 +142,11 @@ public void testStore() throws Exception {
ParsedDocument doc = mapper.parse(source(b -> b.field("field", "::1")));

IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(3, fields.length);
IndexableField pointField = fields[0];
assertEquals(1, pointField.fieldType().pointIndexDimensionCount());
IndexableField dvField = fields[1];
assertEquals(DocValuesType.SORTED_SET, dvField.fieldType().docValuesType());
IndexableField storedField = fields[2];
assertEquals(2, fields.length);
IndexableField pointFieldAndDVField = fields[0];
assertEquals(1, pointFieldAndDVField.fieldType().pointIndexDimensionCount());
assertEquals(DocValuesType.SORTED_SET, pointFieldAndDVField.fieldType().docValuesType());
IndexableField storedField = fields[1];
assertTrue(storedField.fieldType().stored());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddress.getByName("::1"))), storedField.binaryValue());
}
Expand Down Expand Up @@ -190,16 +186,13 @@ public void testNullValue() throws IOException {
doc = mapper.parse(source(b -> b.nullField("field")));

IndexableField[] fields = doc.rootDoc().getFields("field");
assertEquals(2, fields.length);
IndexableField pointField = fields[0];
assertEquals(1, pointField.fieldType().pointIndexDimensionCount());
assertEquals(16, pointField.fieldType().pointNumBytes());
assertFalse(pointField.fieldType().stored());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddresses.forString("::1"))), pointField.binaryValue());
IndexableField dvField = fields[1];
assertEquals(DocValuesType.SORTED_SET, dvField.fieldType().docValuesType());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddresses.forString("::1"))), dvField.binaryValue());
assertFalse(dvField.fieldType().stored());
assertEquals(1, fields.length);
IndexableField pointFieldAndDVField = fields[0];
assertEquals(1, pointFieldAndDVField.fieldType().pointIndexDimensionCount());
assertEquals(16, pointFieldAndDVField.fieldType().pointNumBytes());
assertFalse(pointFieldAndDVField.fieldType().stored());
assertEquals(new BytesRef(InetAddressPoint.encode(InetAddresses.forString("::1"))), pointFieldAndDVField.binaryValue());
assertEquals(DocValuesType.SORTED_SET, pointFieldAndDVField.fieldType().docValuesType());

mapper = createDocumentMapper(fieldMapping(b -> {
b.field("type", "ip");
Expand Down

0 comments on commit df31192

Please sign in to comment.