Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
$Match range of compound index key?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jonas  
View profile  
 More options Oct 12 2012, 11:47 am
From: Jonas <jo89...@gmail.com>
Date: Fri, 12 Oct 2012 08:47:22 -0700 (PDT)
Local: Fri, Oct 12 2012 11:47 am
Subject: $Match range of compound index key?

Hello.

I have documents with the following format:

time : {
"day": 5,
"month": 10,
"year": 2012,
"hour": 22,

}

If I have a compound index on {year:1,month:1,day:1,hour:1}

Can I find objects in a date range?

In other words

I want

  2011<=year<=2012

where year is 2011 (but not 2012), I also want
  4<=month

where year is 2012 (but not 2011), I also want
  month<=7

They can at least get it to sort like this using $sort. I want to return
objects where the index key is between a certain range using the
aggregation framework!

Thank you in advance!
/J


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Mikola  
View profile  
 More options Oct 12 2012, 5:11 pm
From: Jeremy Mikola <jmik...@gmail.com>
Date: Fri, 12 Oct 2012 14:11:40 -0700 (PDT)
Local: Fri, Oct 12 2012 5:11 pm
Subject: Re: $Match range of compound index key?

If you using the aggregation framework, it may be preferable to work with
an actual BSON Date and then use the date operators<http://docs.mongodb.org/manual/reference/aggregation/#date-operators> to
exact and project parts of the date as needed.

If you're dealing with individual fields for the data components, I can't
think of a simple query to handle that (without some deep $and/$or
nesting). It would be much simpler to work with a Date field, which can
easily be indexed, and then query between two ranges on that one field.
That would remove the need for a multi-key index and certainly prove more
efficient (storage and performance-wise).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas  
View profile  
 More options Oct 15 2012, 4:36 am
From: Jonas <jo89...@gmail.com>
Date: Mon, 15 Oct 2012 01:36:08 -0700 (PDT)
Local: Mon, Oct 15 2012 4:36 am
Subject: Re: $Match range of compound index key?

Thanks Jeremy for your reply.

The reason that I do not use BSON date is that it is *not local sensitive*.
See my previous topic on the issue:

https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/okVT...

Since sorting in this order is possible you'd think that you could do some
greater than/less than on compound indexes. If anyone else has some input
please share.

Otherwise I guess the way to go is to add another field that is a timestamp
that compensated for the current timezone as an index.

Den fredagen den 12:e oktober 2012 kl. 23:11:40 UTC+2 skrev Jeremy Mikola:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »