I need it mapped as an IP type so I can search on IP ranges, but when would I want it to be a keyword?
Is searching on a keyword field faster than an IP field? Like for example if I want to query for a specific IP would a query for host_ip.keyword:<specific ip> be faster then searching on host_ip:<specific ip> (where host_ip is an IP type)?
I don't see any real use for that. ip fields behaves just as keyword field in the sense that you can do aggregations over it plus the fact that you can do CIDR queries on ip fields.
One aggregation where there is a possible performance benefit is the significant_terms aggregation.
It needs to look up background frequencies to relevance rank candidate terms. An example use case is identifying the IP addresses strongly correlated with risky behaviour [1].
With a simple keyword field Lucene maintains a count that can be looked up cheaply. However, to look up the background frequency for an ip type field the internal implementation in significant terms has to effectively run a query to count the set of docs with this value which is more expensive.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.