Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solr6 template upgrade #1504

Merged
merged 55 commits into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
2955843
Fix django template context passing
RabidCicada Apr 6, 2017
a8d79ff
Fix to tests to run with context dicts instead of context objects for…
RabidCicada Apr 6, 2017
c4f73d6
Update solr template to be solr6 compatible
RabidCicada Apr 8, 2017
eaaf3a2
Reworked start-solr-test-server to work with modern solr. Reworked s…
RabidCicada Apr 11, 2017
d664828
Fixed LiveSolrContentExtractionTestCase Failure. Reworked core creat…
RabidCicada Apr 12, 2017
085fc91
Fixed LiveSolrAutocompleteTestCase Failure
RabidCicada Apr 12, 2017
493085c
Fix LiveSolrMoreLikeThisTestCase.
RabidCicada Apr 12, 2017
cfae3ed
Fix LiveSolrMoreLikeThisTestCase. Also fix the deferred case (whoops)
RabidCicada Apr 12, 2017
17fb620
Fix LiveSolrSearchQueryTestCase. Specifically spellcheck. Added spe…
RabidCicada Apr 13, 2017
9a375d4
Fix Collation based results. Add future plumbing for returning more …
RabidCicada Apr 13, 2017
3389712
Fix result_class swap failure
RabidCicada Apr 13, 2017
59bf22d
Attempting to get travis to see jdk8 request
RabidCicada Apr 13, 2017
ac52128
Trying to get a travis platform that supports jdk setting
RabidCicada Apr 13, 2017
f384e74
Adjusting matrix to include django 1.11. Adjusting wait_for_solr scr…
RabidCicada Apr 13, 2017
4197a9f
Troubleshooting travis failure that is not replicatable here
RabidCicada Apr 13, 2017
5a51fa0
more troubleshooting
RabidCicada Apr 13, 2017
544378a
more troubleshooting
RabidCicada Apr 13, 2017
0eae986
Fix wrong object in test for spelling suggestions.
RabidCicada Apr 14, 2017
db19db6
More troubleshooting
RabidCicada Apr 14, 2017
045fa19
More troubleshooting and fixing old test back to original check
RabidCicada Apr 14, 2017
0a6613d
Printing raw response that I found existed:)
RabidCicada Apr 14, 2017
d4e7a5b
Thinking solr versoin is wrong.
RabidCicada Apr 14, 2017
b356097
Final Fixes to support 6.4.0 and 6.5.0 spelling suggestions
RabidCicada Apr 14, 2017
f3a30f1
Working template management and tests. Lots of plumbing to test. Mo…
RabidCicada Apr 18, 2017
24ee453
Fixing a problem introduced in build_template.
RabidCicada Apr 18, 2017
19fbf00
Allow overriding collate for spellcheck at most entrypoints that acce…
RabidCicada Apr 18, 2017
30058af
Python 3 compatibility updates
RabidCicada Apr 18, 2017
49388f2
PEP8 Fixes. Mostly ignoring line length PEP violations due to concis…
RabidCicada Apr 19, 2017
042d6c3
Merge and deconflict of upstream PEP8 changes
RabidCicada Apr 19, 2017
9f8c583
Run isort on files updated in this branch
acdha Apr 19, 2017
3b94141
Remove unused imports
acdha Apr 19, 2017
ed228fb
PEP-8
acdha Apr 19, 2017
c4e30e1
PEP-8
acdha Apr 19, 2017
3d5583c
Tidy imports
acdha Apr 19, 2017
898a51b
build_solr_schema: less abbreviated keyword argument name
acdha Apr 19, 2017
0509703
build_solr_schema tidying
acdha Apr 19, 2017
4ccc96a
Test Solr launcher updates
acdha Apr 19, 2017
65c592c
Moved constants.HAYSTACK_DOCUMENT_FIELD to constants.DOCUMENT_FIELD t…
RabidCicada Apr 20, 2017
f8bad8f
Addressing Chris' comments on boolean check
RabidCicada Apr 20, 2017
1d810db
Addressing Chris' comments on comment style :) >.<
RabidCicada Apr 20, 2017
bd877a5
Update Solr spelling suggestion handling
acdha Apr 21, 2017
46fb6c2
Solr: ensure that the default document field is always applied
acdha Apr 21, 2017
6dca6ac
Update Solr management command tests
acdha Apr 25, 2017
477c677
Tests: better name for Solr-specific management commands
acdha Apr 25, 2017
168c9ae
Update build_solr_schema arguments
acdha Apr 25, 2017
6cf4f26
Tidy Solr backend tests
acdha Apr 25, 2017
245b946
Tidying test suite
acdha Apr 25, 2017
6501ce6
Updated docs to match new implementation
RabidCicada Apr 27, 2017
a46a515
Removed Unnecessary stopword files as requested
RabidCicada Apr 27, 2017
01dc17b
Updated docs to add warning about template filename change. Fixed typo
RabidCicada Apr 28, 2017
47a11b7
Cleaner approach based on acdh's comments. We don't carry around bag…
RabidCicada May 1, 2017
0e41ff5
Attempt to fix on Travis. I guess it runs from different directory
RabidCicada May 1, 2017
03209da
build_solr_schema: reload should not assume the backend name
acdha May 22, 2017
5608db1
Tidy build_solr_schema help text and exceptions
acdha May 22, 2017
038dd5f
Documentation copy-editing

