query « mongodb « Java Database Q&A





1. Polishing a mongodb query    stackoverflow.com

This is my current query: Using Java+mongoDB

    {
    BasicDBObject select = new BasicDBObject();
    select.put("info.name.fn", 1);

    DBCursor cursor = collection.find(new ...

2. Query embedded object with AND in mongodb    stackoverflow.com

Let's say there is:

{username : "tom1", address : { type : 0, year : 2001 }}
{username : "tom2", address : { type : 1, year : 2011 }}
{username : "tom3", address ...

3. MongoDB and Java driver: "ignore case" in query    stackoverflow.com

This is the code I'm using now, how do I add the "ignore case" attribute?

DBObject query = new BasicDBObject("prop", value);
Thanks

4. Querying Array Positions in MongoDB?    stackoverflow.com

I am using Java Driver for mongoDB. I have a document which contains, AlbumName, PreviewSize, ThumbSize, _id & Comments. PreviewSize & ThumbSize are array. I want to know how can i ...

5. MongoDB Equivalent to SQL query with Java Driver?    stackoverflow.com

I need to know how to use where in MongoDB queries using Java Driver.

SELECT COLUMN1, COLUMN2 WHERE COLOUM3 = 'KeyWord';
I have a key Name and its value, and i want to ...

6. Querying Morphia by Id    stackoverflow.com

I am using Morphia, the Pojo mapper for MongoDB, and I find difficult a task that in my view should be very simple: getting an object by id. I am able ...

7. Executing Mongo like Query (JSON)through Java    stackoverflow.com

I was wondering if there is a way to execute mongo like query directly through Java i.e. we give mongoDB like query as a String to a function in Java driver ...

8. Is there a cleaner way to do this Group Query in MongoDB from Groovy?    stackoverflow.com

I'm working on learning MongoDB. Language of choice for the current run at it is Groovy. Working on Group Queries by trying to answer the question of which pet is the most ...

9. How to query mongodb with “likeâ€? using the java api?    stackoverflow.com

this question is very similar to another post I basically want to use the mongodb version of the sql "like" '%m%' operator but in my situation i'm using the java api for ...





10. how to query mongodb using the $ne operator?    stackoverflow.com

i'm trying to do a $ne query in mongodb while using a regex, but it doesn't seem to work. the $ne (not equal) operator works fine when i don't use a ...

11. how to do a regex query on mongodb ObjectId field    stackoverflow.com

this is a bit tricky.. how do you do a regex query on the ObjectId field? i'm using the java api, so this is what i have so far

BasicDBObject q = new ...

12. How can I sort MongoDB query results by inner array size?    stackoverflow.com

I'm using Morphia to access mongoDB. I need to get a list of objects by the length of the inner array. Does any one have an idea how it can be done ...

13. How to do $or and "and" in mongo query for java driver?    stackoverflow.com

I want to do both AND and $or operations in a single mongo query. In mongo doc i have read mongo queries use AND by default. If i use only or $or, its ...

14. Not able to retrieve result from MongoDB    stackoverflow.com

private String pageElementUpdateProperty="{'user_id':'4d9fe87d1e327f0858000003','session_token':'84146295a9c0eb344f68510ac3645763','project_id':'4dac27b6156aec840d000007','page_id':'4db90554156aec180a000005','element_id':'4dec8964206b74b0dbe2236a',property:{style:{left:177.5,'top':153.5,'width':600,'height':800}}}";

DBCollection collPageElement = getServerDocument("PageElementCollection");
JSONObject jsonPageElementObject=JSONObject.fromObject(pageElementUpdateProperty);
PageElmentBean pageElementBean = (PageElmentBean) JSONObject.toBean(jsonPageElementObject,PageElmentBean.class);//fill the fields of Bean with JSON object..this i'm gettig correctly

BasicDBObject query = new BasicDBObject();
query.put("_id", pageElementBean.getElement_id());
query.put("page_id", pageElementBean.getPage_id());

DBCursor cur;
cur = collPageElement.find(query);
now i ...

15. What is Morphia or Java driver query in one to many relation?    stackoverflow.com

Suppose i have user collection and children collection. Assume I have a specific user and children (which is the many side of user) has a field status of type string. I want ...

16. MongoDB & Java Driver: Range Query    stackoverflow.com

I have a database of documents that all contain a numerical field X. I am attempting to write a query that returns a specified number of documents whose X fields ...





17. How to log all the queries in a log file in a java application with mongodb?    stackoverflow.com

I have a java application which use morphia to work with mongodb. I want to log all the queries sent to mongodb in a file, which I can analyze them ...

18. Java/MongoDB query by date    stackoverflow.com

I stored a value as a java.util.Date() in my collection, but when I query to get values between two specific dates, I end up getting values outside of the range. Here's ...

19. How to convert such sql query to mongodb query    stackoverflow.com

I need to execute such sql query on mongo(I mean mongodb query should be logically equal to the sql). So here is the SQL query:

SELECT * FROM table1 ALIAS1
WHERE 
 field1=1
AND
 ...

20. MapReduce in mongo with query from java    stackoverflow.com

I want to do a mapReduce in mongo with query. I make it succesfully in shell like this

db.betlog.mapReduce(m,r,{out:"temp", query: {"date": {$gte: new Date(2011, 7, 23), $lt: new Date(2011, 7, 24)}}})
So, I ...

21. Update multiple rows in MongoDB java Driver    stackoverflow.com

I want to update multiple rows in My Collection called "Users". Right now I am updating both the rows seperately but I want to do the same in one query. My current ...

22. Exists Query for multilple Document in Mongodb using java driver    stackoverflow.com

If we want to check that the record is exists in Collection or not, then there is an operator $exists in Mongodb. But if we want to know multiple records exists ...

23. How to update value of specific embedded document, inside an array, of a specific document in MongoDB?    stackoverflow.com

I have the following structure in my document:

{
  _id : ObjectId("43jh4j343j4j"), 
  array : [
            { 
 ...

24. How do I query MongoDB's ISODate field using Java querybuilder    stackoverflow.com

I would like to do a query based on a MongoDB ISODate field. However, I'm not sure how to serialize a Java Date object into the correct ISODate object, which can then be ...

25. retrieve large number of records with mongoDB in a reasonable time    stackoverflow.com

I'm using mongoDB to store a querylog and get some stats about it. Objects that I store in mongoDB contains the text of the query, the date, the user, if the user clicked ...