New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new ip_range field type #24433

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@nknize
Member

nknize commented May 2, 2017

This commit adds support for indexing and searching the new ip_range field type. Both IPv4 and IPv6 formats are supported. Tests and docs are updated.

@jpountz

I left some minor comments but the change looks good to me overall.

core/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java Outdated
}
@Override
public InetAddress parseFrom(RangeFieldType fieldType, XContentParser parser, boolean coerce, boolean included)
throws IOException {

This comment has been minimized.

@jpountz

jpountz May 3, 2017

Contributor

can you indent so that the throws is not indented at the same level as the content of the block? (similar issues on the below lines)

core/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java Outdated
@Override
public InetAddress parse(Object value, boolean coerce) {
try {
return value instanceof InetAddress ? (InetAddress) value : InetAddress.getByName((String) value);

This comment has been minimized.

@jpountz

jpountz May 3, 2017

Contributor

can you use InetAddresses.forString intead, which guarantees it won't do a dns lookup

core/src/test/java/org/elasticsearch/index/mapper/RangeFieldMapperTests.java Outdated
if (type.equals("date_range")) {
strVal = "1477872000000";
} else if (type.equals("ip_range")) {
strVal = "/192.168.1.7:/2001:db8:0:0:0:0:0:0";

This comment has been minimized.

@jpountz

jpountz May 3, 2017

Contributor

I guess we get this by doing a toString on an InetAddress. Could you make sure we use InetAddresses.toAddrString instead?

@nknize

This comment has been minimized.

Member

nknize commented May 3, 2017

Thanks for the excellent feedback @jpountz. I made the changes and will go ahead and merge tomorrow unless you have any other concerns.

@jpountz

jpountz approved these changes May 4, 2017

Add new ip_range field type
This commit adds support for indexing and searching a new ip_range field type. Both IPv4 and IPv6 formats are supported. Tests are updated and docs are added.
@nknize

This comment has been minimized.

Member

nknize commented May 5, 2017

merged in 0c4eb0a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment