Mongoose Text Search does not work

499 views
Skip to first unread message

Samuel Castro e Silva

unread,
Apr 10, 2014, 12:07:15 PM4/10/14
to mongoo...@googlegroups.com
Mongoose Text Search does not work and I can not solve the problem.

In my required: 
var TextSearch = require('mongoose-text-search');

My Shema:
var LocalSchema = new Schema({
    profile
: { type: Number, index: true, required: true },
    desiredJobs
: { type: [], index: true, fulltext: true, aggregate: true }
   
...
   
... });

Set plugin and index:
// give our schema text search capabilities
LocalSchema.plugin(TextSearch);

// add a text index to the tags array
LocalSchema.index({searchIdx: 'text'},{default_language: "portuguese"});


Model and exports:

var model = Mongoose.model('curriculum', LocalSchema);


var domain =  {
      textSearch
: function(term, options, cb) {
        model
.textSearch(term, options, cb);
   
}
};


module.exports = domain;


And finally:
  var options = {
              limit
: 10,
             language
: 'portuguese'


       
}


       
Curriculum.textSearch('qualificacoes',options, function (err, output) {
           
if (err){
                console
.log(err);
               
done();
           
}else{
                console
.log(output);
               
done();
           
}
   
});

node --version: v0.10.25
mongod --version v2.4.9
mongoose: 3.8.3


Nothing happens, I need help.

Thanks.

Regards.
Samuel Castro
Message has been deleted

Samuel Castro e Silva

unread,
Apr 22, 2014, 3:58:34 PM4/22/14
to mongoo...@googlegroups.com
Hi, The text search was already enabled. How we work in assync the status of connection was like 'connecting' and needed to be 'connected'. I solved call my callback function in connecting the Mongoose. ex: 

 Mongoose.connect(ServerConfig.db.host, function (error) {
           
            Schema.textSearch(...);
});

Thanks.. 


On 22 April 2014 16:24, Matej Salković <matej.s...@gmail.com> wrote:
Hi, just a quick check - are you running mongod with text-search enabled? Like this:

mongod --setParameter textSearchEnabled=true

--
Documentation - http://mongoosejs.com/
Plugins - http://plugins.mongoosejs.com/
Bug Reports - http://github.com/learnboost/mongoose
Production Examples - http://mongoosejs.tumblr.com/
StackOverflow - http://stackoverflow.com/questions/tagged/mongoose
Google Groups - https://groups.google.com/forum/?fromgroups#!forum/mongoose-orm
Twitter - https://twitter.com/mongoosejs
IRC - #mongoosejs
---
You received this message because you are subscribed to the Google Groups "Mongoose Node.JS ODM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Samuel Castro

Full Stack Developer

(37) 9110-8850

Valeri Karpov

unread,
May 14, 2014, 1:18:11 PM5/14/14
to mongoo...@googlegroups.com
Hi Samuel,

Glad you figured this out!

As a side note, text search was in beta for mongodb 2.4.x and its not recommended for production use. MongoDB 2.6.x now supports text search as a fully fledged query operator (shameless plug, I wrote about it here). 2.6.x style text search is fully supported in mongoose as of v3.8.9, so I recommend you give that a shot, because the new text search setup is very powerful :)

Cheers,
Val
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Samuel Castro e Silva

unread,
May 14, 2014, 4:12:30 PM5/14/14
to mongoo...@googlegroups.com
Thanks Val, I'm testing the 2.6 version. =)

Regards,
Samuel Castro


To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-orm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages