SphinxQL 比较 json 个属性

SphinxQL compare json attributes

我有一个 json 字符串,如下所示:

{"mo":[{"from":800,"to":1100},{"from":1400,"to":1700}],"di":[{"from":800,"to":1100},{"from":1400,"to":1700}],"do":[{"from":800,"to":1100},{"from":1400,"to":1700}],"mi":[{"from":800,"to":1100}],"fr":[{"from":800,"to":1300}],"so":[],"sa":[]}

包含此 json 字符串的 mysql 字段在配置中声明为 sql_attr_json

以下 WHERE 条件工作正常:

WHERE json.mo[0].from < 1100

但是,下面的不是:

WHERE json.mo[0].from < json.mo[0].to

结果是:

sphinxql: syntax error, unexpected IDENT near 'json.mo[0].to

这是为什么?我正在尝试检查营业时间,但不幸的是,我很难做到这一点,我尝试了十几种不同的方法,但似乎没有任何效果。

更新:

我也在努力做:

WHERE (DATE_FORMAT(NOW(),'%H%i') between json.mo[0].from and json.mo[0].to) 

结果是

sphinxql: syntax error, unexpected '(' near '(NOW(),'%H%i')) between json.mo[0].from and json.mo[0].to)

即使是最基本的

SELECT DATE_FORMAT(NOW(),'%H%i') < 1050

导致相同的错误

 Sphinx expr: syntax error, unexpected '(', expecting $end near '(NOW(),'%H%i') < 1050'

作为解决方法,我也尝试过

SELECT CONCAT(HOUR(NOW()), MINUTE(NOW())) currentTime;

但这会导致

sphinxql: syntax error, unexpected $end, expecting FROM or ',' near 'currentTime'

在 MySQL 中工作正常

只是还没有实现。请尝试以下解决方法:

mysql> select *, INTEGER(j.mo[0].to) - INTEGER(j.mo[0].from) diff from rt where diff > 0\G
*************************** 1. row ***************************
  id: 1
   s:
   j: {"mo":[{"from":800,"to":1100},{"from":1400,"to":1700}],"di":[{"from":800,"to":1100},{"from":1400,"to":1700}],"do":[{"from":800,"to":1100},{"from":1400,"to":1700}],"mi":[{"from":800,"to":1100}],"fr":[{"from":800,"to":1300}],"so":[],"sa":[]}
diff: 300
1 row in set (0.00 sec)

我在 Manticore Search(Sphinx 的分支)中工作正常,在 Sphinx 中也应该工作正常。