SphinxQL Query Builder generates SphinxQL, a SQL dialect, which is used to query the Sphinx search engine. (Composer Package)

Overview

Query Builder for SphinxQL

Build Status Latest Stable Version Latest Unstable Version Total Downloads

About

This is a SphinxQL Query Builder used to work with SphinxQL, a SQL dialect used with the Sphinx search engine and it's fork Manticore. It maps most of the functions listed in the SphinxQL reference and is generally faster than the available Sphinx API.

This Query Builder has no dependencies except PHP 7.1 or later, \MySQLi extension, PDO, and Sphinx/Manticore.

Missing methods?

SphinxQL evolves very fast.

Most of the new functions are static one liners like SHOW PLUGINS. We'll avoid trying to keep up with these methods, as they are easy to just call directly ((new SphinxQL($conn))->query($sql)->execute()). You're free to submit pull requests to support these methods.

If any feature is unreachable through this library, open a new issue or send a pull request.

Code Quality

The majority of the methods in the package have been unit tested.

The only methods that have not been fully tested are the Helpers, which are mostly simple shorthands for SQL strings.

How to Contribute

Pull Requests

  1. Fork the SphinxQL Query Builder repository
  2. Create a new branch for each feature or improvement
  3. Submit a pull request from each branch to the master branch

It is very important to separate new features or improvements into separate feature branches, and to send a pull request for each branch. This allows me to review and pull in new features or improvements individually.

Style Guide

All pull requests must adhere to the PSR-2 standard.

Unit Testing

All pull requests must be accompanied by passing unit tests and complete code coverage. The SphinxQL Query Builder uses phpunit for testing.

Learn about PHPUnit

Installation

This is a Composer package. You can install this package with the following command: composer require foolz/sphinxql-query-builder

Usage

The following examples will omit the namespace.

<?php
use Foolz\SphinxQL\SphinxQL;
use Foolz\SphinxQL\Drivers\Mysqli\Connection;

// create a SphinxQL Connection object to use with SphinxQL
$conn = new Connection();
$conn->setParams(array('host' => 'domain.tld', 'port' => 9306));

$query = (new SphinxQL($conn))->select('column_one', 'colume_two')
    ->from('index_ancient', 'index_main', 'index_delta')
    ->match('comment', 'my opinion is superior to yours')
    ->where('banned', '=', 1);

$result = $query->execute();

Drivers

We support the following database connection drivers:

  • Foolz\SphinxQL\Drivers\Mysqli\Connection
  • Foolz\SphinxQL\Drivers\Pdo\Connection

Connection

  • $conn = new Connection()

    Create a new Connection instance to be used with the following methods or SphinxQL class.

  • $conn->setParams($params = array('host' => '127.0.0.1', 'port' => 9306))

    Sets the connection parameters used to establish a connection to the server. Supported parameters: 'host', 'port', 'socket', 'options'.

  • $conn->query($query)

    Performs the query on the server. Returns a ResultSet object containing the query results.

More methods are available in the Connection class, but usually not necessary as these are handled automatically.

SphinxQL

  • new SphinxQL($conn)

    Creates a SphinxQL instance used for generating queries.

Bypass Query Escaping

Often, you would need to call and run SQL functions that shouldn't be escaped in the query. You can bypass the query escape by wrapping the query in an \Expression.

  • SphinxQL::expr($string)

    Returns the string without being escaped.

Query Escaping

There are cases when an input must be escaped in the SQL statement. The following functions are used to handle any escaping required for the query.

  • $sq->escape($value)

    Returns the escaped value. This is processed with the \MySQLi::real_escape_string() function.

  • $sq->quoteIdentifier($identifier)

    Adds backtick quotes to the identifier. For array elements, use $sq->quoteIdentifierArray($arr).

  • $sq->quote($value)

    Adds quotes to the value and escapes it. For array elements, use $sq->quoteArr($arr).

  • $sq->escapeMatch($value)

    Escapes the string to be used in MATCH.

  • $sq->halfEscapeMatch($value)

    Escapes the string to be used in MATCH. The following characters are allowed: -, |, and ".

    Refer to $sq->match() for more information.

