Reputation: 53
Sorry if this question is duplicated. Because I can't find any solution in my case. And sorry again, because I'm not good at English.
I'm trying to do a query on Elasticsearch using the query string:
{
query_string: {
fields: ["name^10"],
query: q
}
}
When I search with the keyword: coffee
=> The data will response. But when I search with the keyword: coffe
=> Nothing responded.
I want to match coffe
with coffee
in the the database. How can I do that?
Thanks for any help!
Upvotes: 1
Views: 112
Reputation: 217514
I suggest that you simply add an asterisk *
behind what the user is typing, like below, and that should achieve what you need:
{
query_string: {
fields: ["name^10"],
query: q + "*"
}
}
Upvotes: 2