Some times we need to get the number of documents with a distinct/unique value. An example use case is in the classic blog example. Get the number of authors with at least one post. Get the number of distinct tags/categories You can use the following commands to get the answers for the above questions db.posts.distinct(‘author’).length
A complete guide to Integrating MongoDB with Elastic Search
After almost two weeks and several re-installs and fresh installs, I finally got to integrate mongodb and elastic search. Here is a step by step procedure on how to integrate them. If you follow this procedure carefully, it will prevent errors like Exception: java.lang.NoSuchMethodError: com.mongodb.Mongo.fsyncAndLock() { “error” : “IndexMissingException[[testmongo] missing]”, “status” : 404 } Follow