acdha May 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sudo: true
sudo: required
dist: trusty
language: python
python:
- 2.7
Expand All @@ -11,6 +12,8 @@ cache:
pip: true
directories:
- $HOME/download-cache
jdk:
- oraclejdk8

addons:
apt_packages:
Expand Down Expand Up @@ -59,6 +62,7 @@ env:
- DJANGO_VERSION=">=1.8,<1.9" VERSION_ES=">=2.0.0,<3.0.0"
- DJANGO_VERSION=">=1.9,<1.10" VERSION_ES=">=2.0.0,<3.0.0"
- DJANGO_VERSION=">=1.10,<1.11" VERSION_ES=">=2.0.0,<3.0.0"
- DJANGO_VERSION=">=1.11,<1.12" VERSION_ES=">=2.0.0,<3.0.0"

matrix:
allow_failures:
Expand Down
10 changes: 5 additions & 5 deletions docs/backend_support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Supported Backends
==================

* Solr_
* Elasticsearch_
* ElasticSearch_
* Whoosh_
* Xapian_

.. _Solr: http://lucene.apache.org/solr/
.. _Elasticsearch: http://elasticsearch.org/
.. _ElasticSearch: http://elasticsearch.org/
.. _Whoosh: https://bitbucket.org/mchaput/whoosh/
.. _Xapian: http://xapian.org/

Expand All @@ -37,7 +37,7 @@ Solr
* Spatial search
* Requires: pysolr (2.0.13+) & Solr 3.5+

Elasticsearch
ElasticSearch
-------------

**Complete & included with Haystack.**
Expand All @@ -50,7 +50,7 @@ Elasticsearch
* Stored (non-indexed) fields
* Highlighting
* Spatial search
* Requires: `elasticsearch <https://pypi.python.org/pypi/elasticsearch>`_ 1.x or 2.x. Elasticsearch 5.X is currently unsupported: see `#1383 <https://github.com/django-haystack/django-haystack/issues/1383>`_.
* Requires: `elasticsearch-py <https://pypi.python.org/pypi/elasticsearch>`_ 1.x or 2.x. ElasticSearch 5.X is currently unsupported: see `#1383 <https://github.com/django-haystack/django-haystack/issues/1383>`_.

Whoosh
------
Expand Down Expand Up @@ -88,7 +88,7 @@ Backend Support Matrix
+================+========================+=====================+================+============+==========+===============+==============+=========+
| Solr | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
+----------------+------------------------+---------------------+----------------+------------+----------+---------------+--------------+---------+
| Elasticsearch | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
| ElasticSearch | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
+----------------+------------------------+---------------------+----------------+------------+----------+---------------+--------------+---------+
| Whoosh | Yes | Yes | Yes | Yes | No | Yes | Yes | No |
+----------------+------------------------+---------------------+----------------+------------+----------+---------------+--------------+---------+
Expand Down
47 changes: 32 additions & 15 deletions docs/installing_search_engines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,46 @@ Official Download Location: http://www.apache.org/dyn/closer.cgi/lucene/solr/

