Skip to content

Commit f797beb

Browse files
committed
feat: add helper parity APIs and advanced query builder clauses
1 parent 65b31ad commit f797beb

10 files changed

Lines changed: 1145 additions & 72 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
* Hardened runtime validation for `SphinxQL`, `Facet`, `Helper`, and `Percolate` input contracts (fail-fast exceptions for invalid query-shape input)
77
* Standardized driver exception message prefixes for better diagnostics (`[mysqli][...]`, `[pdo][...]`)
88
* Expanded helper runtime API coverage (`SHOW WARNINGS`, `SHOW STATUS`, `SHOW INDEX STATUS`, `FLUSH RAMCHUNK`, `FLUSH RTINDEX`, `OPTIMIZE INDEX`, UDF lifecycle checks)
9+
* Added fluent boolean grouping APIs (`orWhere`, `whereOpen/whereClose`, `orHaving`, `havingOpen/havingClose`) and JOIN builders (`join`, `innerJoin`, `leftJoin`, `rightJoin`, `crossJoin`)
10+
* Added `orderByKnn()` and broader helper wrappers for operational and Manticore-oriented commands (`SHOW PROFILE/PLAN/THREADS/VERSION/PLUGINS`, table status/settings/indexes, flush/reload/kill, suggest family)
11+
* Added capability-aware runtime tests for optional engine features (`supportsCommand`, Buddy-gated checks)
912
* Added and stabilized Sphinx 3 compatibility coverage while preserving Sphinx 2 and Manticore test behavior
1013
* Migrated CI to GitHub Actions-only validation with strict composer metadata checks
1114
* Updated documentation and added a dedicated `MIGRATING-4.0.md` guide

README.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ This Query Builder has no dependencies except PHP 8.2 or later, `\MySQLi` extens
1616

1717
### Missing methods?
1818

19-
SphinxQL evolves very fast.
19+
SphinxQL and ManticoreQL evolve fast. This library provides fluent builders for
20+
core query composition and helper wrappers for common operational commands.
2021

21-
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.
22-
23-
If any feature is unreachable through this library, open a new issue or send a pull request.
22+
If any feature is still unreachable through this library, open an issue or send
23+
a pull request.
2424

2525
## Code Quality
2626

