sylius/search-bundle 问题修复 & 功能扩展

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

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

sylius/search-bundle

最新稳定版本:v0.19.0

Composer 安装命令:

composer require sylius/search-bundle

包简介

Product catalog for your Symfony2 applications.

README 文档

README

Search system for Symfony2 applications.

It supports search functionality for mysql and elastic search.

Usage:

Place the following snippets on a twig view and you are ready to go.

{% render controller('SyliusSearchBundle:Search:form', {'request':app.request}) %}

{% include 'SyliusSearchBundle::filter_form.html.twig' %}

If you want to use the search pragmatically there are currently 2 query types, string query and taxon query.

$finder = $this->get('sylius_search.finder')
            ->setTargetIndex('product') // target index searches in a specific type, if it's not set it searches in all types
            ->setFacetGroup('search_set') // configuration based, uses the relevant facet set, if not set it does not show facets
            ->find(new SearchStringQuery(...));

Taxon

$finder = $this->get('sylius_search.finder')
            ->setFacetGroup('categories_set')
            ->find(new TaxonQuery(...));

Basic configuration guidelines:

Form

form: 'SyliusSearchBundle::form.html.twig'

The actual form you want to use for performing a search. As long as the naming of the elements is the same you can define a new twig file with your own design.

Request method

The default value for both search and filter forms is GET but you can use post by adding the following snippet on the configuration

request_method: POST

Engine

engine: orm

Possible values: orm, elasticsearch

If orm is selected the search uses mysql as engine, if elasticsearch is selected if uses the elasticsearch search engine, which must be configured through the fos_elastica bundle. For documentation on fos_elastica please check the fos_elastica github page.

Query logger

By default query logger is disabled.

If you wish to using you need to add the following configuration parameters. Query logger currently supports orm for smaller websites and elasticsearch for one with higher transactions. In the future we need to introduce queue support.

query_logger:
    enabled: true
    engine: orm

Indexes

orm_indexes: # it is being used only when orm is selected as a driver
        product: # indentifier of an index
            class: Sylius\Component\Core\Model\Product # the corresponding model
            mappings: # appart from the id, the rest of the fields will be used to compile the searchable content
                id: ~
                name: ~
                description: ~

if elasticsearch is selected here is a sample configuration

fos_elastica:
     clients:
         elasticsearch:
            servers:
                - { host: 10.0.0.100, port: 9200, logger: true }
                - { host: 10.0.0.101, port: 9200, logger: true }
           #for clustering you need to define the logger because of the https://github.com/FriendsOfSymfony/FOSElasticaBundle/issues/543
     indexes:
         sylius:
             client: elasticsearch
             finder: ~
             settings:
                 analysis:
                     filter:
                         synonym:
                             type: synonym
                             synonyms: synonym.txt
                     analyzer:
                         my_analyzer:
                             filter: synonym
                             type: standard
                             tokenizer: standard
             types:
                 product:
                     mappings:
                         id: { type: integer, index: not_analyzed }
                         name: { type: string, analyzer: my_analyzer }
                         description: { type: string }
                         price: { type: integer }
                         shortDescription: { type: string }
                         slug: { type: string, index: not_analyzed }
                         translations:
                             type: nested
                             properties:
                                 locale: { type: string, index: not_analyzed }
                                 name: { type: string }
                                 metaKeywords: { type: string }
                                 metaDescription: { type: string }
                         variants:
                             type: nested
                             properties:
                                 code: { type: string }
                                 availableOn: { type: date, index: not_analyzed }
                                 availableUntil: { type: date }
                                 name: { type: string }
                                 onHand: { type: integer, index: not_analyzed }
                                 onHold: { type: integer, index: not_analyzed }
                         attributes:
                             type: nested
                             properties:
                                 value: { type: string }
                         channels: { type: string, index: not_analyzed }
                         taxons: { type: string, index: not_analyzed }
                         enabled: { type: boolean }

                     persistence:
                         driver: orm
                         model: Sylius\Component\Core\Model\Product
                         model_to_elastica_transformer:
                            service: sylius.search.transformers.model.product
                         provider: ~
                         listener: ~
                         finder: ~

                 search_log:
                    mappings:
                        search_term: ~
                        ip_address: ~

Filters

filters:
        search_filter: # the small drop down menu on the side of the search field
            enabled: true
            taxon: category # possible values are taxons codes (category, brand for sylius)
        facet_groups: # possible facet groups, you assign them in a finder object
            search_set:
                values: [taxons, price, made_of, color]
            categories_set:
                values: [price, made_of, color]
            all_set:
                values: [taxons, price, made_of]
        facets: # possible facets, as long as a model exposes attributes, options or getters with the given name, it will be used as a facet
            taxons:
                display_name: 'Basic categories'
                type: terms
                value: ~
            price:
                display_name: 'Available prices'
                type: range
                values:
                    - { from: 0, to: 2000}
                    - { from: 2001, to: 5000}
                    - { from: 5001, to: 10000}
            made_of:
                display_name: 'Material'
                type: terms
                value: ~
            color:
                display_name: 'Available colors'
                type: terms
                value: ~

Indexing data

After configuring the indexer properly you execute the following command to populate the appropriate engine:

app/console sylius:search:index

Sylius

Sylius - Modern ecommerce for Symfony2. Visit Sylius.org.

phpspec examples

$ composer install
$ bin/phpspec run -fpretty

behat examples for search bundle

$ composer install
$ /bin/behat --suite=search

Documentation

Documentation is available on docs.sylius.org.

Contributing

All informations about contributing to Sylius can be found on this page.

Mailing lists

Users

Questions? Feel free to ask on users mailing list.

Developers

To contribute and develop this bundle, use the developers mailing list.

Sylius twitter account

If you want to keep up with updates, follow the official Sylius account on twitter.

Bug tracking

This bundle uses GitHub issues. If you have found bug, please create an issue.

Versioning

Releases will be numbered with the format major.minor.patch.

And constructed with the following guidelines.

  • Breaking backwards compatibility bumps the major.
  • New additions without breaking backwards compatibility bumps the minor.
  • Bug fixes and misc changes bump the patch.

For more information on SemVer, please visit semver.org website. This versioning method is same for all Sylius bundles and applications.

MIT License

License can be found here.

Authors

The bundle was originally created by Argyrios Gounaris. See the list of contributors.

sylius/search-bundle 适用场景与选型建议

sylius/search-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.12k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2015 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 sylius/search-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-01-31