Creating an Index for date field in collection

So I am running the following query.

[{$project: {
 location: 1,
 day: {
  $dayOfMonth: '$timestamp'
 month: {
  $month: '$timestamp'
 year: {
  $year: '$timestamp'
}}, {$match: {
 month: 3,
 year: 2022

Which returns 1,273,385 documents. Which is a lot however each of these documents are really important to us, and we need to be able to put them on a Google Map as markers.

Anyway as you can see from the image below, the query has no index. How can I index the timestamp aka Date using MongoDB Compass?

Hello @Russell_Harrower Welcome to the MongoDB Developer Community forum!

One can create an index on the timestamp field. It may be possible to apply that index in your query. But, it depends upon the field data type - can you tell what the timestamp field datatype is?

You can use this to determine the type: