I have a field with type ip_range. When I query for an IP address, I'd like to have the results returned in the order of most precise range to least. Is there a simple way to accomplish this? Perhaps I overlooked something obvious in the docs.
Notice that the CIDR 127.0.0.0/8 contains 127.0.0.1. But 127.0.0.0/20 is more precise (it is a range of size 2^12 vs 2^24), and 127.0.0.1/32 more precisely still (it has size 1). I would like them returned in order of range size.
Does that make sense? Please let me know if you need more information.
unfortunately both the "term" and also the "range" query on "ip_range" fields seem to do only constant scoring (also known as filtering), so in order to sort on the precision of the range I'd probably store the cidr suffix alongside the range in a separate field and sort by that. Would that work for you use case?
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.