yf_search_driver_manticore classManticore Search over SphinxQL: the sphinxsearch driver plus CREATE TABLE / DROP TABLE / TRUNCATE TABLE (RT mode, no index in the config), HIGHLIGHT() (text fields are stored by default) and max_matches raised for deep pages. Same connection settings: Manticore is a drop-in for SPHINX_HOST.
| File | plugins/search/classes/search/yf_search_driver_manticore.class.php |
|---|---|
| Use | _class('search_driver_manticore', 'classes/search/') |
| Extends | yf_search_driver_sphinxsearch → yf_search_driver |
A site sets them in its config with $PROJECT_CONF['search_driver_manticore']['NAME'] = ...;
| Property | Default | Description |
|---|---|---|
$FIELD_TYPESarray<string,string> |
|
create_index() schema type => Manticore column type |
from yf_search_driver_sphinxsearch: $BULK_SIZE, $CONNECT_TIMEOUT, $HOST, $PARENT, $RECONNECT_TRIES, $SPHINX, $SUGGEST_LIMIT
from yf_search_driver: $DEF_LIMIT, $MAX_LIMIT, $MAX_WINDOW, $MAX_WORDS, $last_error
public function capabilities()
public function capabilities()
{
return array_replace(parent::capabilities(), ['ddl' => true]);
}
public function create_index($index, $schema = [])
CREATE TABLE; 'suggest' => true adds min_infix_len = 2 (suggest() and infix search).
$schema mixed ['fields' => [name => text|keyword|string|int|uint|float|bool|timestamp|json], 'suggest' => bool] public function create_index($index, $schema = [])
{
$schema = (array) $schema;
if ( ! $this->_is_valid_name($index)) {
return $this->_fail('bad index');
}
$columns = [];
foreach ((array) ($schema['fields'] ?? []) as $name => $type) {
$sql_type = is_string($type) ? ($this->FIELD_TYPES[strtolower($type)] ?? null) : null;
if ( ! $this->_is_valid_name($name) || $sql_type === null) {
return $this->_fail('bad schema field ' . ($this->_is_valid_name($name) ? $name : 'name'));
}
if (strtolower($name) !== 'id') {
$columns[] = $this->_quote_name($name) . ' ' . $sql_type;
}
}
if ( ! $columns) {
return $this->_fail('create_index() needs schema fields');
}
$sql = 'CREATE TABLE ' . $this->_quote_name($index) . ' (' . implode(', ', $columns) . ')';
if ( ! empty($schema['suggest'])) {
$sql .= " min_infix_len = '2'";
}
return $this->_write($sql);
}
public function drop_index($index)
public function drop_index($index)
{
return $this->_is_valid_name($index) ? $this->_write('DROP TABLE IF EXISTS ' . $this->_quote_name($index)) : $this->_fail('bad index');
}
public function truncate($index)
public function truncate($index)
{
return $this->_is_valid_name($index) ? $this->_write('TRUNCATE TABLE ' . $this->_quote_name($index)) : $this->_fail('bad index');
}
_ hooks and helpers; not routable as page actionspublic function __call($name, $args)
Catch missing method call.
public function __call($name, $args)
{
return main()->extend_call($this, $name, $args);
}
public function _highlight_sql($name, $pre, $post)
$name mixed validated field name$pre mixed marker from _highlight_markers(), not HTML public function _highlight_sql($name, $pre, $post)
{
return "HIGHLIGHT({before_match='" . $this->_literal($pre) . "', after_match='" . $this->_literal($post) . "', limit=0}, '" . $this->_quote_name($name) . "')";
}
public function _options($p, $words)
Manticore refuses offset + limit above max_matches (default 1000); Sphinx 3.9 has no such cap (probed with 1200 documents, LIMIT 1050, 3). MAX_WINDOW bounds the value.
$p mixed normalized paramsReturns string[]
public function _options($p, $words)
{
$options = parent::_options($p, $words);
$max = (int) $p['offset'] + (int) $p['limit'];
if ($max > 1000) {
$options[] = 'max_matches=' . $max;
}
return $options;
}
public function _tables_column()
public function _tables_column()
{
return 'Table';
}
from yf_search_driver: _doc_id(), _fail(), _highlight_html(), _highlight_markers(), _is_valid_name(), _name(), _normalize_filter(), _normalize_params(), _not_supported(), _without_id(), _words()
from yf_search_driver_sphinxsearch: _execute(), _filters_sql(), _init(), _literal(), _match_escape(), _quote_name(), _search_sql(), _transport(), _value(), _write(), add(), bulk(), connect(), delete(), escape(), index_exists(), is_ready(), raw(), search(), suggest(), update()