I need search query such that, the ad/product co-ordinates must be either pickUplocation or dropOffLocation and need to boost ads which are urgent that satisfied coordinate requirements.
My search query is as follows:
The problem with this query is that: It return urgent ad which are not even inside the mentioned co-ordinates
$search: {
index: 'ad-search',
compound: {
mustNot: [
{
equals: {
path: 'userId',
value: new mongoose.Types.ObjectId(userId),
},
},
{
equals: {
path: 'isVisible',
value: false,
},
},
],
should: [
{
geoWithin: {
circle: {
center: {
type: Lang.POINT,
coordinates,
},
radius: radiusToBeSearchedAround,
},
path: 'pickUpDetails.location',
},
},
{
geoWithin: {
circle: {
center: {
type: Lang.POINT,
coordinates,
},
radius: radiusToBeSearchedAround,
},
path: 'dropOffDetails.location',
},
},
{
equals: {
path: 'isUrgent',
value: true,
},
},
],
minimumShouldMatch: 1,
},
},