SELECT

  • $sq = (new SphinxQL($conn))->select($column1, $column2, ...)->from($index1, $index2, ...)

    Begins a SELECT query statement. If no column is specified, the statement defaults to using *. Both $column1 and $index1 can be arrays.

INSERT, REPLACE

This will return an INT with the number of rows affected.

  • $sq = (new SphinxQL($conn))->insert()->into($index)

    Begins an INSERT.

  • $sq = (new SphinxQL($conn))->replace()->into($index)

    Begins an REPLACE.

  • $sq->set($associative_array)

    Inserts an associative array, with the keys as the columns and values as the value for the respective column.

  • $sq->value($column1, $value1)->value($column2, $value2)->value($column3, $value3)

    Sets the value of each column individually.

  • $sq->columns($column1, $column2, $column3)->values($value1, $value2, $value3)->values($value11, $value22, $value33)

    Allows the insertion of multiple arrays of values in the specified columns.

    Both $column1 and $index1 can be arrays.

UPDATE

This will return an INT with the number of rows affected.

  • $sq = (new SphinxQL($conn))->update($index)

    Begins an UPDATE.

  • $sq->value($column1, $value1)->value($column2, $value2)

    Updates the selected columns with the respective value.

  • $sq->set($associative_array)

    Inserts the associative array, where the keys are the columns and the respective values are the column values.

DELETE

Will return an array with an INT as first member, the number of rows deleted.

  • $sq = (new SphinxQL($conn))->delete()->from($index)->where(...)

    Begins a DELETE.

WHERE

  • $sq->where($column, $operator, $value)

    Standard WHERE, extended to work with Sphinx filters and full-text.

    <?php
    // WHERE `column` = 'value'
    $sq->where('column', 'value');
    
    // WHERE `column` = 'value'
    $sq->where('column', '=', 'value');
    
    // WHERE `column` >= 'value'
    $sq->where('column', '>=', 'value');
    
    // WHERE `column` IN ('value1', 'value2', 'value3')
    $sq->where('column', 'IN', array('value1', 'value2', 'value3'));
    
    // WHERE `column` NOT IN ('value1', 'value2', 'value3')
    $sq->where('column', 'NOT IN', array('value1', 'value2', 'value3'));
    
    // WHERE `column` BETWEEN 'value1' AND 'value2'
    // WHERE `example` BETWEEN 10 AND 100
    $sq->where('column', 'BETWEEN', array('value1', 'value2'));

    It should be noted that OR and parenthesis are not supported and implemented in the SphinxQL dialect yet.

MATCH

  • $sq->match($column, $value, $half = false)

    Search in full-text fields. Can be used multiple times in the same query. Column can be an array. Value can be an Expression to bypass escaping (and use your own custom solution).

    <?php
    $sq->match('title', 'Otoshimono')
        ->match('character', 'Nymph')
        ->match(array('hates', 'despises'), 'Oregano');

    By default, all inputs are escaped. The usage of SphinxQL::expr($value) is required to bypass the default escaping and quoting function.

    The $half argument, if set to true, will not escape and allow the usage of the following characters: -, |, ". If you plan to use this feature and expose it to public interfaces, it is recommended that you wrap the query in a try catch block as the character order may throw a query error.

    <?php
    use Foolz\SphinxQL\SphinxQL;
    
    try
    {
        $result = (new SphinxQL($conn))
            ->select()
            ->from('rt')
            ->match('title', 'Sora no || Otoshimono', true)
            ->match('title', SphinxQL::expr('"Otoshimono"/3'))
            ->match('loves', SphinxQL::expr(custom_escaping_fn('(you | me)')));
            ->execute();
    }
    catch (\Foolz\SphinxQL\DatabaseException $e)
    {
        // an error is thrown because two `|` one after the other aren't allowed
    }

GROUP, WITHIN GROUP, ORDER, OFFSET, LIMIT, OPTION

  • $sq->groupBy($column)

    GROUP BY $column

  • $sq->withinGroupOrderBy($column, $direction = null)

    WITHIN GROUP ORDER BY $column [$direction]

    Direction can be omitted with null, or be ASC or DESC case insensitive.

  • $sq->orderBy($column, $direction = null)

    ORDER BY $column [$direction]

    Direction can be omitted with null, or be ASC or DESC case insensitive.

  • $sq->offset($offset)

    LIMIT $offset, 9999999999999

    Set the offset. Since SphinxQL doesn't support the OFFSET keyword, LIMIT has been set at an extremely high number.

  • $sq->limit($limit)

    LIMIT $limit

  • $sq->limit($offset, $limit)

    LIMIT $offset, $limit

  • $sq->option($name, $value)

    OPTION $name = $value

    Set a SphinxQL option such as max_matches or reverse_scan for the query.

