spinxsql combine match and filter

I use Manticore Search. Fork of Spinx. I'am trying to use Full text search. But problem in json fields. So I fond solutions via ANY()

ANY(client_user.login = "test" FOR client_user IN client_users)

It works great. But when I try to use it with common full text search - it's not work

PHP code like this

$client = new \Manticoresearch\Client($config);
$search = new \Manticoresearch\Search($client);
$search->setIndex('clients');
$search->expression('cond1', 'ANY(client_user.login = "'.$query.'" FOR client_user IN client_users)');
$bool = new \Manticoresearch\Query\BoolQuery();
$bool->should(new \Manticoresearch\Query\Equals('cond1', 1));
$bool->should(new \Manticoresearch\Query\QueryString($query.'*'));
$search->search($bool);
$results = $search->get();

print '<pre>'.print_r($search->getBody(), true).'</pre>';

Like query array:

Array
(
    [index] => clients
    [script_fields] => Array
        (
            [cond1] => Array
                (
                    [script] => Array
                        (
                            [inline] => ANY(client_user.login = "test" FOR client_user IN client_users)
                        )

                )

        )

    [query] => Array
        (
            [bool] => Array
                (
                    [should] => Array
                        (
                            [0] => Array
                                (
                                    [equals] => Array
                                        (
                                            [cond1] => 1
                                        )

                                )

                            [1] => Array
                                (
                                    [query_string] => test*
                                )

                        )

                )

        )

)

Response is empty.

If I use sql:

select login, name, ANY(client_user.login = 'test' FOR client_user IN client_users) as cond1 from clients where cond1 = 1 OR match('test*');

I have an error

ERROR 1064 (42000): sphinxql: syntax error, unexpected '(' near '('test*')'

Upvotes: 0

Views: 343

Answers (0)

Related Questions