def index(self, _id, hit):
        """ Queue one document for indexing. """

        if not self.connected:
            self.connect()

        # https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
        self.buffer.append('{"index":{"_id":"%s"}}\n%s\n' % (
            _id,
            json.dumps(hit)  # pylint: disable=no-member
        ))

        if len(self.buffer) >= self.batch_size:
            self.flush()