I have a mongo query with this match statement:

    {
        "$match": {
            "$and": [
                {
                    "gender": {
                        "$gte": 0.5
                    }
                }
            ]
        }
    }

and it works just fine. However if I write this:

    {
        "$match": {
            "$and": [
                {
                    "gender": {
                        "$gte": "{{minGender}}"
                    }
                }
            ]
        }
    }

And insert a 0.5 for the parameter minGender I get zero records back.
Why is it like that and can I fix this? Is this a bug?

Change your query to be: (remove the quotes)

{
        "$match": {
            "$and": [
                {
                    "gender": {
                        "$gte": {{minGender}}
                    }
                }
            ]
        }
    }

Because otherwise the value of minGender is treated as a string and hence returns no results.

If I do that, I get an error: bad string
image
Neither do single quotes work.

And if you ignore this marker and just run the query?

Then no error is shown, but also no data appears.