2016-10-27 10 views
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" 
     ] 
    } 
} 

Я хочу найти в поле «информация», содержащее «Опера». У кого-нибудь есть идея?Определите, содержит ли объект с multifields строку

+0

Что случилось с ответами в http://stackoverflow.com/questions/40280393/finding-records-whose-object-contains-a-string-value? – chridam

ответ

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

Используйте текстовый индекс в Монго

 Смежные вопросы

  • Нет связанных вопросов^_^