TRANSACTION

  • (new SphinxQL($conn))->transactionBegin()

    Begins a transaction.

  • (new SphinxQL($conn))->transactionCommit()

    Commits a transaction.

  • (new SphinxQL($conn))->transactionRollback()

    Rollbacks a transaction.

Executing and Compiling

  • $sq->execute()

    Compiles, executes, and returns a ResultSet object containing the query results.

  • $sq->executeBatch()

    Compiles, executes, and returns a MultiResultSet object containing the multi-query results.

  • $sq->compile()

    Compiles the query.

  • $sq->getCompiled()

    Returns the last query compiled.

  • $sq->getResult()

    Returns the ResultSet or MultiResultSet object, depending on whether single or multi-query have been executed last.

Multi-Query

  • $sq->enqueue(SphinxQL $next = null)

    Queues the query. If a $next is provided, $next is appended and returned, otherwise a new SphinxQL object is returned.

  • $sq->executeBatch()

    Returns a MultiResultSet object containing the multi-query results.

<?php
use Foolz\SphinxQL\SphinxQL;

$result = (new SphinxQL($this->conn))
    ->select()
    ->from('rt')
    ->match('title', 'sora')
    ->enqueue((new SphinxQL($this->conn))->query('SHOW META')) // this returns the object with SHOW META query
    ->enqueue() // this returns a new object
    ->select()
    ->from('rt')
    ->match('content', 'nymph')
    ->executeBatch();

$result will contain MultiResultSet object. Sequential calls to the $result->getNext() method allow you to get a ResultSet object containing the results of the next enqueued query.

Query results

ResultSet

Contains the results of the query execution.

  • $result->fetchAllAssoc()

    Fetches all result rows as an associative array.

  • $result->fetchAllNum()

    Fetches all result rows as a numeric array.

  • $result->fetchAssoc()

    Fetch a result row as an associative array.

  • $result->fetchNum()

    Fetch a result row as a numeric array.

  • $result->getAffectedRows()

    Returns the number of affected rows in the case of a DML query.

MultiResultSet

Contains the results of the multi-query execution.

  • $result->getNext()

    Returns a ResultSet object containing the results of the next query.

Helper

The Helper class contains useful methods that don't need "query building".

Remember to ->execute() to get a result.

  • Helper::pairsToAssoc($result)

    Takes the pairs from a SHOW command and returns an associative array key=>value

The following methods return a prepared SphinxQL object. You can also use ->enqueue($next_object):

<?php
use Foolz\SphinxQL\SphinxQL;

$result = (new SphinxQL($this->conn))
    ->select()
    ->from('rt')
    ->where('gid', 9003)
    ->enqueue((new Helper($this->conn))->showMeta()) // this returns the object with SHOW META query prepared
    ->enqueue() // this returns a new object
    ->select()
    ->from('rt')
    ->where('gid', 201)
    ->executeBatch();
  • (new Helper($conn))->showMeta() => 'SHOW META'
  • (new Helper($conn))->showWarnings() => 'SHOW WARNINGS'
  • (new Helper($conn))->showStatus() => 'SHOW STATUS'
  • (new Helper($conn))->showTables() => 'SHOW TABLES'
  • (new Helper($conn))->showVariables() => 'SHOW VARIABLES'
  • (new Helper($conn))->setVariable($name, $value, $global = false)
  • (new Helper($conn))->callSnippets($data, $index, $query, $options = array())
  • (new Helper($conn))->callKeywords($text, $index, $hits = null)
  • (new Helper($conn))->describe($index)
  • (new Helper($conn))->createFunction($udf_name, $returns, $soname)
  • (new Helper($conn))->dropFunction($udf_name)
  • (new Helper($conn))->attachIndex($disk_index, $rt_index)
  • (new Helper($conn))->flushRtIndex($index)
  • (new Helper($conn))->optimizeIndex($index)
  • (new Helper($conn))->showIndexStatus($index)
  • (new Helper($conn))->flushRamchunk($index)

