CreateIndex is causing "Exceeded memory limit" error

We’re trying to add a index as follows on a field which won’t always have data:

db.customers.createIndex({ eligibilityId: 1 }, { partialFilterExpression: { eligibilityId: { $exists: true } } });
to a collection in a M50 cluster with 500K documents.

When running the script to perform this index created we get the following error and we’re not sure how to resolve it:

Error: command failed: {
	"operationTime" : Timestamp(1636570102, 1),
	"ok" : 0,
	"errmsg" : "Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in.",
	"code" : 16945,
	"codeName" : "Location16945",
	"$clusterTime" : {
		"clusterTime" : Timestamp(1636570102, 1),
		"signature" : {
			"hash" : BinData(0,"2Ud1T0j/gGO9a3WGk9FbUjeZG38="),
			"keyId" : NumberLong("6983333742001520642")
		}
	}

Currently the collection doesn’t have any documents with that field, eligibilityId.
Our use case is that we need to query customers by eligibilityId. Some customers will have that field, some won’t. But for those who do it will be unique.