Вопрос

I am using a SetFilter command as so:

 $mycategoryids = "345,366,456,444,789,345";

 $cl->SetFilter( 'thecatid', array( $mycategoryids ));

However, of the results I get back, they all have 345 as either their primary or secondary category, so it appears that since 345 is the first number in that array, it is given more if not all of the weight. Am I doing something wrong? I thought that having all of those numbers in that array would simply mean that sphinx would only grab items that included one of those numbers within "thecatid" so that if there was an item like this:

 [thecatid] => Array
                                 (
                                [0] => 444
                                [1] => 552
                                [2] => 554
                                [3] => 566
                            )

Then it should still show up in the results because 444 is in the item's 'thecatid' array and 444 is also in the filter call.

Am I missing something?

Oh, and to make sure my query is correct, within the query I have:

  SELECT u.ID,u.Downloads as downloads, CONCAT_WS(',', u.catID, u.CatID1, u.CatID2, u.CatID3) as thecatid, ...

And then down below:

 sql_attr_multi = uint thecatid from field;

Thanks!

Craig

Это было полезно?

Решение

 $mycategoryids = "345,366,456,444,789,345";

 $cl->SetFilter( 'thecatid', array( $mycategoryids ));

Thats not valid code. You need to pass setFilter an array of numbers. Not an array containing a single string.

Both of these are better...

$mycategoryids = array(345,366,456,444,789,345);
$cl->SetFilter( 'thecatid', $mycategoryids);

or

$mycategoryids = "345,366,456,444,789,345";
$cl->SetFilter( 'thecatid', explode(',',$mycategoryids) );
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top