ciricihq/match-against-bundle

A search bundle for symfony, using MySQL FULLTEXT MATCH AGAINST

Installs: 2 982

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 6

Forks: 1

Open Issues: 1

Type:symfony-bundle

v1.0.0 2016-04-11 22:07 UTC

This package is auto-updated.

Last update: 2024-04-08 05:39:03 UTC


README

Based on https://gist.github.com/ZeBigDuck/1234419

Installing

composer require ciricihq/match-against-bundle

Usage

You must load the bundle provided config.yml in order to have the MATCH_AGAINST MySQL sentence

imports:
    - { resource: ../../src/Cirici/MatchAgainstBundle/Resources/config/config.yml }

Make a query:

  $qbuilder
      ->select('sti.foreignId')
      ->from('Cirici\MatchAgainstBundle\Entity\SearchTextIndex', 'sti')
      ->where('sti.model = :entityClass')
      ->andWhere('sti.field = :fieldName')
      // ->andWhere("MATCH_AGAINST(sti.content, :text 'IN NATURAL LANGUAGE MODE') > :score")
      ->andWhere("MATCH_AGAINST(sti.content, :text 'IN BOOLEAN MODE') > :score")
      ->setParameter('entityClass', $entity_class)
      ->setParameter('fieldName', $field_name)
      ->setParameter('text', $text)
      ->setParameter('score', $score)
  ;

License

Licensed under the GNU GPL 2.0 license. Check out the LICENSE file for more details.

Copyright 2015 © Cirici New Media