Cannot create index in MongoDB 2.4 -


my friend's app designed use mongodb indexes. fine while developing locally, once moved code hosting provider, code fails:

db.createindex('collections', {title:"text", description:"text"}, function(err, indexname) {     console.log("8. index name: " + indexname); }); 

the error message "index creation failed"

provider says because not upgrade mongodb 2.6, version 2.4 , have no plans upgrade. looked mongodb website, indexes section not mention indexes not available until 2.6. says 2.6 has features. what's going on here, wrong code or mongodb not supporting indexes until 2.6, how be, or doing wrong, option have fast search mongodb 2.4?

as lix said, createindex deprecated. should use ensureindex instead:

collection.ensureindex({title:"text", description:"text"}, function(err, indexname) {   //handle error , check index name }) 

please remember, compound index, not 2 seperate indexes created @ once

more info here: link
info indexes in nodejs (i assumue use nodejs, used callback:) link2

edit

there info in docs stating " in mongodb 2.4, need enable text search feature manually create text indexes , perform text search."
link , source: indexes


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -