Skip to content

Commit

Permalink
Fix DerivedFieldTypeTests
Browse files Browse the repository at this point in the history
I broke these when fixing DerivedFieldMapperQueryTests.

Signed-off-by: Michael Froh <[email protected]>
  • Loading branch information
msfroh committed Dec 19, 2024
1 parent fd14e80 commit ea0549b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,9 @@ public static InetAddressField buildInetAddressField(String name, InetAddress va
return new InetAddressField(name, value);
}

// Field type that combines dimensional points and
private static class InetAddressField extends Field {
private static FieldType FIELD_TYPE = new FieldType();
// Field type that combines dimensional points and doc values for IP fields
public static class InetAddressField extends Field {
private static final FieldType FIELD_TYPE = new FieldType();
static {
FIELD_TYPE.setDimensions(1, InetAddressPoint.BYTES);
FIELD_TYPE.setDocValuesType(DocValuesType.SORTED_SET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.apache.lucene.document.KeywordField;
import org.apache.lucene.document.LatLonPoint;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.LongPoint;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.memory.MemoryIndex;
import org.apache.lucene.queries.spans.SpanMultiTermQueryWrapper;
Expand Down Expand Up @@ -66,7 +65,7 @@ public void testBooleanType() {
public void testDateType() {
DerivedFieldType dft = createDerivedFieldType("date");
assertTrue(dft.getFieldMapper() instanceof DateFieldMapper);
assertTrue(dft.getIndexableFieldGenerator().apply(System.currentTimeMillis()) instanceof LongPoint);
assertTrue(dft.getIndexableFieldGenerator().apply(System.currentTimeMillis()) instanceof LongField);
expectThrows(Exception.class, () -> dft.getIndexableFieldGenerator().apply("blah"));
}

Expand All @@ -83,7 +82,7 @@ public void testGeoPointType() {
public void testIPType() {
DerivedFieldType dft = createDerivedFieldType("ip");
assertTrue(dft.getFieldMapper() instanceof IpFieldMapper);
assertTrue(dft.getIndexableFieldGenerator().apply("127.0.0.1") instanceof InetAddressPoint);
assertTrue(dft.getIndexableFieldGenerator().apply("127.0.0.1") instanceof IpFieldMapper.InetAddressField);
expectThrows(Exception.class, () -> dft.getIndexableFieldGenerator().apply("blah"));
}

Expand Down

0 comments on commit ea0549b

Please sign in to comment.