Skip to content
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

Updated ElasticSearch example for ES v5.5.1 #192

Merged
merged 2 commits into from
Jul 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Changelog
- Fixed 'nets'->'range' bug for legacy whois CIDR net_range values (#188)
- Fixed a bug in IPASN/Net that caused the ASN result to vary if Cymru has
more than one ASN listed for an IP (#190)
- Updated ElasticSearch example for ES v5.5.1 (#138)

0.15.1 (2017-02-16)
-------------------
Expand Down
8 changes: 4 additions & 4 deletions ipwhois/asn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
import copy
import logging

from .exceptions import (NetError, ASNRegistryError, ASNParseError,
ASNLookupError, HTTPLookupError, WhoisLookupError,
WhoisRateLimitError, ASNOriginLookupError)

if sys.version_info >= (3, 3): # pragma: no cover
from ipaddress import ip_network

else: # pragma: no cover
from ipaddr import IPNetwork as ip_network

from .exceptions import (NetError, ASNRegistryError, ASNParseError,
ASNLookupError, HTTPLookupError, WhoisLookupError,
WhoisRateLimitError, ASNOriginLookupError)

log = logging.getLogger(__name__)

BASE_NET = {
Expand Down
4 changes: 2 additions & 2 deletions ipwhois/examples/elastic_search/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Dependencies

Tested using::

ElasticSearch 2.3.5
Kibana 4.5.4
ElasticSearch 5.5.1
Kibana 5.5.1

Python 2.6 (requirements26.txt - geopy is not supported)::

Expand Down
2 changes: 1 addition & 1 deletion ipwhois/examples/elastic_search/data/kibana.json

Large diffs are not rendered by default.

109 changes: 47 additions & 62 deletions ipwhois/examples/elastic_search/elastic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@

# Common es mapping.
DEFAULT_MAPPING = {
'date_detection': 1,
'date_detection': 'true',
'properties': {
'@version': {
'type': 'string',
'index': 'not_analyzed'
},
'updated': {
'type': 'date',
'format': 'yyyy-MM-dd\'T\'HH:mm:ssZ',
'format': 'date_time_no_millis',
'ignore_malformed': 'false'
}
},
Expand All @@ -124,13 +124,7 @@
'match': '*',
'match_mapping_type': 'string',
'mapping': {
'type': 'multi_field',
'fields': {
'{name}': {
'type': 'string',
'index': 'not_analyzed'
}
}
'type': 'keyword'
}
}
}
Expand Down Expand Up @@ -186,49 +180,44 @@ def create_index():

# base doc type mapping
mapping = DEFAULT_MAPPING.copy()
mapping.update({
'properties': {
'asn_date': {
'type': 'date',
'format': 'date',
'ignore_malformed': 'true'
},
'network_events_timestamp': {
'type': 'date',
'format': 'yyyy-MM-dd\'T\'HH:mm:ssZ',
'ignore_malformed': 'false'
},
'query': {
'type': 'ip',
'store': True,
'ignore_malformed': True
},
'query_geo': {
'type': 'geo_point',
'lat_lon': True,
'geohash': True
},
'network': {
'properties': {
'country_geo': {
'type': 'geo_point',
'lat_lon': True,
'geohash': True
},
'start_address': {
'type': 'ip',
'store': True,
'ignore_malformed': True
},
'end_address': {
'type': 'ip',
'store': True,
'ignore_malformed': True
}
mapping['properties'].update({
'asn_date': {
'type': 'date',
'format': 'date',
'ignore_malformed': 'true'
},
'network_events_timestamp': {
'type': 'date',
'format': 'date_time_no_millis',
'ignore_malformed': 'false'
},
'query': {
'type': 'ip',
'store': 'true',
'ignore_malformed': 'true'
},
'query_geo': {
'type': 'geo_point'
},
'network': {
'properties': {
'country_geo': {
'type': 'geo_point'
},
'start_address': {
'type': 'ip',
'store': 'true',
'ignore_malformed': 'true'
},
'end_address': {
'type': 'ip',
'store': 'true',
'ignore_malformed': 'true'
}
}
}
})

es.indices.put_mapping(
index='ipwhois',
doc_type='base',
Expand All @@ -238,20 +227,16 @@ def create_index():

# entity doc type mapping
mapping = DEFAULT_MAPPING.copy()
mapping.update({
'properties': {
'contact': {
'properties': {
'address': {
'properties': {
'geo': {
'type': 'geo_point',
'lat_lon': True,
'geohash': True
},
'value': {
'type': 'string',
}
mapping['properties'].update({
'contact': {
'properties': {
'address': {
'properties': {
'geo': {
'type': 'geo_point'
},
'value': {
'type': 'string',
}
}
}
Expand Down