S
S
Sergey Kudrin2016-02-17 11:35:21
PHP
Sergey Kudrin, 2016-02-17 11:35:21

How to get the unique properties of products and the number of products with these properties from the sphinx?

Good afternoon!
There is a task "to receive from the Sphinx unique properties of the goods and an amount of the goods with these properties".
In other words, get an output similar to a SQL query from the Sphinx:

SELECT i.prop, count(i.prop) FROM table_items i GROUP BY i.prop

Working with the sphinx in our project is organized through the sphinx client .
Tried to organize it, through setgroupby, but the strange result when property "sql_attr_multi" turns out.
For example, the tags property, code:
$cl->setGroupBy('tags', 4, '@groupby asc');
$result = $cl->query($query, $index);
foreach ($result['matches'] as $match)
{
   var_dump($match['attrs']['@groupby'], $match['attrs']['tags']);
}

produces the following result:
int 24
array (size=2)
  0 => int 24
  1 => int 273
int 58
array (size=2)
  0 => int 58
  1 => int 273
int 273
array (size=2)
  0 => int 234
  1 => int 273

Those. it outputs 24, 58, 273. Why is property 234 lost? And if you change the sort order, then property 273 will be lost.
Tell me what I'm doing wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
klirichek, 2016-02-25
@klirichek

max_matches is configured which one?
(see doc: WARNING: grouping is done in fixed memory and thus its results are only approximate; so there might be more groups reported in total_found than actually present. @count might also be underestimated. To reduce inaccuracy, one should raise max_matches .if max_matches allows to store all found groups, results will be 100% correct. )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question