What are the different options for search by date & tags using java & mongodb?
What are the steps that should I keep in mind for storing dates & tags into mongo using java?
There should be nothing special about searching for dates over any other type of data. You can use comparators so you can search across date ranges for example. Any tags that you want to query on will obviously benefit from indexing so you might want to setup a multiple single indexes on these fields.
http://cookbook.mongodb.org/patterns/date_range/
Another question here about storing tag data and querying on it which goes into more detail.
Datastore solution for tag search
Here is following code for select a value from the mongodb with java. Hope it will help you.
MongoClient mongo=new MongoClient("localhost",27017);
DB db = mongo.getDB("yourdb");
DBCollection coll=db.getCollection("yourtable");
BasicDBObject doc1=new BasicDBObject("email",email).
append("password", password);
DBCursor cours=coll.find(doc1);
if(cours.hasNext())
{
Map userdata=cours.next().toMap();
String username=userdata.get("username").toString();
String email1=userdata.get("email").toString();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With