# Differnce in results when the search query contains a hyphen

**URL:** https://discuss.elastic.co/t/differnce-in-results-when-the-search-query-contains-a-hyphen/336324
**Category:** Elasticsearch
**Created:** [June 19, 2023, 4:18am UTC](https://discuss.elastic.co/t/differnce-in-results-when-the-search-query-contains-a-hyphen/336324 "2023-06-19T04:18:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zigoo0](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zigoo0/32/122413_2.png) [@zigoo0](https://discuss.elastic.co/u/zigoo0)
#### Post date: [June 19, 2023, 4:18am UTC](https://discuss.elastic.co/t/differnce-in-results-when-the-search-query-contains-a-hyphen/336324/1 "2023-06-19T04:18:31Z")

</div>

Hello team,  
I have an elasticsearch index that contains hostnames and email addresses. When searching the index, my aim is to retrieve all hostnames and emails that contains certain domain

Following examples will explain the problem:  
Note the \* at the start to make sure it gets all the results:  
q=\*HOSTNAME&pretty&size=9999  
Above query gets all results accurately. But when searching it WITHOUT \*, it gets very limited results.

Second example is "host-name" note the HYPHEN in the hostname:  
q=\*HOST-NAME&pretty&size=9999 (ignore the [.] in the hostname)  
The above example gets very limited results, however, when Removing the \*, it gets all the results.

That confuses me as some examples works perfectly with \* and failed without \*, while some other examples (contains -) fails \* and works fine without it.

What is the best approach to make sure I get all the results for any hostname no matter it contains hyphen or not?

Thank you

---

<div class="post-metadata">

### Author: ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)
#### Post date: [June 19, 2023, 1:00pm UTC](https://discuss.elastic.co/t/differnce-in-results-when-the-search-query-contains-a-hyphen/336324/2 "2023-06-19T13:00:46Z")

</div>

Hi @zigoo0

Not knowing how the index mapping is, I would try to add the OR in the query like this: q=\*HOSTNAME OR HOST-NAME

---

<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 17, 2023, 1:01pm UTC](https://discuss.elastic.co/t/differnce-in-results-when-the-search-query-contains-a-hyphen/336324/3 "2023-07-17T13:01:14Z")

</div>

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