Extract context search into resource module, cache context query