Percolate

The Percolate class provides methods for the "Percolate query" feature of Manticore Search. For more information about percolate queries refer the Percolate Query documentation.

INSERT

The Percolate class provide a dedicated helper for inserting queries in a percolate index.

<?php
use Foolz\SphinxQL\Percolate;

$query = (new Percolate($conn))
     ->insert('full text query terms',false)      
     ->into('pq')                                              
     ->tags(['tag1','tag2'])                                  
     ->filter('price>3')                                      
     ->execute();
  • $pq = (new Percolate($conn))->insert($query,$noEscape)

    Begins an INSERT. A single query is allowed to be added per insert. By default, the query string is escaped. Optional second parameter $noEscape can be set to true for not applying the escape.

  • $pq->into($index)

    Set the percolate index for insert.

  • $pq->tags($tags)

    Set a list of tags per query. Accepts array of strings or string delimited by comma

  • $pq->filter($filter) Sets an attribute filtering string. The string must look the same as string of an WHERE attribute filters clause

  • $pq->execute()

    Execute the INSERT.

CALLPQ

Searches for stored queries that provide matching for input documents.

<?php
use Foolz\SphinxQL\Percolate;
$query = (new Percolate($conn))
     ->callPQ()
     ->from('pq')                                              
     ->documents(['multiple documents', 'go this way'])        
     ->options([                                               
           Percolate::OPTION_VERBOSE => 1,
           Percolate::OPTION_DOCS_JSON => 1
     ])
     ->execute();
  • $pq = (new Percolate($conn))->callPQ()

    Begins a CALL PQ

  • $pq->from($index)

    Set percolate index.

  • $pq->documents($docs)

    Set the incoming documents. $docs can be:

    • a single plain string (requires Percolate::OPTION_DOCS_JSON set to 0)
    • array of plain strings (requires Percolate::OPTION_DOCS_JSON set to 0)
    • a single JSON document
    • an array of JSON documents
    • a JSON object containing an array of JSON objects
  • $pq->options($options)

    Set options of CALL PQ. Refer the Manticore docs for more information about the CALL PQ parameters.

    • Percolate::OPTION_DOCS_JSON (as docs_json) default to 1 (docs are json objects). Needs to be set to 0 for plain string documents. Documents added as associative arrays will be converted to JSON when sending the query to Manticore.
    • Percolate::OPTION_VERBOSE (as verbose) more information is printed by following SHOW META, default is 0
    • Percolate::OPTION_QUERY (as query) returns all stored queries fields , default is 0
    • Percolate::OPTION_DOCS (as docs) provide result set as per document matched (instead of per query), default is 0
  • $pq->execute()

    Execute the CALL PQ.

Laravel

Laravel's dependency injection and realtime facades brings more convenience to SphinxQL Query Builder usage.

// Register connection:
use Foolz\SphinxQL\Drivers\ConnectionInterface;
use Foolz\SphinxQL\Drivers\Mysqli\Connection;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(ConnectionInterface::class, function ($app) {
            $conn = new Connection();
            $conn->setParams(['host' => 'domain.tld', 'port' => 9306]);
            return $conn;
        });
    }
}

// In another file:
use Facades\Foolz\SphinxQL\SphinxQL;

$result = SphinxQL::select('column_one', 'colume_two')
    ->from('index_ancient', 'index_main', 'index_delta')
    ->match('comment', 'my opinion is superior to yours')
    ->where('banned', '=', 1)
    ->execute();

Facade access also works with Helper and Percolate.