@@ -240,7 +240,8 @@ Will return an array with an `INT` as first member, the number of rows deleted.
240240
$sq->where('column', 'BETWEEN', array('value1', 'value2'));
241241
```
242242

243-
_It should be noted that `OR` and parenthesis are not supported and implemented in the SphinxQL dialect yet._
243+
You can compose grouped boolean filters with:
244+
`orWhere()`, `whereOpen()`, `orWhereOpen()`, and `whereClose()`.
244245

245246
#### MATCH
246247

@@ -297,6 +298,18 @@ Will return an array with an `INT` as first member, the number of rows deleted.
297298

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

301+
* __$sq->orderByKnn($field, $k, array $vector, $direction = 'ASC')__
302+
303+
`ORDER BY KNN($field, $k, $vector) [$direction]`
304+
305+
#### JOIN
306+
307+
* __$sq->join($table, $left, $operator, $right, $type = 'INNER')__
308+
* __$sq->innerJoin($table, $left, $operator, $right)__
309+
* __$sq->leftJoin($table, $left, $operator, $right)__
310+
* __$sq->rightJoin($table, $left, $operator, $right)__
311+
* __$sq->crossJoin($table)__
312+
300313
* __$sq->offset($offset)__
301314

302315
`LIMIT $offset, 9999999999999`
@@ -448,11 +461,27 @@ $result = (new SphinxQL($this->conn))
448461
* `(new Helper($conn))->showMeta() => 'SHOW META'`
449462
* `(new Helper($conn))->showWarnings() => 'SHOW WARNINGS'`
450463
* `(new Helper($conn))->showStatus() => 'SHOW STATUS'`
464+
* `(new Helper($conn))->showProfile() => 'SHOW PROFILE'`
465+
* `(new Helper($conn))->showPlan() => 'SHOW PLAN'`
466+
* `(new Helper($conn))->showThreads() => 'SHOW THREADS'`
467+
* `(new Helper($conn))->showVersion() => 'SHOW VERSION'`
468+
* `(new Helper($conn))->showPlugins() => 'SHOW PLUGINS'`
469+
* `(new Helper($conn))->showAgentStatus() => 'SHOW AGENT STATUS'`
470+
* `(new Helper($conn))->showScroll() => 'SHOW SCROLL'`
471+
* `(new Helper($conn))->showDatabases() => 'SHOW DATABASES'`
451472
* `(new Helper($conn))->showTables() => 'SHOW TABLES'`
452473
* `(new Helper($conn))->showVariables() => 'SHOW VARIABLES'`
474+
* `(new Helper($conn))->showCreateTable($table)`
475+
* `(new Helper($conn))->showTableStatus($table = null)`
476+
* `(new Helper($conn))->showTableSettings($table)`
477+
* `(new Helper($conn))->showTableIndexes($table)`
478+
* `(new Helper($conn))->showQueries()`
453479
* `(new Helper($conn))->setVariable($name, $value, $global = false)`
454480
* `(new Helper($conn))->callSnippets($data, $index, $query, $options = array())`
455481
* `(new Helper($conn))->callKeywords($text, $index, $hits = null)`
482+
* `(new Helper($conn))->callSuggest($text, $index, $options = array())`
483+
* `(new Helper($conn))->callQSuggest($text, $index, $options = array())`
484+
* `(new Helper($conn))->callAutocomplete($text, $index, $options = array())`
456485
* `(new Helper($conn))->describe($index)`
457486
* `(new Helper($conn))->createFunction($udf_name, $returns, $soname)`
458487
* `(new Helper($conn))->dropFunction($udf_name)`
@@ -461,6 +490,11 @@ $result = (new SphinxQL($this->conn))
461490
* `(new Helper($conn))->optimizeIndex($index)`
462491
* `(new Helper($conn))->showIndexStatus($index)`
463492
* `(new Helper($conn))->flushRamchunk($index)`
493+
* `(new Helper($conn))->flushAttributes()`
494+
* `(new Helper($conn))->flushHostnames()`
495+
* `(new Helper($conn))->flushLogs()`
496+
* `(new Helper($conn))->reloadPlugins()`
497+
* `(new Helper($conn))->kill($queryId)`
464498

465499
### Percolate
466500
The `Percolate` class provides methods for the "Percolate query" feature of Manticore Search.

docs/helper.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,27 @@ Available Methods
2222
- ``showMeta()``
2323
- ``showWarnings()``
2424
- ``showStatus()``
25+
- ``showProfile()``
26+
- ``showPlan()``
27+
- ``showThreads()``
28+
- ``showVersion()``
29+
- ``showPlugins()``
30+
- ``showAgentStatus()``
31+
- ``showScroll()``
32+
- ``showDatabases()``
2533
- ``showTables($index)``
2634
- ``showVariables()``
35+
- ``showCreateTable($table)``
36+
- ``showTableStatus($table = null)``
37+
- ``showTableSettings($table)``
38+
- ``showTableIndexes($table)``
39+
- ``showQueries()``
2740
- ``setVariable($name, $value, $global = false)``
2841
- ``callSnippets($data, $index, $query, array $options = array())``
2942
- ``callKeywords($text, $index, $hits = null)``
43+
- ``callSuggest($text, $index, array $options = array())``
44+
- ``callQSuggest($text, $index, array $options = array())``
45+
- ``callAutocomplete($text, $index, array $options = array())``
3046
- ``describe($index)``
3147
- ``createFunction($udfName, $returns, $soName)``
3248
- ``dropFunction($udfName)``
@@ -36,6 +52,11 @@ Available Methods
3652
- ``optimizeIndex($index)``
3753
- ``showIndexStatus($index)``
3854
- ``flushRamchunk($index)``
55+
- ``flushAttributes()``
56+
- ``flushHostnames()``
57+
- ``flushLogs()``
58+
- ``reloadPlugins()``
59+
- ``kill($queryId)``
3960

4061
Validation Notes
4162
----------------

docs/query-builder.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,24 @@ The builder now validates critical query-shape input and throws
6262
- negative ``limit()`` / ``offset()``
6363
- invalid shapes for ``IN`` and ``BETWEEN`` filters
6464
- invalid ``facet()`` object type
65+
66+
Boolean Grouping and OR Filters
67+
-------------------------------
68+
69+
The builder supports grouped boolean filters for ``WHERE`` and ``HAVING``:
70+
71+
- ``orWhere()``
72+
- ``whereOpen()`` / ``orWhereOpen()`` / ``whereClose()``
73+
- ``orHaving()``
74+
- ``havingOpen()`` / ``orHavingOpen()`` / ``havingClose()``
75+
76+
JOIN and KNN Ordering
77+
---------------------
78+
79+
``SELECT`` queries support fluent joins:
80+
81+
- ``join()``, ``innerJoin()``, ``leftJoin()``, ``rightJoin()``, ``crossJoin()``
82+
83+
Vector-oriented ordering is available through:
84+
85+
- ``orderByKnn($field, $k, array $vector, $direction = 'ASC')``

0 commit comments

Comments
 (0)