Store an IP range in ES

SO i've tried to find an answer to this and i've had no luck in finding the answer. I want to store an IP range such as '5.10.89.104', '5.10.89.107' and then be able to search for data associated within the particular range. so lets say that if i search for 5.10.89.106 the document associated with that range will show up.

I can find a ton of stuff looking up a range but nothing about storing a range

Well, you could create a range query with the IPs and register it in the .percolator on your index, then match the document with the single IP address against the registered queries.

1 Like

There are some ongoing developments in Lucene about adding the ability to index ranges, which will probably get exposed in elasticsearch at some point: https://issues.apache.org/jira/browse/LUCENE-7381

i didn't know anything about .percolator so i shall read up and see if that helps, thank you for your reply - very helpful :smiley:

Hi! Why don't create two fields IP_START and IP_END to store start and end of range?
In search query you can compare your IP with it (documentation say that IP stores as long internally so it easyly comparable like numbers).

Like: IP >= IP_START and IP<= IP_END
http://pastebin.com/yChG2z2w

thanks for you suggestion i'll have a look into it, not sure though that's quite what i'm looking for though