Add index and type support to the elasticsearch filter

Also added a protection against empty results while at it.