From 0be9b85a6649664240a3cbc62d2b4f0e9d2788e2 Mon Sep 17 00:00:00 2001 From: ciastektk Date: Wed, 17 Jan 2024 14:55:16 +0100 Subject: [PATCH] IBX-7418: Added CriterionVisitior for ContentName Criterion (#61) For more details see https://issues.ibexa.co/browse/IBX-7418 and https://github.com/ibexa/solr/pull/61 Key changes: * Implemented criterion visitor for ContentName Criterion --- .../Content/CriterionVisitor/ContentName.php | 33 +++++++++++++++++++ .../container/solr/criterion_visitors.yml | 5 +++ 2 files changed, 38 insertions(+) create mode 100644 src/lib/Query/Content/CriterionVisitor/ContentName.php diff --git a/src/lib/Query/Content/CriterionVisitor/ContentName.php b/src/lib/Query/Content/CriterionVisitor/ContentName.php new file mode 100644 index 00000000..71a94208 --- /dev/null +++ b/src/lib/Query/Content/CriterionVisitor/ContentName.php @@ -0,0 +1,33 @@ +operator === Criterion\Operator::LIKE; + } + + public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + { + /** @var string $value */ + $value = $criterion->value; + $searchField = 'meta_content__name_s'; + + return "{!edismax v='{$this->escapeQuote($value)}' qf='{$searchField}' uf=-*}"; + } +} diff --git a/src/lib/Resources/config/container/solr/criterion_visitors.yml b/src/lib/Resources/config/container/solr/criterion_visitors.yml index df8fc881..7ab6c403 100644 --- a/src/lib/Resources/config/container/solr/criterion_visitors.yml +++ b/src/lib/Resources/config/container/solr/criterion_visitors.yml @@ -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: