Giter VIP home page Giter VIP logo

sphinxsearchbundle's Introduction

SphinxSearchBundle

Some SphinxSearch integration with Symfony for gigablah/sphinxphp and foolz/sphinxql-query-builder. Alt text

Version 0.1.* was released during Codewave's shipit day!

Installation

Install via composer:

composer require karolnet/sphinxbundle

Add to AppKernel.php

new \Ekiwok\SphinxBundle\EkiwokSphinxBundle()

QueryBuilder

You may register many connections. Example configuration is:

ekiwok_sphinx:
    connection:
        host: localhost
        port: 9306
        driver: pdo

Default connection with following configuration will always be created unless you provide alternative default configuration:

    host: localhost
    port: 9306
    driver: pdo

It means if you want to use pdo and you are running sphinx daemon on localhost on port 9306 you do not have to provide any configuration.

Examples of usage:

        $sphinx = $this->get('sphinx');
        $conn = $sphinx->getConnection();
        $recipes = $conn->createQueryBuilder()
                        ->select('id', 'title')
                        ->from('recipes')
                        ->match('title', 'chicken')
                        ->limit(100)
                        ->execute();
        $sphinx = $this->get('sphinx');
        $conn = $sphinx->getConnection();
        $recipes = $conn->query('SELECT id, title FROM recipes WHERE MATCH("(@title chicken)")');

For more please visit https://github.com/FoolCode/SphinxQL-Query-Builder

gigablah/sphinxphp

Fresh use

If you are just starting using sphinx in your project all you have to do is declare your default connection:

    sphinx.default.connection:
        class: Sphinx\SphinxClient
        calls: 
            - [setServer, ['127.0.0.1', 9312] ]

Next decorate it with data collector:

    sphinx.default:
        class: Ekiwok\SphinxBundle\Sphinx\SphinxDataCollector
        arguments: [@sphinx.default.connection, @sphinx_stats]

@sphinx_stats is service that provides data to profiler. You may implement your own provider by implementing: Ekiwok\SphinxBundle\Sphinx\SphinxDataCollector

Now use sphinx.default like Sphinx\SphinxClient.

$sphinxClient = $this->get('sphinx.default');

Replacing Sphinx\SphinxClient

Symfony 2.5+

If you are using Symfony 2.5+ you may be interested in service decoration: http://symfony.com/doc/current/components/dependency_injection/advanced.html#decorating-services

Replacing Sphinx\SphinxClient

If you have your SphinxClient registered for example as sphinx.default use little hack, change this service name to sphinx.default.connection and register SphinxDataCollector as sphinx.default. Because SphinxDataCollector extends SphinxClient it shoud have no side effects on your project:

    sphinx.default:
        class: Ekiwok\SphinxBundle\Sphinx\SphinxDataCollector
        arguments: [@sphinx.default.connection, @sphinx_stats]

You can always instantiate SphinxDataCollector manually (for example in situation when you don't have your SphinxClient managed by container)

    // $sphinxClient is instance of Sphinx\SphinxClient
    $sphinxStats = $this->get('sphinx_stats');
    $sphinxClient = new \Ekiwok\SphinxBundle\Sphinx\SphinxDataCollector($sphinxClient, $sphinxStats);

What does this bundle do?

Well, it shows fancy things and stuff in profiler and toolbar. Those things are now query calls and errors. So all it does is tracking calls of SphinxClient query method and measuring time of this method execution (yeah, it's not actuall query time).

Because SphinxClient uses binary protocol this bundle does not show real human readable queries that may be copied to sphinx cli. (Now =) Unfortunately, it shows just arguments (query, indexes and comment) passed to query method.

This bundle trakcs all errors that unfold during executing queries.

Authors

This bundle was originally developed by Piotr Kowalczyk

sphinxsearchbundle's People

Contributors

ekiwok avatar karolnet avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.