I've found 2 approaches for Like-Search in Elasticsearch. Which one of those whould I choose? They seem to have the same behaviour. Or is there even a better one?
query_string:
"query": {
"bool": {
"filter": [
{
"query_string": {
"query": "*quick*",
"fields": [
"text"
]
}
}
]
}
}
wildcard:
"query": {
"bool": {
"must": [
{
"wildcard": {
"text": "*quick*"
}
}
]
}
}
SQL would be WHERE text like '%quick%'
I think, the difference is, that in the filter query no scores are calculated. In the documentation: In filter context, a query clause answers the question “Does this document match this query clause?” The answer is a simple Yes or No — no scores are calculated.
So i would use wildcard query. There you can use * for more characters and ? for only one character - depending on your needs. And here, the scores are calculated.