在Django狮身人面像中的Order_by

时间:2009-12-29 12:23:25

标签: django django-sphinx

我在我的网站上实施了django-sphinx搜索。 我需要结果集“按end_time排序”,但我的结果 oder首先是“id”,然后是“end_time”

我的尴尬是:

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')

任何人都可以帮我解决这个问题.............

1 个答案:

答案 0 :(得分:0)

尝试更改配置,使其具有UNIX_TIMESTAMP(end_time)作为end_time,重新索引,重新启动searchd,然后再进行测试。