Solr is Java but comes in a pre-packaged form that requires very little other
than the JRE and Jetty. It's very performant and has an advanced featureset.
Haystack suggests using Solr 3.5+, though it's possible to get it working on
Solr 1.4 with a little effort. Installation is relatively simple::
Haystack suggests using Solr 6.x, though it's possible to get it working on
Solr 4.x+ with a little effort. Installation is relatively simple:

For Solr 6.X::

curl -LO https://archive.apache.org/dist/lucene/solr/x.Y.0/solr-X.Y.0.tgz
tar -C solr -xf solr-X.Y.0.tgz --strip-components=1
cd solr
./bin/solr create -c tester -n basic_config

By default this will create a core with a managed schema. This setup is dynamic
but not useful for haystack, and we'll need to configure solr to use a static
(classic) schema. Haystack can generate a viable schema.xml and solrconfig.xml
for you from your application and reload the core for you (once Haystack is
installed and setup). To do this run:
``./manage.py build_solr_schema --configure-directory=<CoreConfigDif>
--reload-core``. In this example CoreConfigDir is something like
``../solr-6.5.0/server/solr/tester/conf``, and ``--reload-core``
is what triggers reloading of the core. Please refer to ``build_solr_schema``
in the :doc:`management-commands` for required configuration.

For Solr 4.X::

curl -LO https://archive.apache.org/dist/lucene/solr/4.10.2/solr-4.10.2.tgz
tar xvzf solr-4.10.2.tgz
cd solr-4.10.2
cd example
java -jar start.jar

You'll need to revise your schema. You can generate this from your application
Youll need to revise your schema. You can generate this from your application
(once Haystack is installed and setup) by running
``./manage.py build_solr_schema``. Take the output from that command and place
it in ``solr-4.10.2/example/solr/collection1/conf/schema.xml``. Then restart Solr.

.. note::
``build_solr_schema`` uses a template to generate ``schema.xml``. Haystack
provides a default template using some sensible defaults. If you would like
to provide your own template, you will need to place it in
``search_configuration/solr.xml``, inside a directory specified by your app's
``TEMPLATE_DIRS`` setting. Examples::
it in ``solr-4.10.2/example/solr/collection1/conf/schema.xml``. Then restart
Solr.

/myproj/myapp/templates/search_configuration/solr.xml
# ...or...
/myproj/templates/search_configuration/solr.xml
.. warning::
Please note; the template filename, the file YOU supply under
TEMPLATE_DIR/search_configuration has changed to schema.xml from solr.xml.
The previous template name solr.xml was a legacy holdover from older
versions of solr.

You'll also need a Solr binding, ``pysolr``. The official ``pysolr`` package,
distributed via PyPI, is the best version to use (2.1.0+). Place ``pysolr.py``
Expand All @@ -43,7 +59,8 @@ somewhere on your ``PYTHONPATH``.
.. note::

``pysolr`` has its own dependencies that aren't covered by Haystack. See
https://pypi.python.org/pypi/pysolr for the latest documentation.
https://pypi.python.org/pypi/pysolr for the latest documentation. Simplest
approach is to install using ``pip install pysolr``

More Like This
--------------
Expand Down
69 changes: 54 additions & 15 deletions docs/management_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ easier.

The ``clear_index`` command wipes out your entire search index. Use with
caution. In addition to the standard management command options, it accepts the
following arguments::
following arguments:

``--noinput``:
If provided, the interactive prompts are skipped and the index is
uncerimoniously wiped out.
unceremoniously wiped out.
``--verbosity``:
Accepted but ignored.
``--using``:
Expand Down Expand Up @@ -55,7 +55,7 @@ wish to delete the entire index.
The ``update_index`` command will freshen all of the content in your index. It
iterates through all indexed models and updates the records in the index. In
addition to the standard management command options, it accepts the following
arguments::
arguments:

``--age``:
Number of hours back to consider objects new. Useful for nightly
Expand Down Expand Up @@ -95,7 +95,7 @@ arguments::

.. note::

The ``--nocommit`` argument is only supported by the Solr and Elasticsearch backends.
The ``--nocommit`` argument is only supported by the Solr and ElasticSearch backends.

Examples::

