0
{
    "_id" : ObjectId("5811b03d231d884982672ddd"),
    "person-name" : "Bell, Lee Phillip",
    "info" : {
        "trivia" : [
            "Mother-in-law of 'Colleen Bell (II)' (qv) and 'Maria Arena Bell' (qv).",
            "Mother of actress 'Lauralee Bell' (qv), writer/producer 'Bradley Bell (I)' (qv) and TV executive 'William J. Bell Jr.' (qv)."
        ],
        "birthnotes" : [
            "Chicago, Illinois, USA"
        ],
        "spouse" : [
            "'William J. Bell' (qv) (October 1954 - 29 April 2005) (his death); 3 children"
        ],
        "birthname" : [
            "Phillip, Lee"
        ]
    }
}

I want to find in the field "info" which contains "Opera". Does anyone have an idea?

chridam
  • 100,957
  • 23
  • 236
  • 235
zhelyu
  • 41
  • 1
  • 3
  • What happened to the answers in http://stackoverflow.com/questions/40280393/finding-records-whose-object-contains-a-string-value ? – chridam Oct 27 '16 at 11:43

1 Answers1

0
db.collection.ensureIndex({ "$**": "text" })
db.collection.find( { 
                      $text: { 
                               $search: "Opera",
                               $caseSensitive: true
                             }
                    }
);

Use the text index in mongo

gianlucatursi
  • 670
  • 5
  • 19
zhelyu
  • 41
  • 1
  • 3