V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
foonpcf
V2EX  ›  Django

請問怎樣使用Django-haystack作搜尋器?

  •  
  •   foonpcf · 2013-08-28 17:06:00 +08:00 · 3490 次点击
    这是一个创建于 3896 天前的主题,其中的信息可能已经有所发展或是发生改变。
    8 条回复    1970-01-01 08:00:00 +08:00
    zhuf
        1
    zhuf  
       2013-08-28 17:16:56 +08:00   ❤️ 1
    foonpcf
        2
    foonpcf  
    OP
       2013-08-28 18:01:16 +08:00
    @zhuf, 當我python manage.py rebuild_index後出現這個情況“TypeError: coercing to Unicode: need string or buffer, tuple found“
    zhuf
        3
    zhuf  
       2013-08-28 18:24:07 +08:00
    @foonpcf 具体代码贴下
    foonpcf
        4
    foonpcf  
    OP
       2013-08-28 18:27:07 +08:00
    我是用Django-cms及django-cms-search, 需要倚賴Django-haystack

    settings.py

    HAYSTACK_SEARCH_ENGINE = 'whoosh'

    HAYSTACK_WHOOSH_PATH = os.path.join(os.path.dirname(__file__), 'whoosh_index'),

    HAYSTACK_SITECONF = 'cmsplugin_search.search_indexes'
    zhuf
        5
    zhuf  
       2013-08-28 18:29:08 +08:00   ❤️ 1
    @foonpcf 我记得文档里应该是这样的吧
    ```import os
    HAYSTACK_CONNECTIONS = {
    'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
    },
    }```
    zhuf
        6
    zhuf  
       2013-08-28 18:30:02 +08:00   ❤️ 1
    还有检查下haystack的版本,好像版本不对是有问题的。
    foonpcf
        7
    foonpcf  
    OP
       2013-08-28 18:30:49 +08:00
    版本是django-haystack 1.2.7
    foonpcf
        8
    foonpcf  
    OP
       2013-08-29 11:46:03 +08:00
    @zhuf, 我重新用你的教學做多一次,但得不到結搜尋結果....... =(
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3238 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:12 · PVG 20:12 · LAX 05:12 · JFK 08:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.