I want to find if field_1 matches the beginning of field_2 within a document, using MongoDB Shell, and get the count of documents that matches and that does not match.
field_1 and field_2 are in the same document, and there are about 180k documents.
field_1: 2 numbers in string type (Ex. '10', '40', '15')
field_2: 8 numbers in string type (Ex. '10102020', '40204010')
Below is my code so far. It returns nothing.
db.coll_1.find().forEach(
function(x) {
db.coll_1.find({
field_1: {$regex: /^x.field_2*/}
})