@@ -56,13 +56,33 @@ public void testTermQuery() {
5656 MappedFieldType ft = new IpFieldMapper .IpFieldType ("field" );
5757
5858 String ip = "2001:db8::2:1" ;
59+ Query query = InetAddressPoint .newExactQuery ("field" , InetAddresses .forString (ip ));
60+ assertEquals (new IndexOrDocValuesQuery (query , convertToDocValuesQuery (query )), ft .termQuery (ip , MOCK_CONTEXT ));
61+
62+ ip = "192.168.1.7" ;
63+ query = InetAddressPoint .newExactQuery ("field" , InetAddresses .forString (ip ));
64+ assertEquals (new IndexOrDocValuesQuery (query , convertToDocValuesQuery (query )), ft .termQuery (ip , MOCK_CONTEXT ));
65+
66+ ip = "2001:db8::2:1" ;
67+ String prefix = ip + "/64" ;
68+ query = InetAddressPoint .newPrefixQuery ("field" , InetAddresses .forString (ip ), 64 );
69+ assertEquals (new IndexOrDocValuesQuery (query , convertToDocValuesQuery (query )), ft .termQuery (prefix , MOCK_CONTEXT ));
70+
71+ ip = "192.168.1.7" ;
72+ prefix = ip + "/16" ;
73+ query = InetAddressPoint .newPrefixQuery ("field" , InetAddresses .forString (ip ), 16 );
74+ assertEquals (new IndexOrDocValuesQuery (query , convertToDocValuesQuery (query )), ft .termQuery (prefix , MOCK_CONTEXT ));
75+
76+ ft = new IpFieldMapper .IpFieldType ("field" , true , false );
77+
78+ ip = "2001:db8::2:1" ;
5979 assertEquals (InetAddressPoint .newExactQuery ("field" , InetAddresses .forString (ip )), ft .termQuery (ip , MOCK_CONTEXT ));
6080
6181 ip = "192.168.1.7" ;
6282 assertEquals (InetAddressPoint .newExactQuery ("field" , InetAddresses .forString (ip )), ft .termQuery (ip , MOCK_CONTEXT ));
6383
6484 ip = "2001:db8::2:1" ;
65- String prefix = ip + "/64" ;
85+ prefix = ip + "/64" ;
6686 assertEquals (InetAddressPoint .newPrefixQuery ("field" , InetAddresses .forString (ip ), 64 ), ft .termQuery (prefix , MOCK_CONTEXT ));
6787
6888 ip = "192.168.1.7" ;
0 commit comments