基于日期时间的 Sphinx 搜索
我有一个名为“createdOn”的字段,其类型为“时间戳”。其中存储的值如下: 2011-08-07 00:00:00
我想按此属性进行搜索。例如,在 mysql 中我会这样做:
SELECT * FROM `posts` where deleted = 1 and date(createdOn) = '2011-8-4'
我尝试在 sphinx 中设置它:
sql_query = \
SELECT id, deleted, upvotes, DATE(createdOn) as createdOn, thread_title, first_post \
FROM posts
sql_attr_bool = deleted
sql_attr_timestamp = createdOn
在 php 中:
$cl->SetFilter ( "deleted",array(1));
$cl->SetFilter ( "createdOn", '2011-8-4');
$result = $cl->Query("");
但这给了我一个断言失败错误。
谢谢你
I have a field called 'createdOn' which of the type 'timestamp'. The values stored in it are as such e.g.: 2011-08-07 00:00:00
I would like to search by this attribute. For example in mysql I would do this :
SELECT * FROM `posts` where deleted = 1 and date(createdOn) = '2011-8-4'
I tried to set it up in sphinx as such :
sql_query = \
SELECT id, deleted, upvotes, DATE(createdOn) as createdOn, thread_title, first_post \
FROM posts
sql_attr_bool = deleted
sql_attr_timestamp = createdOn
and in php:
$cl->SetFilter ( "deleted",array(1));
$cl->SetFilter ( "createdOn", '2011-8-4');
$result = $cl->Query("");
But this gives me an assertion failed error.
Thanking you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
属性时间戳应该具有整数值。
在 sphinx.conf 中:
和 php 中:
Attribute timestamp should have integer value.
In sphinx.conf:
and in php:
对于较新版本的 Sphinx,您需要使用
SetFilterRange
, IE:For newer versions of Sphinx you need to use
SetFilterRange
, i.e.: