定制 onedrop/solr-extbase 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

onedrop/solr-extbase

Composer 安装命令:

composer require onedrop/solr-extbase

包简介

Extbase indexing addition to Apache Solr for TYPO3

README 文档

README

This integration gives you the easy possibility to use your extbase entities during solr indexation. Very often you want to access related records and don't want to clone your business logic into TypoScript to select related records.

What does it do?

  • Hooks into extbase repositories added/modified/deleted methods to update the record in solr`s indexQueue
  • Provides a way to switch the language when loading extbase records (needed for correct indexation)
  • Provides an interface that must be inherited by extbase models to be indexable

Usage

Assumption: You already have an indexQueue configured in solr as usual and mapped fields from TCA to the solr document.

Add IndexableEntity interface to the desired entity model

    <?php
    namespace Vendor\Extension\Domain\Model;
    
    class Foobar extends AbstractEntity implements \Onedrop\SolrExtbase\Domain\Model\IndexableEntity {
    
        /**
         * relatedEntities
         *
         * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Vendor\Extension\Domain\Model\RelatedEntity>
         */
        protected $relatedEntities = NULL;
        
        public function __construct() {
            $this->relatedEntities = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        }
        
        public function isIndexable() {
            // Just returning true will cause the model to be indexed according to its enableFields
            // and all other indexQueue constraints (additionalWhere etc.)
            return true;
        }
        
        public function addEntityFieldsToDocument(\Apache_Solr_Document $document) {
            foreach ($this->relatedEntites as $relatedEntity) {
                $document->addField('relatedUid_intM', $relatedEntity->getUid());
            }
            return $document;
        }

The method addEntityFieldsToDocument is processed after the document has been generated by the usual solr indexer using the TypoScript configuration. Therefore you can add new fields or overwrite fields using the setField method.

As you might have some constraints in your business logic that makes the models visible for search, you can modify the method isIndexable to match your custom constraints. If the method evaluates to false the model will not be indexed (not even the basic fields configured in TypoScript).

Modify solr configuration to use the extbase indexer

plugin.tx_solr.index.queue {

    myIndexQueue = 1
    myIndexQueue {
        table = tx_news_domain_model_news
        indexer = Onedrop\SolrExtbase\IndexQueue\EntityIndexer
        repository = Vendor\Extension\Domain\Repository\FoobarRepository
        
        fields {
            title = title
            # ... more fields
        }
    }
}

You must set the indexer of the indexQueue and the repository that will be used to load the model using findByUid.

Documentation and Support

Contributions

Feel free to give us a pull request.

Onedrop Solutions GmbH & Co. KG

统计信息

  • 总下载量: 132
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2016-03-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固