Expand Down Expand Up @@ -136,7 +136,7 @@ Examples::
=================

A shortcut for ``clear_index`` followed by ``update_index``. It accepts any/all
of the arguments of the following arguments::
of the arguments of the following arguments:

``--age``:
Number of hours back to consider objects new. Useful for nightly
Expand All @@ -148,7 +148,7 @@ of the arguments of the following arguments::
The site object to use when reindexing (like `search_sites.mysite`).
``--noinput``:
If provided, the interactive prompts are skipped and the index is
uncerimoniously wiped out.
unceremoniously wiped out.
``--remove``:
Remove objects from the index that are no longer present in the
database.
Expand All @@ -175,22 +175,61 @@ For when you really, really want a completely rebuilt index.
=====================

Once all of your ``SearchIndex`` classes are in place, this command can be used
to generate the XML schema Solr needs to handle the search data. It accepts the
following arguments::
to generate the XML schema Solr needs to handle the search data. Generates a
Solr schema and solrconfig file that reflects the indexes using templates under
a Django template dir 'search_configuration/\*.xml'. If none are found, then
provides defaults suitable for Solr 6.4.

It accepts the following arguments:

``--filename``:
If provided, directs output to a file instead of stdout.
If provided, renders schema.xml from the template directory directly to
a file instead of stdout. Does not render solrconfig.xml
``--using``:
Update only the named backend (can be used multiple times). By default
all backends will be updated.
``--configure-directory``:
If provided, attempts to configure a core located in the given directory
by removing the ``managed-schema.xml`` (renaming if it exists), configuring
the core by rendering the ``schema.xml`` and ``solrconfig.xml`` templates
provided in the Django project's ``TEMPLATE_DIR/search_configuration``
directories.
``--reload-core``:
If provided, attempts to automatically reload the solr core via the urls
in the ``URL`` and ``ADMIN_URL`` settings of the Solr entry in
``HAYSTACK_CONNECTIONS``. Both *must* be provided.

.. warning::
.. note::
``build_solr_schema --configure-directory=<dir>`` can be used in isolation to
drop configured files anywhere one might want for staging to one or more solr
instances through arbitrary means. It will render all template files in the
directory into the ``configure-directory``

``build_solr_schema --configure-directory=<dir> --reload-core`` can be used
together to reconfigure and reload a core located on a filesystem accessible
to Django in a one-shot mechanism with no further requirements (assuming
there are no errors in the template or configuration)

This command does NOT update the ``schema.xml`` file for you. You either
have to specify a ``filename`` flag or have to
copy-paste (or redirect) the output to the correct file. Haystack has no
way of knowing where your Solr is setup (or if it's even on the same
machine), hence the manual step.
.. note::
``build_solr_schema`` uses templates to generate the output files. Haystack
provides default templates for ``schema.xml`` and ``solrconfig.xml`` that
are solr 6.5 compatible using some sensible defaults. If you would like to
provide your own template, you will need to place it in
``search_configuration/`` inside a directory specified by your app's
template directories settings. Examples::

/myproj/myapp/templates/search_configuration/schema.xml
/myproj/myapp/templates/search_configuration/sorlconfig.xml
/myproj/myapp/templates/search_configuration/otherfile.xml
# ...or...
/myproj/templates/search_configuration/schema.xml
/myproj/templates/search_configuration/sorlconfig.xml
/myproj/myapp/templates/search_configuration/otherfile.xml

.. warning::
This command does NOT automatically update the ``schema.xml`` file for you
all by itself. You must use --filename or --configure-directory to achieve
this.


``haystack_info``
Expand Down
4 changes: 3 additions & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ Additionally, each backend may have additional options it requires:

* Solr

* ``URL`` - The URL to the Solr core.
* ``URL`` - The URL to the Solr core. e.g. http://localhost:9001/solr/collection1
* ``ADMIN_URL`` - The URL to the administrative functions. e.g.
http://localhost:9001/solr/admin/cores

* Whoosh

Expand Down
3 changes: 2 additions & 1 deletion haystack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
# DEBUG = True.
def reset_search_queries(**kwargs):
for conn in connections.all():
conn.reset_queries()
if conn:
conn.reset_queries()


if settings.DEBUG:
Expand Down