Query_string using '*' wildcard VS prefix query

I wrote a query for get all clients whose name start with c. I am getting the same results with the two following queries:

#Q1 Query String and * wildcard
GET /client/_search
{
  "query": {
    "query_string": {
      "default_field": "Name.keyword",
      "query": "c*"
    }
  }
}


#Q2 prefix query
GET /client/_search
{
    "query": {
        "prefix": {
            "Name.keyword": {
                "value": "c"
            }
        }
    }
}

I guess the string query is less efficient as it is explained here:

Be aware that wildcard queries can use an enormous amount of memory and perform very badly — just think how many terms need to be queried to match the query string " a* b* c* ".

But could somebody tell me which one would be the best and more efficient for my approach?

Thanks.

More efficient speed wise is probably using edge ngram based analyzers.

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