Вопрос

I''m working with JSON functionality in sphinx 2.2.2.INDEX table looks like:

mysql> SELECT subsite_min_cnt, version_content_cnt FROM mobile_collection;
+------------------------+-----------------------------------------------------------+
| subsite_min_cnt        | version_content_cnt                                       |
+------------------------+-----------------------------------------------------------+
| {"85":3,"75":4,"65":5} | {"10003":4,"10008":5,"10009":5,"11000":7,"1":1,"10000":3} |
| {"85":6,"75":4,"65":5} | {"46":1,"201":1,"11000":1,"10010":1}                      |
+------------------------+-----------------------------------------------------------+

And I work with two values from JSONs:

mysql> SELECT subsite_min_cnt.85 as a, version_content_cnt.10008 as b 
       FROM mobile_collection;
+------+------+
| a    | b    |
+------+------+
| 3    | 5    |
| 6    | NULL |
+------+------+

I try to compare these two value and here is what i get (the json_autoconv_numbers is equal to 1):

mysql> SELECT subsite_min_cnt.85 as a, version_content_cnt.10008 as b 
       FROM mobile_collection WHERE b IS NOT NULL and a < b;

ERROR 1064 (42000): sphinxql: syntax error, unexpected IDENT, expecting CONST_INT (or 3 other tokens) near 'b'

Or:

mysql> SELECT subsite_min_cnt.85 < version_content_cnt.10008 as b 
       FROM mobile_collection;
+------+
| b    |
+------+
| 0    |
| 0    |
+------+

So, the question is: does comparison of two json values work in sphinxql? Or, maybe, I compare items in wrong way...

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

Решение

Despite json_autoconv_numbers = 1, the type conversion solved my problem:

mysql> SELECT integer(subsite_min_cnt.85) < integer(version_content_cnt.10008) as c, subsite_min_cnt.85, version_content_cnt.10008 
       FROM mobile_collection where c > 0;
+------+--------------------+---------------------------+
| c    | subsite_min_cnt.85 | version_content_cnt.10008 |
+------+--------------------+---------------------------+
|    1 | 3                  | 5                         |
+------+--------------------+---------------------------+
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top