There exists a plugin for CouchDB called GeoCouch, which can be used to issue very basic geospatial queries against the database. With this plugin you can formulate queries based on locations and bounding boxes. For example: "give me all the restaurants in a certain (rectangular) area".
This is possible because GeoCouch uses a different indexing system than CouchDB internally.
Using this plugin we can represent the time interval we're interested in as a 1 dimensional bounding box around the document start dates.
view definition:
function(doc)
{
if(doc.begin && doc.end)
{
//start and end time as UNIX timestamps (seconds, not milliseconds)
var begin = Math.round(new Date(doc.begin).getTime()/1000);
var end = Math.round(new Date(doc.end).getTime()/1000);
emit(
{
type: "Point",
bbox : [0,start,0,end]
}, null
);
}
}
query:
http://localhost:5984/entries/_design/entries/_spatial/entriesByPeriod?bbox=0,1280998800,0,128100060