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
2条答案
按热度按时间5jdjgkvh1#
CentOS 8,太阳能8.7,Django奥斯卡3.0
1)安装Java
2)安装Solr
3)限制
调整solr用户的linux限制,可以在
/etc/security/limits.conf
中进行,在文件末尾添加行:或者在这里/etc/systemd/system.conf设置变量:
4)防火墙
关闭iptables或防火墙中的端口8983
5)重启
6)创建solr配置文件
将在此处创建配置文件目录:/var/solr/数据/干草堆/
7)www.example.com中的干草堆设置settings.py
重新启动受监控d:
8)切换到virtualenv
9)创建模式
在文件
/var/solr/data/haystack/conf/managed-schema
中,替换与
在文件
/var/solr/data/haystack/conf/managed-schema
中,找到最后一个</fieldType>
并在其后面添加将
currency.xml
复制到您的工作目录:10)重启电磁阀:
11)重建索引
mzsu5hc02#