protected function executeSearchCommand($entityClass, $commandOptions, $command, $optionKey)
    {
        if ($commandOptions instanceof ConditionsInterface) {
            $commandOptions = array(
                $optionKey => $this->formatConditions($entityClass, $commandOptions)
            ) + $commandOptions->getOptions();
        } elseif (!is_array($commandOptions)) {
            throw new \InvalidArgumentException('Expecting command options to be an array or instance of \Cpliakas\DynamoDb\ODM\KeyConditionsInterface');
        }

        $commandOptions['TableName'] = $this->getEntityTable($entityClass);
        $commandOptions += array(
            'ConsistentRead'         => $this->consistentRead,
            'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
        );

        $command = strtolower($command);
        $eventNamePrefix = 'dynamo_db.search.';

        $this->dispatchSearchRequestEvent($eventNamePrefix . 'pre_' . $command, $entityClass);
        $iterator = $this->dynamoDb->getIterator($command, $commandOptions);
        $this->dispatchSearchResponseEvent($eventNamePrefix . 'post_' . $command, $entityClass, $iterator);

        $entities = array();
        foreach ($iterator as $item) {
            $data = array();
            foreach ($item as $attribute => $value) {
                $data[$attribute] = current($value);
            }
            $entities[] = $this->entityFactory($entityClass, $data);
        }

        return $entities;
    }