承接 manugarciaes/easy-search-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

manugarciaes/easy-search-bundle

Composer 安装命令:

composer require manugarciaes/easy-search-bundle

包简介

Easy way to integration ElasticaBundle in your project with filters, aggregations, ...

README 文档

README

  1. You need Fos Elastica Bundle installed and configurated

  2. Add SearchBundle to your appKernel

    $bundles = array( [..] new manugarciaes\SearchBundle\SearchBundle(), );

  3. Change your Fos Elastica Bundle configuration, using as repository the next one

    persistence: [..] repository: manugarciaes\SearchBundle\Repository\SearchRepository

  4. Create a new service using the Easy Search Service like next example:

    • elastica_entity is the fos elastica entity in your configuration

    • search_string is the fields of your entity where you want to search

      EXAMPLE

      article.search: class: SearchBundle\Services\SearchService arguments: - "@fos_elastica.manager.orm" - %elastica_entity% - ['%search_string%']

If you want Add Filters

  1. create a new service with Easy Search Filter Object

     ## FILTER EXAMPLE
     elastic.search.filter.enabled:
       class: SearchBundle\Filter\ObjectFilter
       calls:
             - [setField, ['enabled']]
             - [setValue, [true]]
    

If you want a dynamic value you can use for example a service or something like this:

   - [setValue, ["@=service('request_stack').getMasterRequest.get('enabled')"]]

With this your filter change the value using the request

  1. Add this filter to your Search Service

    EXAMPLE

    article.search: class: SearchBundle\Services\SearchService arguments: - "@fos_elastica.manager.orm" - %elastica_entity% - ['%search_string%'] calls: - [addFilter, ['@elastic.search.filter.enabled']]

If you want add Aggregations

  1. Create a new service with Easy Search Aggregation Object

         ## example
         elastic.search.aggregation.categories:
           class: Elastica\Aggregation\Terms
           arguments:
             - %name%
           calls:
             - [setField, ['%category_field%']]
             - [setSize, [%category_size%]]
    
  2. Add this aggregation to your Easy Search Service

EXAMPLE

   article.search:
     class: SearchBundle\Services\SearchService
     arguments:
       - "@fos_elastica.manager.orm"
       - %elastica_entity%
       - ['%search_string%']
     calls:
       - [addAggregation, [@elastic.search.aggregation.categories]]

Now you can make a search using this service, example:

       $searchService = $this->get('article.search');
       $results = $searchService->search('hello');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固