kaliop/ezfindsearchenginebundle 问题修复 & 功能扩展

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

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

kaliop/ezfindsearchenginebundle

Composer 安装命令:

composer require kaliop/ezfindsearchenginebundle

包简介

Kaliop eZFind-Search-Engine Bundle

README 文档

README

This bundle introduces a wrapper around the legacy eZFind search engine, making it available to developers with the same search API available by default in eZ Publish 5.

Features

  • swap existing database-based content searches with solr-based searches by simply changing the name of one service used
  • supports most of the query criteria and sort clauses from the eZPublish kernel
  • allows to get back from searches either eZ5 Content objects or raw solr data (in both eZFind-decoded and SOLR-native format)
  • allows to sort by score
  • supports facetting
  • allows to use custom SOLR syntax for both query criteria and sort clauses
  • unlike the SolrSearchEngineBundle, does not overtake all existing content searches
  • optimized for speed of execution and memory usage (as much as we can without nuking eZFind)

Setup

Installation

You can install the bundle using Composer:

composer require kaliop/ezfindsearchenginebundle

and then enabling it in your kernel.

Configuration

The bundle comes fully configured by default. Here the complete list of parameters available with example values:

    ezfind_search_engine.search_settings.boost_functions:
        - 'recip(ms(NOW/HOUR,attr_publication_date_dt),4e-12,1000,2)'
    # default list of fields returned when *not* returning Contents
    ezfind_search_engine.search_settings.fields_to_return:
        - meta_name_t
        - meta_owner_name_t
        - meta_path_string_ms
        - meta_priority_si
        - meta_score_value:score # Score field needs to be renamed as it won't be passed from eZFind
    # in case you want to use an alternative 'legacy fetch function' to power the search service. The default is ezfind/search
    ezfind_search_engine.search_settings.legacy_function_handler.module_name: 'ezfind'
    ezfind_search_engine.search_settings.legacy_function_handler.function_name: 'search'

Usage

The simplest way to use this bundle is to simply swap the Search Service that you use for existing queries with the new one:

    ...

For more advanced features, you can swap the Query object with one of a more specific class. This allows you to set more query parameters, f.e. to speed up the execution of the query by disabling unneeded features

    ...

Facets

Currently the following FacetBuilders are implemented by the bundle:

use eZ\Publish\API\Repository\Values\Content\Query\FacetBuilder;
use Kaliop\EzFindSearchEngineBundle\API\Repository\Values\Content\Query\FacetBuilder as KaliopFacetBuilder;
 
$now = new DateTime();
$yearAgo = new DateTime();
$yearAgo->modify('-1 year');
 
$query->facetBuilders = [
    // Kaliop Facet Builders
    new KaliopFacetBuilder\FieldRangeFacetBuilder([
        'name' => 'Numeric field range facet',
        'fieldPath' => 'product/price',
        'start' => 100,
        'end' => 500,
        'gap' => 50,
        'limit' => 8,
    ]),
    new KaliopFacetBuilder\DateRangeFacetBuilder([
        'name' => 'Date range facet',
        'fieldPath' => 'article/publication_date',
        'start' => $yearAgo,
        'end' => $now,
        'gap' => new DateInterval('P1M'),
        'limit' => 12,
    ]),
    // Base eZ Facet Builders
    new FacetBuilder\FieldFacetBuilder([
        'name' => 'Simple field facet',
        'fieldPaths' => 'article/title',
        'limit' => 20,
    ]),
    new FacetBuilder\FieldFacetBuilder([
        'name' => 'Object relation(s) facet',
        'fieldPaths' => 'article/author/id',
        'limit' => 20,
    ]),
    new FacetBuilder\ContentTypeFacetBuilder([
        'name' => 'Content type facet',
    ]),
    new FacetBuilder\CriterionFacetBuilder([
        'name' => 'Criterion facet',
        'filter' => new Criterion\Field('article/title', Criterion\Operator::CONTAINS, 'new'),
    ]),
];

Extending the bundle

Tagged Services / Criteria

The bundle utilises a series of 'handlers' to convert the search Query into legacy search configuration to be sent to Solr.

You can add more custom handlers using tagged services, with the following tags:

ezfind_search_engine.content.criterion_handler.filter

These are supposed to convert criteria that will be added to the "filter" section of the eZFind call (or to the query string when sorting by score)

ezfind_search_engine.content.sort_clause_handler

These are supposed to convert sort clauses

Troubleshooting

...

FAQ

  • Is 'Location Search' implemented in this bundle? A: given the SOLR schema used by eZFind, it is not possible to implement 'Location Search' reliably unless you use no multi-located contents whatsoever. Sorry about that

  • What is the difference between this bundle and the 'SolrSearchEngineBundle' available since eZPublish 5? A1: this bundle uses the same SOLR schema as ezfind. It is thus 100% compatible with the Legacy kernel A2: this bundle does not overtake the standard Search service from the eZPublish repository. It is up to the developer to decide which queries to send to the database and which ones to send to SOLR.

  • Why do I see the same score for all results? A: when you are not sorting results by score, the bundle optimizes performances by using a pure 'filter query' for the Solr request (this should be good because Solr caches filters). This means that all search hits get the same score.

  • Is there any difference between using $query->filter and $query->query? A: when you are not sorting results by score, none. When you are sorting results by score, you should use for optimal performaces $query->query for all criteria that influence the scoring (eg. a search term), and $query->filter for all other criteria (eg limitations on content type, section, etc...)

  • I tried using the new search service in a command line script but I always get back no results A: there is a bug in the way the eZPublish legacy kernel is booted in command line scripts. We provide as courtesy an alternative implementation that can be activated by editing the services

Thanks

Special tahnks to SOkamoto (who got this all started), CRevillo, DClements, MIwaniak, SKlimaszewski

License Latest Stable Version Total Downloads

Scrutinizer Code Quality

kaliop/ezfindsearchenginebundle 适用场景与选型建议

kaliop/ezfindsearchenginebundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 96 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 01 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「solr」 「search」 「ezpublish」 「ezfind」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2018-01-01