RomanStruk/manticore-scout-engine

ManticoreEngine.php Line:120 - Hardcoded operator

ritey opened this issue · 3 comments

$search->filter($key, 'gte', $value);

Is there a reason why the operator is hardcoded? I'd like to be able to do an equals filter and this I think is preventing it?

Recommended use MySQL Engine, Support for richer filtering rules and advanced syntax, operators.

// config/manticore.php
return [
    'engine' => 'mysql', // Any value that is not equal to http-client
];
use RomanStruk\ManticoreScoutEngine\Mysql\Builder;

$field = 'id';
$value = 1;

$operator = '='; // Supports: =, >=, <=, like, >, <. Just like eloquent orm

Item::search($keywords, function (Builder $builder) use ($field, $operator, $value) {
    return $builder->where($field, $operator, $value);
    // whereIn ...
})

this is the default behavior and if you want to change you need to use the closure*

Item::search($keywords, function (\Manticoresearch\Index $index, $query) {
    return $index->search($query)->filter($key, '=', $value);
})

*did not test the example code