Filter In all fields exclude some fields

I have this query, I would like to search in all query but exclude some fields

let pipeline = [{
        $search: {
            index: "index",
            'compound': {
                'must': {
                    'text': {
                        'path': 'x',
                        'query': arg.x
                    }
                },
                'filter': {
                    text: {
                        query: arg.filterBy,
                        path: {
                           wildcard: '*'
                        }
                    }
                }
            }
        }
    },
    {
        $project: {
            
        }
    }
]

Hello, @Ibrahim_ALSURKHI! Welcome to the MongoDB community :wave:

To understand better your case, please provide:

  • Example document from your collection
  • The result you are expecting to get after running the aggregation

Would it not be as simple as:

{
    $project: { unwantedField1: 0, unwantedField2: 0 }
}