Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongoose-text-search is not working #14

Open
jatinseth2007 opened this issue Apr 14, 2016 · 1 comment
Open

mongoose-text-search is not working #14

jatinseth2007 opened this issue Apr 14, 2016 · 1 comment

Comments

@jatinseth2007
Copy link

I have a already built old project on nodejs where I am using MongoDb to store data. Mongodb version is 2.4

The problem is I am running a text-search on a collection but it's never return anything which means console.log(arguments); never get print anything

It's to inform you guys that I am able to run db.socialposts.runCommand( "text", { search: "accessories",limit: 1 } ) on mongo terminal and getting results very fast

var options, search;

options = {
limit: 1
};

search = 'accessories';

console.log(search);

SocialPost.textSearch(search, options, function(err, out) {
console.log(arguments);
return true;
});

It's Schema is

var schema;
schema = new mongoose.Schema({
entity_id: {
type: mongoose.Schema.Types.ObjectId,
required: true
},
social_id: {
type: String,
required: true
},
type: {
type: String,
required: true
},
app: {
type: String,
required: true
},
date: {
type: Date,
required: true
},
url: {
type: String,
required: true
},
post: {
type: String
},
title: {
type: String
},
image: {
type: String
},
video: {
type: String
},
hashtags: [String]
}, {
strict: 'throw'
});

And Index is

schema.index({
type: 1,
social_id: 1
});

schema.index({
type: 1,
entity_id: 1,
date: 1
});

schema.index({
title: 'text',
post: 'text'
});

@jatinseth2007
Copy link
Author

I have put this issue on stackoverflow also

http://stackoverflow.com/questions/36617113/mongoose-text-search-is-not-working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant