django sphinx 中的 Order_by
我已经在我的网站中实现了 django-sphinx 搜索。 我需要结果集“按 end_time 排序”,但我得到的结果先按“id”排序,然后按“end_time”排序。
我的conf是:
source main_event : main_civilengagement
{
sql_query = \
SELECT mc.id as id, mc.name as name, tt.name as ttname, mp.text as mptext, \
mc.description as description, mc.meta_search as meta_search, \
mc.start_time as start_time, mc.end_time as end_time \
FROM main_event mc LEFT JOIN \
(tagging_taggeditem tti JOIN tagging_tag tt on tti.tag_id=tt.id) \
on mc.id=tti.object_id and \
tti.content_type_id=(select id from \
django_content_type where name='event' \
and app_label='main') \
LEFT JOIN main_post mp on mc.id=mp.object_id \
and mp.content_type_id= \
(select id from \
django_content_type where name='event' \
and app_label='main')
# DateField's and DateTimeField's
sql_attr_timestamp = start_time
sql_attr_timestamp = end_time
}
index main_event : main_civilengagement
{
source = main_event
path = ../../../sphinx/data/main_event_damco
}
我的观点
model_results = model.search.query(keyword,stype).order_by('-end_time')
任何人都可以帮我解决这个问题............
I have implemented django-sphinx search in my website.
I need result set "order by end_time" but i got results oder by first "id" and then "end_time".
My conf is:
source main_event : main_civilengagement
{
sql_query = \
SELECT mc.id as id, mc.name as name, tt.name as ttname, mp.text as mptext, \
mc.description as description, mc.meta_search as meta_search, \
mc.start_time as start_time, mc.end_time as end_time \
FROM main_event mc LEFT JOIN \
(tagging_taggeditem tti JOIN tagging_tag tt on tti.tag_id=tt.id) \
on mc.id=tti.object_id and \
tti.content_type_id=(select id from \
django_content_type where name='event' \
and app_label='main') \
LEFT JOIN main_post mp on mc.id=mp.object_id \
and mp.content_type_id= \
(select id from \
django_content_type where name='event' \
and app_label='main')
# DateField's and DateTimeField's
sql_attr_timestamp = start_time
sql_attr_timestamp = end_time
}
index main_event : main_civilengagement
{
source = main_event
path = ../../../sphinx/data/main_event_damco
}
And my view
model_results = model.search.query(keyword,stype).order_by('-end_time')
Can anyone help me in sorting out this problem.............
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试更改您的配置,使其将 UNIX_TIMESTAMP(end_time) 作为 end_time,重新索引,重新启动 searchd,然后进行测试。
Try changing your config so it has UNIX_TIMESTAMP(end_time) as end_time, reindexing, restarting searchd, and testing after that.