Z
Z
Zeraks2014-09-25 12:57:30
PHP
Zeraks, 2014-09-25 12:57:30

How to do a search on a specific field using php sphinxapi?

When running from the console, the where match('@category_id 42') query returns matches on the category_id field.
Through my code:

$cl = new SphinxClient();
$cl->SetServer(SLAVE_HOST, 9312);
$cl->_limit = 300000;
$cl->SetLimits(0, 10000, 10000);
$cl->setMatchMode(SPH_MATCH_EXTENDED2);
$keyword = '@category_id 42';
$keyword = $cl->EscapeString($keyword);
$result = $cl->Query($keyword, 'customers');

Finds no matches. Please tell me what could be wrong.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zeraks, 2014-09-25
@Zeraks

In general, the answer is found the problem is in this line
. It escaped the @ sign and the request was not read correctly.

A
AxisPod, 2014-09-25
@AxisPod

If category_id is an attribute, then the setFilter function must be used here. And probably it is not necessary to thrust such fields into a full-text index.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question