Is there any way that we can convert data type of a field while querying using filters. The scenario that I had is I have a document with a field
customData: {
"contactCustomFieldMapId":xxxx,
"contactId":xxxxx,
"customFieldId":45788,
"value":"1899",
"fieldInputTypeId":0
},
{
"contactCustomFieldMapId":xxxx,
"contactId":xxxxx,
"customFieldId":45732,
"value":"Meet me at noon",
"fieldInputTypeId":0
},
{
"contactCustomFieldMapId":xxxx,
"contactId":xxxxx,
"customFieldId":23233,
"value":"233589",
"fieldInputTypeId":0
}
In the above field the value property can be of any datatype(string, datatime, or number), where as I need to fetch data using range filters (greater than, less than). This range filter should be combined with a term filter I made a query using bool filter as
"filter": {
"and": {
"filters": [
{
"bool": {
"must": [
{
"and": {
"filters": [
{
"term": {
"customData.customFieldId": 45788
}
},
{
"range": {
"customData.value": {
"gt": "1000"
}
}
}
]
}
}
]
}
}
]
}
}
Unfortunately the query is fetching all the records with customData.customFieldId as 45788 (working similarly as exist filter).
Is there any way that I can combine both the term filter and range filter.