diff --git a/src/lib/Query/Content/CriterionVisitor/ContentName.php b/src/lib/Query/Content/CriterionVisitor/ContentName.php new file mode 100644 index 00000000..2ad00145 --- /dev/null +++ b/src/lib/Query/Content/CriterionVisitor/ContentName.php @@ -0,0 +1,53 @@ +tokenizer = $tokenizer; + $this->parser = $parser; + $this->generator = $generator; + } + + public function canVisit(Criterion $criterion): bool + { + return $criterion instanceof Criterion\ContentNameCriterion + && $criterion->operator === Criterion\Operator::LIKE; + } + + public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + { + /** @var string $value */ + $value = $criterion->value; + $tokenSequence = $this->tokenizer->tokenize($value); + $syntaxTree = $this->parser->parse($tokenSequence); + + $queryString = $this->generator->generate($syntaxTree); + $searchField = 'meta_content__name_s'; + + return "{!edismax v='{$this->escapeQuote($queryString)}' 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..3079945b 100644 --- a/src/lib/Resources/config/container/solr/criterion_visitors.yml +++ b/src/lib/Resources/config/container/solr/criterion_visitors.yml @@ -236,6 +236,15 @@ services: tags: - {name: ibexa.search.solr.query.content.criterion.visitor} + Ibexa\Solr\Query\Content\CriterionVisitor\ContentName: + arguments: + $tokenizer: '@ibexa.solr.query.query_translator.galach.tokenizer' + $parser: '@ibexa.solr.query.query_translator.galach.parser' + $generator: '@ibexa.solr.query.query_translator.galach.generator.edismax' + 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: