I have a query below. I want get items between 4 and 6 so only a:1 should match because it has the value 5 in b.
> db.test.find({ b : { $gt : 4 }, b: {
Because you did not check the documentation.
See
http://www.mongodb.org/display/DOCS/Advanced+Queries
and check for "ranges" on the page.
Neither is your query syntax correct (compare against the example)
nor does your "why a:2" part of the question make any sense since 'a' is not involved in your query. If you want to search for a:1 then you have to include it in your query.
Keep in mind that all query clauses are AND combined by default unless you use the $or operator.