[ANN] Mongoosastic: Mongoose + Elastic Search

1,423 views
Skip to first unread message

James Carr

unread,
Jun 20, 2012, 11:26:01 AM6/20/12
to nod...@googlegroups.com, mongoo...@googlegroups.com
Hey All,

I just released a new mongoose plugin last night that allows mongoose models to be indexed in elasticsearch on save for full text searching. For now just about all of the Query DSL in elastic search (or at least as much as is supported by elastical) works.

Check it out and let me know of any improvements that can be made: http://jamescarr.github.com/mongoosastic/



Thanks,
James

Charlie

unread,
Jun 20, 2012, 12:19:33 PM6/20/12
to mongoo...@googlegroups.com, nod...@googlegroups.com
I've been integrating ElasticSearch into my app this week so this looks interesting.

It would be great if there was a way to also set boosts per field, alongside the es_indexed option.  In the model would be a great place to define this mapping anyway (http://www.elasticsearch.org/guide/reference/mapping/)

Will try it out this week, thanks

Charlie

unread,
Jun 20, 2012, 12:27:40 PM6/20/12
to mongoo...@googlegroups.com, nod...@googlegroups.com
Also, to avoid having to hydrate models would it be possible to include fields in the _source of the document, but not have them indexed/analyzed by elastic search?  This would keep the elasticsearch index smaller but allow you to return the document directly rather than have to query in MongoDB again.

What I've been doing is storing the most important parts of the documents in elasticsearch, and then creating a model with the available data before returning from the search method, e.g.:

User.statics.search = function(queryStr, cb) {
  elasticalClient.search({ query: queryStr }, function(err, results) {
    var users = results.hits.map(function(doc) {
      return new User(doc);
    });
    cb(null, users);
  });
});


On Wednesday, June 20, 2012 4:26:01 PM UTC+1, James Carr wrote:

James Carr

unread,
Jun 20, 2012, 12:51:37 PM6/20/12
to mongoo...@googlegroups.com

Great, this is why i wanted to announce this ASAP so I could get some feature requests. ;)

I'll add it to the issue tracker and get started.

Thanks,
James

--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en

Phill Rosen

unread,
Jun 20, 2012, 12:55:24 PM6/20/12
to mongoo...@googlegroups.com
Would be cool if a stream from es could update/insert to mongoose.

James Carr

unread,
Jun 20, 2012, 1:09:20 PM6/20/12
to mongoo...@googlegroups.com

Could you provide a use case or example?

I'm looking to add features but not sure how'd this would be used.

Thanks,
James

Phill Rosen

unread,
Jun 20, 2012, 1:45:40 PM6/20/12
to mongoo...@googlegroups.com

Aaron Heckmann

unread,
Jun 20, 2012, 5:02:21 PM6/20/12
to mongoo...@googlegroups.com, nod...@googlegroups.com
Very cool. Thanks for sharing.

--
http://mongoosejs.com
http://github.com/learnboost/mongoose
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en



--
Aaron



shawn wilson

unread,
Oct 3, 2012, 3:31:34 PM10/3/12
to mongoo...@googlegroups.com
months later, but yes i can provide a use case now. i want a back end "scraper" to take json and shove it into es. the only thing i really want in mongo are a few values from the structure, the resource it came from, and a timestamp. mongo never needs to see the majority of this data, and when i query it, i just want it passed along as maybe a 'meta: { <es data> }' object or some such.

i can hydrate the result to get the query done (i think). however, i'm thinking i'm going to have to write some pre or post hook to do the insert and didn't know whether there was a cleaner way in your plugin?

i found this thread first with the question which is why i'm posting here. however, i can submit an issue if that would be preferred.

Travis sturzl

unread,
Oct 9, 2014, 9:16:44 PM10/9/14
to mongoo...@googlegroups.com, phill...@gmail.com
Not at all, elasticSearch writes can fail, and if you request too many inserts into elasticSearch it will start dropping writes. You can also get stuck in the purgatory where the connection times out with elasticSearch, and you don't know what happens. This is not good, there's no transaction durability. Mongodb will try and assure rights. Its simply a much much more intelligent to persist data to mongodb first, then and only then index to elasticsearch. If mongodb write fails, it will tell you and you can therefore decide not to index into elasticsearch. Much like mongoosastic is already doing.

William Riley-Land

unread,
Oct 10, 2014, 11:49:05 AM10/10/14
to mongoo...@googlegroups.com
Out of curiosity, do you have any opinion using the mongo 2.6 text search vs ElasticSearch?

--
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.

Wyatt Benno

unread,
Jun 26, 2015, 8:55:15 PM6/26/15
to mongoo...@googlegroups.com
I just switched my app http://www.ayedeals.com from Mongo $text to Mongoosastic. Its saves a lot of RAM that would be used on indexing $text in mongo,
allowing us to use the RAM for other things. The algorithm in Elastic Search for full-text search works much better in my opinion. 

Great job on Mongoosastic!

2014年10月11日土曜日 0時49分05秒 UTC+9 William Riley-Land:
Reply all
Reply to author
Forward
0 new messages