Differnce in results when the search query contains a hyphen

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:
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

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

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