Reputation: 341
Is it possible in MongoDB to extract most popular words from certain field in collection's documents? I read MongoDb Text Search documentation, but i didn't find anything.
I am in the middle of migrating my database from PostgreSQL to MongoDB. In PostgreSQL i had full text index (pgsql tsearch) which i was using to function ts_stat to extract most popular words in stored articles. How to do that in MongoDB?
Upvotes: 2
Views: 1176
Reputation: 75
I am not sure if this is exactly what you need, but I just wrote a sample code for you, see if it helps. :)
var keys=db.collection.distinct('Key');
Array.max = function( array ){
return Math.max.apply( Math, array );
};
for (var i = 0; i < keys.length; i++) {
keyTrend[i]= db.collection.find({"Key":keys[i]}).count()
}
Array.max(keyTrend)
I have not tested the code, but hope it works. As mongodb is all manipulated with javascript, you can always seek help with javascript to suit your customized needs.
Upvotes: 1