There’s lots of academic research into ways one might get efficient ways of querying data in peer 2 peer networks. Found a couple papers, maybe something could be useful.
A Content-Addressable Network for Similarity Search in Metric Spaces
Resource Location in P2P Systems
Approximate Matching for Peer-to-Peer Overlays with Cubit
Magnolia: An Efficient and Lightweight Keyword-based Search Service in DHT based P2P Networks
Range-capable Distributed Hash Tables
Distributed Pattern Matching: A Key to Flexible and Efficient P2P Search