June 2017
Beginner to intermediate
404 pages
8h 22m
English
In the previous section, we discussed geo data type, which is used to store location-based data. In this section, we will discuss IP data type, which is used to store IP addresses. Both IPv4 and IPv6 addresses are supported. For example, we have a login history document, and we want to store the IP address of the client in the history. We can add an ip_address field to history mapping, as shown next:
PUT chapter3/_mapping/history { "properties": { "ip_address": { "type": "ip" } } }
You can index the history document with an IP address, as shown here:
{ "username" : "user1", "ip_address" : "10.123.24.33", "login_status" : "SUCCESSFUL" }
Read now
Unlock full access