Coder Social home page Coder Social logo

emiglobetrotting / kohana-sphinxql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mastercj/kohana-sphinxql

0.0 1.0 0.0 121 KB

Sphinx full-text search plugin for the Kohana V3 PHP framework using the SphinxQL interface

License: BSD 4-Clause "Original" or "Old" License

PHP 100.00%

kohana-sphinxql's Introduction

SphinxQL for Kohana
===================

Overview
--------

I wrote this because the other Kohana Sphinx plugin on github was reliant on
the pure PHP sphinx API and was discontinued. This plugin, as suggested by its
name, uses the SphinxQL interface. This means there's less dependancies as it
uses the built-in MySQL interface from PHP. _NOTE_: to use this, MySQL server
does _NOT_ need to be installed on the server. Only the MySQL client library for
PHP is required. As the MySQL interface in PHP is built as an extension, it's
faster than the regular Sphinx API as well, you can check the benchmarks out
here: http://sphinxsearch.com/blog/2010/04/25/sphinxapi-vs-sphinxql-benchmark/

Requirements
------------

Sphinx >= 0.9.9-rc2
PHP MySQL client library (php5-mysql in debian)

Installation
------------

1. `git submodule add git://github.com/MasterCJ/kohana-sphinxql.git modules/sphinxql`
2. Enable sphinxql in your bootstrap file
3. Use the SphinxQL class in your models

Usage
-----

	$sphinxql = new SphinxQL();
	$query = $sphinxql->new_query();
	$query->add_index('my_index')
		->add_field('field_name', 'alias')
		->add_field('another_field')
		->add_fields(array(array('field' => 'title', 'alias' => 'title_alias'), array('field' => 'user_id')))
		->search('some words to search for')
			// string (is given directly to sphinx, so can contain @field directives)
		->where('time', time()-3600, '>', false)
			// field, value, operator='=', quote=true
		->where_in('tags_i_need', array(1, 2, 3), 'all')
		->where_in('tags_i_do_not_want', array(4, 5, 6), 'none')
		->where_in('tags_i_would_like_one_of', array(7, 8, 9), 'any')
			// field, array values, type='any'
		->order('@weight', 'desc')
			// field, sort='desc'
		->offset(10)->limit(50)
			// defaults are 0 and 20, same as the sphinx defaults
		->option('max_query_time', '100')
			// option name, option value
		->group_by('field')
		->in_group_order_by('another_field', 'desc');
			// sphinx-specific, check their docs
	$result = $query->execute();

All the methods in SphinxQL_Query are chainable apart from execute(), so
technically this works fine (ugly as it is):

	$result = $sphinxql->new_query()->add_index('news')->order('time', 'desc')->execute();

Note that as with any Sphinx application, you'd need to then go and fetch the
actual data from a datastore somewhere using the IDs you just recieved.

u mad?
------

All the classes are documented, so there shouldn't be too much confusion. If
you do have questions, concerns, pent up rage, panties or all of the above,
drop me a line at [email protected] or file a bug report.

kohana-sphinxql's People

Contributors

mastercj avatar

Watchers

James Cloos 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.