indexer, rest: add support for ended_before

Change-Id: Id88324d78e5f0ef27f90006e491676855828c897