Searching by part url

I have two indices - one contains "document" objects with _id=<url of the document>, e.g. http://site/folder/document_name.doc ; the other contains "folder" objects with _id=<url of the folder>, e.g. http://site/folder

In my node.js script I need to match documents to folders, i.e. I search for all folder urls, and then for each of them I search for all documents which urls start with the folder url

I can't seem to be able to construct the right query that will return all documents which _id starts with http://site/folder

Any ideas?