private function formatQueryElementDotted($key, $value, EntityMetadata $metadata, Store $store)
    {
        if (false === stripos($key, '.')) {
            return;
        }

        $parts = explode('.', $key);
        $root = array_shift($parts);
        if (false === $metadata->hasRelationship($root)) {
            // Nothing to format. Allow the dotted field to pass normally.
            return [$key, $value];
        }
        $hasIndex = is_numeric($parts[0]);

        if (true === $hasIndex) {
            $subKey = isset($parts[1]) ? $parts[1] : 'id';
        } else {
            $subKey = $parts[0];
        }

        if ($this->isIdentifierField($subKey)) {
            // Handle like a regular relationship
            list($key, $value) = $this->formatQueryElementRel($root, $value, $metadata, $store);
            $key = (true === $hasIndex) ? sprintf('%s.%s', $key, $parts[0]) : $key;
            return [$key, $value];
        }

        if ($this->isTypeField($subKey)) {
            // Handle as a model type field.
            list($key, $value) = $this->formatQueryElementRoot($subKey, $value, $metadata);
            $key = (true === $hasIndex) ? sprintf('%s.%s.%s', $root, $parts[0], $key) : sprintf('%s.%s', $root, $key);
            return [$key, $value];
        }
        return [$key, $value];
    }