I have this scenario, where the keyword is string, ex: customerName, which is string; as well as soCode, which is number.
First, I added a record into elasticsearch:
POST sales-orders/_doc/1234
{
customerName: "hello world", //<---- this is string
soCode: 5678 //<---- this is long
}
Then, I executed this:
GET sales-orders/_search
{
simple_query_string: {
query: 'hello*',
fields: ['customerName']
},
}
It successfully return hits. Then I execute the following:
GET sales-orders/_search
{
simple_query_string: {
query: 'hello*',
fields: ['customerName', 'soCode'] // <--- added soCode field.
},
}
When query, I got this error:
'Can only use prefix queries on keyword and text fields - not on [soCode] which is of type long'
I need the search to be able to return result, if the keyword is 'hello', or '5678'.
How to make this works?