Django-Haystack和Solr 8.5.1

问题描述 投票:0回答:1

Django haystack是否可以使用最新的Solr更新(8.5.1)?另外,如何设置我的Django博客项目

django solr django-haystack pysolr
1个回答
0
投票
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
© www.soinside.com 2019 - 2024. All rights reserved.