django-haystack 安装或设置
例子
安装haystack包
pip install django-haystack
配置
添加haystack到您的项目INSTALLED_APPS的内部settings.py文件:
# settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
# Put haystack with above your project's apps
'haystack',
'myproject_app',
]现在为您的搜索后端添加设置。Haystack目前支持:solr、elasticsearch、whoosh和xapian。
索尔:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr'
# ...or for multicore...
# 'URL': 'http://127.0.0.1:8983/solr/mysite',
},
}弹性搜索:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}嗬嗬:
import os
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}夏平:
import os
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'xapian_backend.XapianEngine',
'PATH': os.path.join(os.path.dirname(__file__), 'xapian_index'),
},
}
热门推荐
10 妹妹生日宴祝福语简短
11 医院乔迁条幅祝福语简短
12 妹妹考上军校祝福语简短
13 作文结尾新年祝福语简短
14 老师高考后祝福语 简短
15 新年英文祝福语简短老师
16 工作花束祝福语简短英文
17 美女新人结婚祝福语简短
18 给母校送花祝福语简短