J
J
jugger32021-09-20 15:46:34
Sphinx
jugger3, 2021-09-20 15:46:34

Why is the request not working?

I can not understand why the request does not work and how to fix it.

$query   = $pdo->prepare("
                   SELECT *, WEIGHT() AS weight
                   FROM {$index} WHERE MATCH (:search)
                   OPTION ranker=proximity_bm25, max_query_time=3, max_matches=300
                ");
                $query->bindValue(':search', $q, \PDO::PARAM_STR);
                $query->execute();
                     
                $rows = $query->fetchAll(\PDO::FETCH_ASSOC);


Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''(Company | *Company*)') OPTION ranker=prox' at line 2

What the final query looks like:
SELECT *, WEIGHT() AS weight FROM companyIndex WHERE MATCH (Company | *Company*) OPTION ranker=proximity_bm25, max_query_time=3, max_matches=300

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
ManticoreSearch, 2021-09-30
@ManticoreSearch

SELECT *, WEIGHT() AS weight FROM companyIndex WHERE MATCH (Company | *Company*) OPTION ranker=proximity_bm25, max_query_time=3, max_matches=300

Missing single quotes aroundКомпания | *Компания*

R
Rsa97, 2021-09-20
@Rsa97

https://dev.mysql.com/doc/refman/8.0/en/fulltext-s...

MATCH (col1,col2,...) AGAINST (expr [search_modifier])

There are no OPTIONs in MySQL.

P
Puma Thailand, 2021-09-21
@opium

So you send a request to the sphinx or a muscle?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question