public function indexBy($field)
    {
        $elements = $this->toArray();
        $this->clear();

        foreach ($elements as $element) {
            $this->set(
                $this->getFieldValue($element, $field),
                $element
            );
        }

        return $this;
    }