count documents by key