You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

how_to_setup_solr.rst 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. .. spelling::
  2. Solr
  3. ============================
  4. How to setup Solr with Oscar
  5. ============================
  6. `Apache Solr`_ is Oscar's recommended production-grade search backend. This
  7. how-to describes how to get Solr running, and integrated with Oscar. The
  8. instructions below are tested on an Ubuntu machine, but should be applicable
  9. for similar environments. A working Java or OpenJDK installation are necessary.
  10. .. _`Apache Solr`: https://lucene.apache.org/solr/
  11. Installing Solr
  12. ===============
  13. You first need to fetch and extract Solr. The schema included with Oscar
  14. is tested with Solr 4.7.2:
  15. .. code-block:: bash
  16. $ wget http://archive.apache.org/dist/lucene/solr/4.7.2/solr-4.7.2.tgz
  17. $ tar xzf solr-4.7.2.tgz
  18. Integrating with Haystack
  19. =========================
  20. Haystack provides an abstraction layer on top of different search backends and
  21. integrates with Django. Your Haystack connection settings in your
  22. ``settings.py`` for the config above should look like this:
  23. .. code-block:: python
  24. HAYSTACK_CONNECTIONS = {
  25. 'default': {
  26. 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
  27. 'URL': 'http://127.0.0.1:8983/solr',
  28. 'INCLUDE_SPELLING': True,
  29. },
  30. }
  31. Build Solr schema
  32. =================
  33. Next, replace the example configuration with Oscar's.
  34. .. code-block:: bash
  35. $ ./manage.py build_solr_schema > solr-4.7.2/example/solr/collection1/conf/schema.xml
  36. You should then be able to start Solr by running:
  37. .. code-block:: bash
  38. $ cd solr-4.7.2/example
  39. $ java -jar start.jar
  40. Rebuild search index
  41. ====================
  42. If all is well, you should now be able to rebuild the search index.
  43. .. code-block:: bash
  44. $ ./manage.py rebuild_index --noinput
  45. Removing all documents from your index because you said so.
  46. All documents removed.
  47. Indexing 201 Products
  48. Indexing 201 Products
  49. The products being indexed twice is caused by a low-priority bug in Oscar and
  50. can be safely ignored. If the indexing succeeded, search in Oscar will be
  51. working. Search for any term in the search box on your Oscar site, and you
  52. should get results.