django-elasticsearch-dsl
django-elasticsearch-dsl copied to clipboard
How can I use ip_range field type?
How can one use the ip_range field type for CIDR notated IP addresses?
https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html#ip-range
I tried making a subclass like this but it results in a field mapping of "type": "text"
...
from django_elasticsearch_dsl.fields import DEDField
from elasticsearch_dsl.field import IpRange
...
class IpRangeField(DEDField, IpRange):
"""Subclass based on DedField and IpRange."""
@registry.register_document
class FeedDataDocument(Document):
"""FeedData elasticsearch."""
...
ipaddress = IpRangeField()
...
"mappings": {
"_doc": {
"properties": {
"ipaddress": {
"type": "text"
...