Skip to content

Conversation

mateuszdebinski
Copy link
Contributor

Question Answer
JIRA Ticket https://issues.ibexa.co/browse/IBX-10311
Versions v4.6, v5.0
Edition Headless+

After discussing this example, we came to an agreement that it should be changed as we do not support fulltext in this place. Instead, fulltext should be added via \Ibexa\Core\FieldType\MapLocation\SearchField::getIndexData

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date
  • Redirects cover removed/moved pages
  • Code samples are working
  • PHP code samples have been fixed with PHP CS fixer
  • Added link to this PR in relevant JIRA ticket or code PR

Copy link

Preview of modified files

Preview of modified Markdown:

@mateuszdebinski mateuszdebinski requested a review from adamwojs July 16, 2025 08:55
Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see that the build is failing with:

WARNING -  [macros] - ERROR # _Macro Rendering Error_

_File_: `search/extensibility/solr_document_field_mappers.md`

_FileNotFoundError_: [Errno 2] No such file or directory: '/home/runner/work/documentation-developer/documentation-developer/code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php'

Copy link

github-actions bot commented Aug 6, 2025

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/search/custom/config/field_mapper_services.yaml

docs/search/extensibility/solr_document_field_mappers.md@65:``` yaml
docs/search/extensibility/solr_document_field_mappers.md@66:[[= include_file('code_samples/search/custom/config/field_mapper_services.yaml') =]]
docs/search/extensibility/solr_document_field_mappers.md@67:```

001⫶services:

code_samples/search/custom/config/field_mapper_services.yaml

docs/search/extensibility/solr_document_field_mappers.md@65:``` yaml
docs/search/extensibility/solr_document_field_mappers.md@66:[[= include_file('code_samples/search/custom/config/field_mapper_services.yaml') =]]
docs/search/extensibility/solr_document_field_mappers.md@67:```

001⫶services:
002⫶    App\Search\Mapper\WebinarEventTitleFulltextFieldMapper:
002⫶    App\Search\FieldMapper\WebinarEventParentNameFieldMapper:
003⫶        arguments:
004⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Handler'
005⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
006⫶ tags:
007⫶ - {name: ibexa.search.solr.field.mapper.content}


code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php

003⫶        arguments:
004⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Handler'
005⫶ - '@Ibexa\Contracts\Core\Persistence\Content\Location\Handler'
006⫶ tags:
007⫶ - {name: ibexa.search.solr.field.mapper.content}


code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php


code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php

docs/search/extensibility/solr_document_field_mappers.md@59:```php
docs/search/extensibility/solr_document_field_mappers.md@59:```php
docs/search/extensibility/solr_document_field_mappers.md@60:[[= include_file('code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php') =]]
docs/search/extensibility/solr_document_field_mappers.md@60:[[= include_file('code_samples/search/custom/src/Search/FieldMapper/WebinarEventParentNameFieldMapper.php') =]]
docs/search/extensibility/solr_document_field_mappers.md@61:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶namespace App\Search\FieldMapper;
004⫶
005⫶use Ibexa\Contracts\Core\Persistence\Content;
006⫶use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler;
007⫶use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler;
008⫶use Ibexa\Contracts\Core\Search;
009⫶use Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper;
010⫶
docs/search/extensibility/solr_document_field_mappers.md@61:```

001⫶<?php declare(strict_types=1);
002⫶
003⫶namespace App\Search\FieldMapper;
004⫶
005⫶use Ibexa\Contracts\Core\Persistence\Content;
006⫶use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler;
007⫶use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler;
008⫶use Ibexa\Contracts\Core\Search;
009⫶use Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper;
010⫶
011⫶class WebinarEventTitleFulltextFieldMapper extends ContentFieldMapper
011⫶class WebinarEventParentNameFieldMapper extends ContentFieldMapper
012⫶{
013⫶ protected ContentHandler $contentHandler;
014⫶
015⫶ protected LocationHandler $locationHandler;
016⫶
017⫶ public function __construct(
018⫶ ContentHandler $contentHandler,
019⫶ LocationHandler $locationHandler
020⫶ ) {
021⫶ $this->contentHandler = $contentHandler;
022⫶ $this->locationHandler = $locationHandler;
023⫶ }
024⫶
012⫶{
013⫶ protected ContentHandler $contentHandler;
014⫶
015⫶ protected LocationHandler $locationHandler;
016⫶
017⫶ public function __construct(
018⫶ ContentHandler $contentHandler,
019⫶ LocationHandler $locationHandler
020⫶ ) {
021⫶ $this->contentHandler = $contentHandler;
022⫶ $this->locationHandler = $locationHandler;
023⫶ }
024⫶
025⫶    public function accept(Content $content)
025⫶    public function accept(Content $content): bool
026⫶    {
027⫶ // ContentType with ID 42 is webinar event
026⫶    {
027⫶ // ContentType with ID 42 is webinar event
028⫶        return $content->versionInfo->contentInfo->contentTypeId == 42;
028⫶        return $content->versionInfo->contentInfo->contentTypeId === 42;
029⫶    }
030⫶
029⫶    }
030⫶
031⫶    public function mapFields(Content $content)
032⫶ {
033⫶ $mainLocationId = $content->versionInfo->contentInfo->mainLocationId;
034⫶ $location = $this->locationHandler->load($mainLocationId);
035⫶ $parentLocation = $this->locationHandler->load($location->parentId);
036⫶ $parentContentInfo = $this->contentHandler->loadContentInfo($parentLocation->contentId);
037⫶
038⫶ return [
039⫶ new Search\Field(
040⫶ 'fulltext',
041⫶ $parentContentInfo->name,
042⫶ new Search\FieldType\FullTextField()
043⫶ ),
044⫶ ];
045⫶ }
046⫶}
031⫶    /**
032⫶ * @return \Ibexa\Contracts\Core\Search\Field[]
033⫶ */
034⫶ public function mapFields(Content $content): array
035⫶ {
036⫶ $mainLocationId = $content->versionInfo->contentInfo->mainLocationId;
037⫶ $location = $this->locationHandler->load($mainLocationId);
038⫶ $parentLocation = $this->locationHandler->load($location->parentId);
039⫶ $parentContentInfo = $this->contentHandler->loadContentInfo($parentLocation->contentId);
040⫶
041⫶ return [
042⫶ new Search\Field(
043⫶ 'parent_name',
044⫶ $parentContentInfo->name,
045⫶ new Search\FieldType\StringField()
046⫶ ),
047⫶ ];
048⫶ }
049⫶}


code_samples/search/custom/src/Search/FieldMapper/WebinarEventTitleFulltextFieldMapper.php


Download colorized diff

Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mnocon mnocon merged commit 073e600 into 5.0 Aug 6, 2025
6 of 7 checks passed
@mnocon mnocon deleted the IBX-10311-fix-example-of-field-mapper branch August 6, 2025 09:17
mnocon pushed a commit that referenced this pull request Aug 6, 2025
* IBX-10311: Changed example of field mapper

* PHP & JS CS Fixes

* Corrected FQCN

* Corrected filename

---------

Co-authored-by: Mateusz Dębiński <[email protected]>
Co-authored-by: mateuszdebinski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants