django - Django-Haystack 和 Solr 8.5.1
问题描述
Django haystack 是否适用于最新的 Solr 更新(8.5.1)?另外我如何设置我的 Django 博客项目
解决方案
Step 1:- Install Package
pip install pysolr
pip install django-haystack
Step 2:- Changes in settings.py for configuration
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'...',
'haystack',
]
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr/blog',
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
step 3:-Install Apache Solr
apt-get install solr-tomcat
# Update Tomcat's configuration to set the servlet connector port to a sensible value:
vim /etc/tomcat7/server.xml
# Change the value of the Catalina service's Connector port to 8983 (at the time of writing, it defaults to 8080). Restart tomcat.
service tomcat6 restart
Step 4:- Build and install the solr schema
python manage.py build_solr_schema > schema.xml
sudo cp schema.xml /usr/share/solr/conf/schema.xml
sudo systemctl restart tomcat7
step 5:- Build the index for the first time:
python manage.py rebuild_index
Step 6: Update Data in Solr
# Update Solr Index
# Changes to the Database Aren't Reflected in Search Results
python manage.py update_index
# This command updates the Solr index with any changes which are not currently reflected.
# When the Solr Schema Definition has been Changed
python manage.py rebuild_index
推荐阅读
- c - 制作空白输出文件的程序,C
- php - 将数据放入php和curl中的更新表中
- javascript - Apps Script webapp 分阶段加载 Javascript (jQuery)
- gcc - 使用 gcc 的 -shared 和 -pie 选项时的问题和疑惑
- angular - 角度材质输入浮动标签默认颜色更改
- laravel-5 - 如何从 laravel 的表中更新软删除值
- vb.net - 在一个处理程序中处理文本框事件
- html - HTML - 应用 CSS - 使用带有 id 的父 div 到带有 CSS 的子 div
- c++ - 使用 boost::geometry::append 时,ID 字段在自定义点类中间歇性丢失
- docker - Docker 通过 ssh 运行连接由端口 22 重置