As a matter of fact, if a blockchain contains Merkle trees in every block, the data structure is more or less useless when it comes to searching for anything. This is because all hashes in the leaves of the Merkle tree are pseudo-random and therefore contain no usable information about the content of the block. The hash pointing to the previous block is useful for finding the block only and not the content that resides within the block.
So, what we can conclude here is for finding anything in the block, you need to perform a search in real-time.
However, to search anything within the blockchain, what you can do is traverse the blockchain once and build whatever additional data structures you need for finding content in the blockchain.
And on every query, you can use the pre-computed data structures to execute your query efficiently. And when blocks are added to the blockchain, update your pre-computed data structures.
Alternatively, you can influence the design of the blockchain and bake the required data structures to the blockchain from the start itself.
Want to make a career in Blockchain? Then enroll now in Blockchain Training by Intellipaat to get the perfect guidance.