I just run a simple wildcard query on my elasticsearch server.
My query is;
GET calls-*/_search
{
"query": {
"bool": {
"filter": [
{
"bool": {
"should": [
{
"query_string": {
"default_field": "foo.number",
"query": "*16922*"
}
}
]
}
}
]
}
}
}
The error response looks like this;
Can only use wildcard queries on keyword, text, and wildcard fields - not on [foo.number] which is of type [long]
when I check the index info I saw number type is long
. If I switch to text
from long
everything worked as expected. This answer says exact same thing.
"number": {
"type": "long",
"ignore_malformed": false,
"coerce": true
},
But I can't change the number type because the code will ship to the prod server and I can't modify any prod elastic index.
So how can I run my wildcard queries without any errors? If the only way is the modifying the index (switch text
from the long
), can I replace wildcard queries with another method?