django sphinx 中的 Order_by

发布于 2024-08-16 10:19:30 字数 1567 浏览 5 评论 0原文

我已经在我的网站中实现了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2024-08-23 10:19:30

尝试更改您的配置,使其将 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文