More information is required for a comprehensive answer, as you can customize the index/type/fields you search on etc., and create a more efficient query with additional parameters, as a wildcard query is very expensive, especially if only wildcarding one letter, and if you wildcarding at the end of a query string.
This is bad. I realize there is an excessive use of bolding, however it's hard to overstate how expensive wildcarding at the end of a querystring (and only one letter at that) is.
You can read about wildcard queries here.
As always with these questions it is good to mention search as you type functionality which is often the end goal, docs found here.
Below is a basic wildcard query that will fulfill the original function you are asking for.
POST /my_index/my_type/_search
{
"query": {
"wildcard": {
"name": {
"value": "B*"
}
}
}
}
This will return all documents with the name field starting with B.
Edit in response to comments:
If you are not interested in wildcard query, you may use the prefix query.
POST /my_index/my_type/_search
{
"query": {
"prefix": {
"name": "B"
}
}
}