Skip to content

Instantly share code, notes, and snippets.

@bgvo
Last active August 29, 2015 14:11
Show Gist options
  • Save bgvo/bb9ac76968cad1c4eddd to your computer and use it in GitHub Desktop.
Save bgvo/bb9ac76968cad1c4eddd to your computer and use it in GitHub Desktop.
Search not working
TEST.JS
db.createCollection("test_index")
db.test_index.ensureIndex({"t.n":"text"})
var mydocs = [
{t: [{language: "english", n: "Mother 1"},{language: "spanish", n: "Madre 1"}]},
{t: [{language: "english", n: "Spreme 1"},{language: "spanish", n: "Edificio 1"}]}
]
db.test_index.insert(mydocs)
FROM CONSOLE
mongo localhost/test_index test.js
mongo test_index --eval 'printjson(db.test_index.findOne({$text: {$search: "Edificio"}}))'
RESULT
Borjas-MacBook-Pro:Development borjagvo$ mongo test_index --eval 'printjson(db.test_index.findOne({$text: {$search: "Edificio"}}))'
MongoDB shell version: 2.6.3
connecting to: test_index
null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment