Hi!
I’m having a problem with an Search Index. I’m trying to do a search query filtering a range of dates, but it results into an empty array of results. The index is defined like this.
{
"mappings": {
"dynamic": false,
"fields": {
"country": {
"type": "string"
},
"item_unit_price": {
"type": "number"
},
"opportunity_id": {
"type": "string"
},
"opportunity_publish_date": {
"type": "date"
},
"opportunity_status": {
"type": "string"
},
"opportunity_type": {
"type": "string"
},
"original_description": {
"type": "string"
},
"summarize_description": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
}
And the search query is like this:
{
$search: {
index: 'better_match',
compound: {
must: [
{
text: {
query: itemName,
path: 'summarize_description',
},
},
],
mustNot: {
text: {
path: 'opportunity_status',
query: 'Cancelada',
},
},
filter: [
{
text: {
query: type,
path: 'opportunity_type',
},
},
{
text: {
query: country,
path: 'country',
},
},
{
range: {
path: 'opportunity_publish_date',
gte: sixMonthsAgo, //Date
lte: now, //Date
},
},
],
},
sort: defaultSort,
count: {
type: 'total',
},
},
}
Is there anything wrong with this query?
Thanks in advance!