Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7418: Added CriterionVisitior for ContentNameCriterion #61

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/lib/Query/Content/CriterionVisitor/ContentName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Solr\Query\Content\CriterionVisitor;

use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Ibexa\Contracts\Solr\Query\CriterionVisitor;

/**
* @internal
*/
final class ContentName extends CriterionVisitor
{
public function canVisit(Criterion $criterion): bool
{
return $criterion instanceof Criterion\ContentName
&& $criterion->operator === Criterion\Operator::LIKE;
}

public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string
{
/** @var string $value */
$value = $criterion->value;
$searchField = 'meta_content__name_s';
alongosz marked this conversation as resolved.
Show resolved Hide resolved

return "{!edismax v='{$this->escapeQuote($value)}' qf='{$searchField}' uf=-*}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ services:
tags:
- {name: ibexa.search.solr.query.content.criterion.visitor}

Ibexa\Solr\Query\Content\CriterionVisitor\ContentName:
tags:
- {name: ibexa.search.solr.query.content.criterion.visitor}
- {name: ibexa.search.solr.query.location.criterion.visitor}

# Location search
Ibexa\Solr\Query\Location\CriterionVisitor\Ancestor:
tags:
Expand Down
Loading