private function getCategorySearchQuery($excludedCategories)
    {
        $categoryIds = array_diff(explode(',', $this->getValue()), $excludedCategories);
        $subQueries  = [];

        foreach ($categoryIds as $categoryId) {
            $subQuery = $this->getRule()->getCategorySearchQuery($categoryId, $excludedCategories);
            if ($subQuery !== null) {
                $subQueries[] = $subQuery;
            }
        }

        $query = null;

        if (count($subQueries) === 1) {
            $query = current($subQueries);
        } elseif (count($subQueries) > 1) {
            $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['should' => $subQueries]);
        }

        return $query;
    }