visuellverstehen/t3meilisearch 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

visuellverstehen/t3meilisearch

Composer 安装命令:

composer require visuellverstehen/t3meilisearch

包简介

Extension to use Meilisearch as search.

README 文档

README

Preparation

Install Meilisearch yourself and make sure it is running. Also make sure you get the host address the server is reachable at, because you will need to configure the extension with that host. Otherwhise the extension cannot communicate with Meilisearch.

You will also need poppler-utils in order to index PDF files.

Installation

You can easily install the extension by using Composer:

composer require visuellverstehen/t3meilisearch

You may have to activate the extension in TYPO3 10.4, but since TYPO3 11.5 this is not required anymore.

Configuration

Log into TYPO3 as an admin or systemmaintainer and go to the settings module. Adjust the configure for t3meilisearch by setting the following fields:

Host

The address the Meilisearch server is reachable at. Optionaly including the port.

Example:

host=127.0.0.1:7700

Api

The key to authenticate the requests

Example:

apiKey=masterKey

Target page uid

The uid of the page where the main plugin lives (see Usage).

Example:

targetPid=56

Index

You can define a custom index by replacing the default value provided by t3meilisearch.

Example:

index=content

Thats pretty much it. The extension will then index pages and pdfs after they've been cached.

Usage

It is recommended to create a new page which can be hidden but not disabled. Insert the plugin »Searchform with results (Pi1)«. This will show a search form and also results if available.

You can also use the »Searchform (Pi2)« plugin to only display a search form wich will redirect to the target page configured in the settings module. You may insert this plugin hardcoded into e.g. the footer like this:

 <f:cObject typoscriptObjectPath="tt_content.list.20.t3meilisearch_pi2" />

Parsing content

By default everything inbetween <body></body> is beeing indexed. You can limit this by using two HTML comments just like indexed_search does. If you use multiple blocks, only the first will be index.

<!-- INDEX_CONTENT_START -->
<p>This content will be indexed</p>
<!-- INDEX_CONTENT_STOP -->

<p>This content will NOT be indexed</p>

Overriding templates

Because it's a basic TYPO3 extension build using Extbase, you can easily override the default templates and use you own. First configure an additional location for your templates and partials in your TypoScript for TYPO3 to look in:

plugin.tx_t3meilisearch {
    view {
        templateRootPaths {
            5000 = EXT:custom_extension/Resources/Private/Templates/
        }
        partialRootPaths {
            5000 = EXT:custom_extension/Resources/Private/Partials/
        }
    }
}

Next you can copy and modify the default templates the way you like. It is important to replicate the namespace structure, otherwhise TYPO3 cannot find the templates and partials.

Exclude pages from indexing

You can disable the »Include in Search« checkbox when editing a page to prevent a page beeing indexed.

Dropping the index

Want a clear start? You can simply execute a HTTP request to drop the index:

curl -H 'Authorization: Bearer yourApiKey' -X DELETE 'http://localhost:7700/indexes/documents'

A new index with the name configured in $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['t3meilisearch']['index'] will be created by t3meilisearch.

Removing specific documents

When there are old or unwanted results, you can easily remove the documents by executing a HTTP request. First find the id of the document by searching through the Meilisearch dashboard. Then you can execute the following request to delete a document:

curl -H 'Authorization: Bearer yourApiKey' -X DELETE 'http://localhost:7700/indexes/documents/documents/:id'

Add sorting option

By default t3meilisearch sorts the results by crdate (filetime for PDFs) descending. You can add simple sorting options by adding a select:

<select name="sorting">
    <option selected disabled>Sorting</option>
    <option value="crdate_desc" {f:if(condition: '{queryParams.sorting} === "crdate_desc" || !{queryParams.sorting}', then: 'selected')}>New first</option>
    <option value="crdate_asc" {f:if(condition: '{queryParams.sorting} === "crdate_asc"', then: 'selected')}>Old first</option>
</select>

It is important that the sorting value is passed by the query key called sorting. The value is composed by column-to-sort_direction-to-sort. If you want more complex sorting you have to do it yourself.

Add type filtering

By default we add a two type to documents. page for normale page content and pdf for PDF files. You could index records yourself and add custom types. Filtering for types can be achieved by passing a types parameter:

<input class="filter__input" type="checkbox" id="type-page" name="types[]" value="page" {f:if(condition: '"page" == {type}', then: 'checked') -> f:for(each: '{queryParams.types}', as: 'type')}>
<label class="filter__label" for="type-page">Allgemein</label>

Meilisearch has an easy API to use: docs.meilisearch.com

visuellverstehen/t3meilisearch 适用场景与选型建议

visuellverstehen/t3meilisearch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.12k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 visuellverstehen/t3meilisearch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 visuellverstehen/t3meilisearch 我们能提供哪些服务?
定制开发 / 二次开发

基于 visuellverstehen/t3meilisearch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 7
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-02-14