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

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

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

ddmaster/postgre-search-bundle

最新稳定版本:v1.0

Composer 安装命令:

composer require ddmaster/postgre-search-bundle

包简介

Tools to use full-text search PostgreSQL in Doctrine.

README 文档

README

Symfony2 bundle with tools full-text search PostgreSQL in Doctrine 2.

Added type 'tsvector' to be used in the mapping.

Added functions 'to_tsquery' and 'ts_rank' to be used in the DQL.

Step 1: Download PostgreSearchBundle using composer

Add PostgreSearchBundle in your composer.json:

{ "require": { "ddmaster/postgre-search-bundle": "dev-master" } }

Now tell composer to download the bundle by running the command:

$ php composer.phar update ddmaster/postgre-search-bundle

Composer will install the bundle to your project's vendor/ddmaster/postgre-search-bundle directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Ddmaster\PostgreSearchBundle\PostgreSearchBundle(), ); }

Step 3: Configure

Add in your config.yml:

# Doctrine Configuration doctrine: dbal: types: tsvector: Ddmaster\PostgreSearchBundle\Dbal\TsvectorType mapping_types: tsvector: tsvector orm: entity_managers: default: dql: string_functions: TSQUERY: Ddmaster\PostgreSearchBundle\DQL\TsqueryFunction TSRANK: Ddmaster\PostgreSearchBundle\DQL\TsrankFunction

Step 4: Mapping example

/**  * @var string  *  * @ORM\Column(name="search_fts", type="tsvector", nullable=true)  */ private $searchFts;

Step 5: Use in DQL

$searchQuery = 'family | history'; $em = $this->getDoctrine()->getManager(); $query = $em->createQuery( 'SELECT b.id, sum(TSRANK(b.searchFts, :searchQuery)) as rank   FROM DemoSearchBundle:Books b  WHERE TSQUERY( b.searchFts, :searchQuery ) = true  GROUP BY b.id  ORDER BY rank DESC') ->setParameter('searchQuery', $searchQuery) ; $result = $query->getArrayResult();

Result example:

Array ( [0] => Array ( [id] => 2 [rank] => 0.0607927 ) [1] => Array ( [id] => 3 [rank] => 0.0303964 ) )

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 1
  • Forks: 34
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固