# Query a field that can be host or IP

**URL:** <https://discuss.elastic.co/t/query-a-field-that-can-be-host-or-ip/184213>\
**Category:** Elasticsearch\
**Created:** [June 4, 2019, 2:55pm UTC](https://discuss.elastic.co/t/query-a-field-that-can-be-host-or-ip/184213 "2019-06-04T14:55:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nili1](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@nili1](https://discuss.elastic.co/u/nili1)\
**Post date:** [June 4, 2019, 2:55pm UTC](https://discuss.elastic.co/t/query-a-field-that-can-be-host-or-ip/184213/1 "2019-06-04T14:55:41Z")

</div>

We have a field that can have either a host name (e.g. [elastic.co](http://elastic.co)) or an IP. We would like to run queries as a regular text field or using CIDR notation. What is the best solution for this? Should we create a multi-field with text and ip and determine which to use in each case? Is there a better solution for indexing this type of field?  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 2, 2019, 2:55pm UTC](https://discuss.elastic.co/t/query-a-field-that-can-be-host-or-ip/184213/2 "2019-07-02T14:55:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
