Wildcard search with space in the text

Wildcard search seems not working if a value contains space.
For example, if a value is "hello world" and if you do search hel* it does not return anything.

Below is the query that I used:

 {
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "hel*"
          }
        }
      ]
    }
  }
}

It works if I do hello* but anything that is partial string of hello is not working. Is there a way that can make it work if I search a substring of hello such as he*, hel*, hell*?

It's because you are using a match query I guess.
Try with a wildcard query.

I tried with wildcard search but it's same result

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

I updated the script.

Where?

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "name": "hel*"
          }
        }
      ]
    }
  }
}

I updated in the post but I pasted here as well. Basically what I am looking for with this script is that it should be able to search any value that contains hel*. If value contains a space such as hello world, it should return the value but currently it is not returning anything.

What should be the analyzer in order to search partial substring of a value that may or may not contain spaces?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

If I execute your script in Kibana it gives that the index does not exist or it returns no data as no data have been indexed.

So I can not reproduce your problem.

* , which can match zero or more characters, including an empty one (from es reference)

"space" is not kinds of characters or "empty one", i guess...

May be u can try this: regexp-query in ur query body

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