Comments
  • Resultset

    Resultset

    Create a Facet object to use in SphinxQL:

    $facet = Facet::create($conn)->facet('category')->orderByFunction('COUNT', '*', ASC)->limit(5,5);

    $sphinxQL->facet($facet); $facet2 = Facet::create($conn)->facet(array('type' => 'idType'))->by('idType')->orderByFunction('COUNT', array('*'), DESC);

    $sphinxQL->facet($facet2); $facet3 = Facet::create($conn)->facetFunction('INTERVAL, array('price',200,400,600,800)));

    $sphinxQL->facet($facet3);

    opened by vizzent 19
  • Iterating search results?

    Iterating search results?

    Hi, guys.

    I just actually have a question - is there a way to iterate the SphinxQL execute() results in a way you could do with MySQL PDO statement? The idea is to use a common ResultSet interface for MySQL and SphinxQL results in our app.

    Thanks, Igor

    opened by t1gor 16
  • excessive escaping

    excessive escaping

    I recieving from $_GET['subway'] :

    array(2) {
      [0]=>
      string(2) "17"
      [1]=>
      string(2) "64"
    }
    

    as result of query subway[0]=17&subway[1]=64

    then, I use:

    $query_data = $query_data->where('subway', 'IN', $_REQUEST['subway']);
    

    and have error:

    SELECT * FROM rt_dp_clinics WHERE subway IN (''17'',''64'')  ORDER BY nreplies DESC OPTION field_weights=(title=20, short=10, text=5);  /* error=index rt_dp_clinics: unsupported filter type '(filter-type-6)' on int column */
    

    Please, check type of variables while escaping it.

    opened by KarelWintersky 10
  • The function 'where'  do not work in sphinx RealTime indexer

    The function 'where' do not work in sphinx RealTime indexer

    I have a question,Here is some info : *SphinxQL Code: * $sphinxql->where('supid', 'IN', array(2750380,1204,3630044,3627779,3627880));

    Builded Query: select * from rt_opcom where supid in ('2750380', '1204', '3630044', '3627779', '3627880');

    Error: ERROR 1064 (42000): sphinxql: syntax error, unexpected QUOTED_STRING, expecting CONST_INT or '-' near ''2750380', '1204', '3630044', '3627779', '3627880')'

    Right Query: select * from rt_opcom where supid in (2750380, 1204, 3630044, 3627779, 3627880);

    Sphinx's conf file: rt_attr_uint = supid

    *_Sphinx version: *_Sphinx 2.2.9-id64-release

    The issue was product in function compileFilterCondition in file SphinxQL.php on line 517. But now, I havn't a good idea to solve it;

    Thank you!

    opened by youyoubao 10
  • All calls to execute are returning Result object rather than results array?

    All calls to execute are returning Result object rather than results array?

    I had queries working using Sphinx Querybuilder and when I called the execute function it was returning an array of results as expected. But suddenly whenever I call any execute I am getting a result object rather than the real results?

    The result object says num_rows found -- but doesn't give me the ids?

    If use SPHINXQL directly with mysql client from command line it returns results - so the query it is building is good, but it is not running when execute is called.

    I did notice it says [stat] => ▒#08S01unknown command (code=9) in the result object. But I can't figure out what is causing this.

    Here is program and output when run and the mysql output.

    root@e578707b156b:/www/coder.tns# cat t.php

    setParams(array('host' => 'sphinx', 'port' => 9306)); #print_r(SphinxQL::create($conn)->query('desc ctr_idx')->execute()); #print_r(SphinxQL::create($conn)->query('SHOW TABLES')->execute()); $stime = mktime(0,0,0,10,1,2008); $etime = mktime(0,0,0,11,1,2008) + (60*60*24); $sq = SphinxQL::create($conn)->select('id') ->from('ctr_idx') ->limit(8) ->where('content_date', 'BETWEEN', array($stime, $etime)) ->where('recip_state', 6) ; $result = $sq->execute(); print_r($result); print "COMPILED QUERY: " . $sq->getCompiled(); ?>

    root@e578707b156b:/www/coder.tns# php t.php Foolz\SphinxQL\Drivers\Mysqli\ResultSet Object ( [connection:protected] => Foolz\SphinxQL\Connection Object ( [internal_encoding:protected] => UTF-8 [connection_params:protected] => Array ( [host] => sphinx [port] => 9306 [socket] => )

            [connection:protected] => mysqli Object
                (
                    [affected_rows] => 8
                    [client_info] => mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
                    [client_version] => 50012
                    [connect_errno] => 0
                    [connect_error] =>
                    [errno] => 0
                    [error] =>
                    [error_list] => Array
                        (
                        )
    
                    [field_count] => 1
                    [host_info] => sphinx via TCP/IP
                    [info] =>
                    [insert_id] => 0
                    [server_info] => 2.2.11-id64-release (95ae9a6)
                    [server_version] => 20211
                    [stat] => ▒#08S01unknown command (code=9)
                    [sqlstate] => 00000
                    [protocol_version] => 10
                    [thread_id] => 1
                    [warning_count] => 0
                )
    
            [silence_connection_warning:protected] =>
        )
    
    [result:protected] => mysqli_result Object
        (
            [current_field] => 0
            [field_count] => 1
            [lengths] =>
            [num_rows] => 8
            [type] => 0
        )
    
    [num_rows:protected] => 8
    [cursor:protected] => 0
    [next_cursor:protected] => 0
    [affected_rows:protected] => 0
    [fields:protected] => Array
        (
            [0] => stdClass Object
                (
                    [name] => id
                    [orgname] => id
                    [table] =>
                    [orgtable] =>
                    [def] =>
                    [db] =>
                    [catalog] => def
                    [max_length] => 6
                    [length] => 20
                    [charsetnr] => 33
                    [flags] => 32768
                    [type] => 8
                    [decimals] => 0
                )
    
        )
    
    [stored:protected] =>
    [fetched:protected] =>
    [adapter:protected] => Foolz\SphinxQL\Drivers\Mysqli\ResultSetAdapter Object
        (
            [connection:protected] => Foolz\SphinxQL\Connection Object
                (
                    [internal_encoding:protected] => UTF-8
                    [connection_params:protected] => Array
                        (
                            [host] => sphinx
                            [port] => 9306
                            [socket] =>
                        )
    
                    [connection:protected] => mysqli Object
                        (
                            [affected_rows] => -1
                            [client_info] => mysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $
                            [client_version] => 50012
                            [connect_errno] => 0
                            [connect_error] =>
                            [errno] => 0
                            [error] =>
                            [error_list] => Array
                                (
                                )
    
                            [field_count] => 1
                            [host_info] => sphinx via TCP/IP
                            [info] =>
                            [insert_id] => 0
                            [server_info] => 2.2.11-id64-release (95ae9a6)
                            [server_version] => 20211
                            [stat] => ▒#08S01unknown command (code=9)
                            [sqlstate] => 00000
                            [protocol_version] => 10
                            [thread_id] => 1
                            [warning_count] => 0
                        )
    
                    [silence_connection_warning:protected] =>
                )
    
            [result:protected] => mysqli_result Object
                (
                    [current_field] => 0
                    [field_count] => 1
                    [lengths] =>
                    [num_rows] => 8
                    [type] => 0
                )
    
            [valid:protected] => 1
        )
    

    ) COMPILED QUERY: SELECT id FROM ctr_idx WHERE content_date BETWEEN 1222833600 AND 1225598400 AND recip_state = 6 LIMIT 0, 8

    root@e578707b156b:/www/coder.tns# mysql -uroot -P9306 -hsphinx Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 2.2.11-id64-release (95ae9a6)

    Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> SELECT id FROM ctr_idx WHERE content_date BETWEEN 1222833600 AND 1225598400 AND recip_state = 6 LIMIT 0, 8; +--------+ | id | +--------+ | 128242 | | 128273 | | 128461 | | 128480 | | 128522 | | 128543 | | 128564 | | 128714 | +--------+ 8 rows in set (0.01 sec)

    opened by kmeekva 9
  • Request for MATCH_ANY mode

    Request for MATCH_ANY mode

    Please, implement ability to do MATCH_ANY mode without doing myself work like:

    if ($search_type == 'or') $descrsearchstr = '"' . $descrsearchstr . '"/1';

    if ($search_type == 'exact') $descrsearchstr = '^' . $descrsearchstr . '$';

    Proposed syntax: ->match_any(FIELD, DATA)

    Resulting query: MATCH('@field ( data_first_word | data_second_word | data_third_word | ... data_nth_word)') OPTION ranker = 'matchany'

    opened by yunasc 8
  • Getter/Setter for $where array

    Getter/Setter for $where array

    Useful for cases when we need to reset specific where conditions for faceting. I'm using this in production and I think i'm not the only one :) Thanks!

    opened by gdluck 7
  • cyrillic words in match()

    cyrillic words in match()

    hello. I can`t use cyrillic symbols in query, because mysqli connection not in UTF8 encoding;

    i created also question here http://stackoverflow.com/questions/28178379/mysqli-cant-set-encoding

    opened by versh23 7
  • where operator not work?

    where operator not work?

    i use code:

    $query = SphinxQL::create($conn)->select('*') ->from('index') ->match('field_value', $string) ->where('document_id', '!=', $filter) ->offset($start) ->limit($limit) ;

    in $filter i try delete element by document_id. but in the search results still displayed filter element. i get in result array:

    [0] => Array ( [id] => 2546 [document_id] => id document [field_value] => name document [document_published] => 1247652360 )

    opened by reimax 7
  • Percolate class for Manticore PQ feature

    Percolate class for Manticore PQ feature

    The PR contains a new class Percolate that:

    • perform CALL PQ
    • perform INSERT in a percolate index (this can be done with regular INSERT as well)

    The PQ is a new feature in Manticore that stored queries in a new index type - percolate - and can test documents if they match the stored queries.

    Also added a parameter for Helper::ShowTables to allow performing SHOW TABLES LIKE 'filter' (this is available in Sphinx too) . This is also needed to change in the Helper unit test for the show tables test, as for Percolate unit test a different .conf should be used to include a pq index as well. In Travis when Manticore is tested, it should be used the manticore.conf instead of sphinx.conf.

    opened by adriannuta 6
  • MATCH conditions are not compiled for DELETE queries

    MATCH conditions are not compiled for DELETE queries

    MATCH conditions are not compiled for DELETE queries

    $res = $query->delete()->from('rt')->match('field', 'value');

    // this will return DELETE FROM rt; (MATCH condition is lost) echo $res->compile()->getCompiled();

    accepting pr 
    opened by glukkkk 5
  • Is there a way to use username/password auth.?

    Is there a way to use username/password auth.?

    As far as I can see, the username and password parameters are always null and there seems to be no way to set them. Is this intentional or have I overlooked something?

    opened by Dgame 0
  • add DISTINCT in FACET for manticoresearch 4.x

    add DISTINCT in FACET for manticoresearch 4.x

    In manticoresearch you can return faceting without duplicates: https://manual.manticoresearch.com/Searching/Faceted_search#Faceting-by-aggregation-over-another-attribute

    opened by bbaronSVK 1
  • PHP 8.1 - Deprecated error in nginx logs

    PHP 8.1 - Deprecated error in nginx logs

    2022/01/21 16:58:57 [error] 3597#3597: *19956001 FastCGI sent in stderr: "PHP message: PHP Deprecated:  Return type of Foolz\SphinxQL\Drivers\ResultSet::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/REMOVED/vendor/foolz/sphinxql-query-builder/src/Drivers/ResultSet.php on line 90"
    
    opened by Fossil01 8
  • SphinxQL::quote() and quoteIdentifier() doesn't exist, but it's in the docs

    SphinxQL::quote() and quoteIdentifier() doesn't exist, but it's in the docs

    The doc says:

    • $sq->escape($value) ... But it seems it's in the Connection class, not in SphinxQL class
    • $sq->quoteIdentifier($identifier) ... But it seems this method doesn't exist

    Or i just got something wrong, in that case, im sorry

    opened by milanmadar 0
  • Change is_int to is_numeric.

    Change is_int to is_numeric.

    Lines of code: https://github.com/FoolCode/SphinxQL-Query-Builder/blob/master/src/Drivers/ConnectionBase.php#L107-L108

    Change

    } elseif (is_int($value)) {
        return (int) $value;
    }
    

    to

    } elseif (is_numeric($value)) {
        return (int) $value;
    }
    

    Values like "1" "2" are not processed although they are numbers.

    opened by igor-kozhevnikov-avg 0
Laravel search is package you can use it to make search query easy.

Laravel Search Installation First, install the package through Composer. composer require theamasoud/laravel-search or add this in your project's comp

Abdulrahman Masoud 6 Nov 2, 2022
Illusionist Searcher - Generates database queries based on search syntax

Illusionist Searcher Generates database queries based on search syntax. English | 中文 ✨ Features Zero configuration Compatible with laravel/scout and l

A doer with magic 2 Feb 24, 2022
A fully featured full text search engine written in PHP

TNTSearch TNTSearch is a full-text search (FTS) engine written entirely in PHP. A simple configuration allows you to add an amazing search experience

TNT Studio 2.9k Jan 8, 2023
A site search engine

THIS PACKAGE IS IN DEVELOPMENT, DO NOT USE IN PRODUCTION YET A site search engine This package can crawl your entire site and index it. Support us We

Spatie 219 Nov 8, 2022
A metadata catalog and search engine for geospatialized data

resto is a metadata catalog and a search engine dedicated to geospatialized data. Originally, it’s main purpose it to handle Earth Observation satellite imagery but it can be used to store any kind of metadata localized in time and space.

Jerome Gasperi 50 Nov 17, 2022
Query Builder for Elasticsearch

Query Builder for Elasticsearch

wangzhiqiang 5 Mar 2, 2022
Build and execute an Elasticsearch search query using a fluent PHP API

PACKAGE IN DEVELOPMENT, DO NOT USE YET Build and execute ElasticSearch queries using a fluent PHP API This package is a lightweight query builder for

Spatie 94 Dec 14, 2022
A search package for Laravel 5.

Search Package for Laravel 5 This package provides a unified API across a variety of different full text search services. It currently supports driver

Mark Manos 354 Nov 16, 2022
Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch

TNTSearch Driver for Laravel Scout - Laravel 5.3 - 8.0 This package makes it easy to add full text search support to your models with Laravel 5.3 to 8

TNT Studio 1k Dec 27, 2022
Laravel package to search through multiple Eloquent models. Supports sorting, pagination, scoped queries, eager load relationships and searching through single or multiple columns.

Laravel Cross Eloquent Search This Laravel package allows you to search through multiple Eloquent models. It supports sorting, pagination, scoped quer

Protone Media 844 Dec 25, 2022
Laravel Searchable - This package makes it easy to get structured search from a variety of sources

This package makes it easy to get structured search from a variety of sources. Here's an example where we search through some model

Spatie 1.1k Dec 31, 2022
A php trait to search laravel models

Searchable, a search trait for Laravel Searchable is a trait for Laravel 4.2+ and Laravel 5.0 that adds a simple search function to Eloquent Models. S

Nicolás López Jullian 2k Dec 27, 2022
Unmaintained: Laravel Searchy makes user driven searching easy with fuzzy search, basic string matching and more to come!

!! UNMAINTAINED !! This package is no longer maintained Please see Issue #117 Here are some links to alternatives that you may be able to use (I do no

Tom Lingham 533 Nov 25, 2022
Kirby docs search workflow for Alfred

Kirby Docs search workflow for Alfred 4 An ultra-fast Kirby Docs search workflow for Alfred 4 Installation Download the latest version Install the wor

Adam Kiss 30 Dec 29, 2022
A TYPO3 extension that integrates the Apache Solr search server with TYPO3 CMS. dkd Internet Service GmbH is developing the extension. Community contributions are welcome. See CONTRIBUTING.md for details.

Apache Solr for TYPO3 CMS A TYPO3 extension that integrates the Apache Solr enterprise search server with TYPO3 CMS. The extension has initially been

Apache Solr for TYPO3 126 Dec 7, 2022
Support search in flarum by sonic

flarum-sonic Support search by Sonic Install Sonic following this guide Install the extension: composer require ganuonglachanh/sonic Change info in a

null 18 Dec 21, 2022
Your personal job-search assistant

JobsToMail Your personal job-search assistant About JobsToMail is an open source web application that allows users to sign up to receive emails with j

JobApis 93 Nov 13, 2022
Search among multiple models with ElasticSearch and Laravel Scout

For PHP8 support use php8 branch For Laravel Framework < 6.0.0 use 3.x branch The package provides the perfect starting point to integrate ElasticSear

Sergey Shlyakhov 592 Dec 25, 2022
This is an open source demo of smart search feature implemented with Laravel and Selectize plugin

Laravel smart search implementation See demo at: http://demos.maxoffsky.com/shop-search/ Tutorial at: http://maxoffsky.com/code-blog/laravel-shop-tuto

Maksim Surguy 215 Sep 8, 2022