add support for querying by appId

Change-Id: I6eb841fa6e953f837aaee5f7d73e93eb938bcd30