ZombieNinja,
As far as I understand, you will have to extend the protocol to do that. Or even better, modify aMule or develop a pluggin, so that only your mod is database query aware.
I kinda agree with lfroen, what you need is a distributed database. What is the gain of having p2p + distributed database intermixed? If you are searching for a specific part of the database, it is more efficient to transfer only that part. Like lfroen said, ed2k protocol goal is to correctly transfer files.
It is a little difficult to point you the exact places in the source code. You will probably want to look at the SharedFilesList and DownloadQueue. The code is big, and things are not quite well distributed...
Anyway, good luck! Cheers!