djangosolrdjango-haystackpysolr

Django-Haystack and Solr 8.5.1


Does Django haystack work with the latest Solr update (8.5.1)? Plus how do I setup with my Django blog project


Solution

  • 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