Skip to content

Commit 1973a46

Browse files
committed
BACKWARD-INCOMPATIBLE: Added multiple index support to Haystack, which enables you to talk to more than one search engine in the same codebase. Thanks to:
* Kent Gormat for funding the development of this feature. * alex, freakboy3742 & all the others who contributed to Django's multidb feature, on which much of this was based. * acdha for inspiration & feedback. * dcramer for inspiration & feedback. * mcroydon for patch review & docs feedback. This commit starts the development efforts for Haystack v2.
1 parent 00a23e0 commit 1973a46

File tree

91 files changed

+3565
-3097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3565
-3097
lines changed

TODO

Lines changed: 0 additions & 63 deletions
This file was deleted.

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
# built documents.
4646
#
4747
# The short X.Y version.
48-
version = '1.2'
48+
version = '2.0'
4949
# The full version, including alpha/beta/rc tags.
50-
release = '1.2.0'
50+
release = '2.0.0-alpha'
5151

5252
# The language for content autogenerated by Sphinx. Refer to documentation
5353
# for a list of supported languages.

docs/debugging.rst

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ small sites or development.
7777

7878
A way to solve this is to subclass ``SearchIndex`` instead::
7979

80-
from haystack.indexes import *
80+
from haystack import indexes
8181
8282
# Change from:
8383
#
84-
# class MySearchIndex(RealTimeSearchIndex):
84+
# class MySearchIndex(indexes.RealTimeSearchIndex):
8585
#
8686
# to:
87-
class MySearchIndex(SearchIndex):
87+
class MySearchIndex(indexes.SearchIndex):
8888
...
8989

9090
The final step is to set up a cron job that runs
@@ -97,52 +97,16 @@ traffic. If this is not acceptable, you should investigate either the Solr or
9797
Xapian backends.
9898

9999

100-
"Import errors on start-up mentioning 'handle_registrations'"
101-
=============================================================
102-
103-
When initializing, Haystack attempts to import and register all of the
104-
``SearchIndex`` classes you've setup. As a by-product of this, especially in
105-
conjunction with third-party apps that attempt to do similar types of imports,
106-
it's possible (though rare) to get a traceback very early in the start-up
107-
process, usually mentioning ``handle_registrations``.
108-
109-
There are typically three possible causes for this error:
110-
111-
* A syntax/import error in a file included by the ``search_indexes.py`` file
112-
* A circular import
113-
* Another app causing models to load early
114-
115-
The first two causes can be debugged by dropping an
116-
``import pdb; pdb.set_trace()`` at the top of the ``search_indexes.py`` where
117-
the error is occurring and stepping through to see the real error.
118-
119-
If neither of those is the case, Haystack provides an advanced setting
120-
(``HAYSTACK_ENABLE_REGISTRATIONS`` - :doc:`settings`) to disable this importing
121-
behavior and allow your applications to function.
122-
123-
As a note of caution, setting ``HAYSTACK_ENABLE_REGISTRATIONS = False`` in your
124-
settings causes Haystack to be left in an uninitialized state. This means that
125-
none of your ``SearchIndex`` classes will be registered and all attempts to use
126-
``SearchQuerySet`` will yield no results. To continue using Haystack, you'll
127-
need to manually import your ``search_indexes.py`` files, either in your
128-
``models.py`` or ``views.py`` files (or something similar). Additionally, any
129-
use at the console/management commands may also require similar imports.
130-
131-
Finally, should this occur to you, it would be appreciated if you could report
132-
the issue and the app(s) you're using that are causing the issue in conjunction
133-
with Haystack on either the mailing list or on the GitHub issue tracker.
134-
135-
136100
"Failed to add documents to Solr: [Reason: None]"
137101
=================================================
138102

139103
This is a Solr-specific traceback. It generally occurs when there is an error
140-
with your ``HAYSTACK_SOLR_URL``. Since Solr acts as a webservice, you should
104+
with your ``HAYSTACK_CONNECTIONS[<alias>]['URL']``. Since Solr acts as a webservice, you should
141105
test the URL in your web browser. If you receive an error, you may need to
142106
change your URL.
143107

144108
This can also be caused when using old versions of pysolr (2.0.9 and before),
145-
using httplib2 and including a trailing slash in your ``HAYSTACK_SOLR_URL``.
109+
using httplib2 and including a trailing slash in your ``HAYSTACK_CONNECTIONS[<alias>]['URL']``.
146110
Please upgrade your version of pysolr (2.0.13+).
147111

148112

docs/do_not_try_this_at_home.rst

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ you up and running:
4141
other_apps
4242
installing_search_engines
4343
debugging
44+
45+
migration_from_1_to_2
4446

4547

4648
Advanced Uses
@@ -57,7 +59,7 @@ you may want to include in your application.
5759
faceting
5860
autocomplete
5961
boost
60-
do_not_try_this_at_home
62+
multiple_index
6163

6264

6365
Reference
@@ -73,7 +75,6 @@ looking for API documentation and advanced usage as detailed in:
7375
searchindex_api
7476
searchfield_api
7577
searchresult_api
76-
searchsite_api
7778
searchquery_api
7879
searchbackend_api
7980

docs/management_commands.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ following arguments::
2020
uncerimoniously wiped out.
2121
``--verbosity``:
2222
Accepted but ignored.
23+
``--using``:
24+
If provided, determines which connection should be used. Default is
25+
``default``.
2326

2427
By default, this is an **INTERACTIVE** command and assumes that you do **NOT**
2528
wish to delete the entire index.
2629

2730
.. warning::
2831

2932
Depending on the backend you're using, this may simply delete the entire
30-
directory, so be sure your ``HAYSTACK_<ENGINE>_PATH`` setting is correctly
33+
directory, so be sure your ``HAYSTACK_CONNECTIONS[<alias>]['PATH']`` setting is correctly
3134
pointed at just the index directory.
3235

3336

@@ -58,6 +61,9 @@ arguments::
5861
and how many records.
5962
* ``2`` = Full output, including everything from ``1`` plus output
6063
on each batch that is indexed, which is useful when debugging.
64+
``--using``:
65+
If provided, determines which connection should be used. Default is
66+
``default``.
6167

6268
.. note::
6369

@@ -96,6 +102,9 @@ of the arguments of the following arguments::
96102
and how many records.
97103
* ``2`` = Full output, including everything from ``1`` plus output
98104
on each batch that is indexed, which is useful when debugging.
105+
``--using``:
106+
If provided, determines which connection should be used. Default is
107+
``default``.
99108

100109
For when you really, really want a completely rebuilt index.
101110

@@ -104,12 +113,19 @@ For when you really, really want a completely rebuilt index.
104113
=====================
105114

106115
Once all of your ``SearchIndex`` classes are in place, this command can be used
107-
to generate the XML schema Solr needs to handle the search data. It accepts no
108-
arguments.
116+
to generate the XML schema Solr needs to handle the search data. It accepts the
117+
following arguments::
118+
119+
``--filename``:
120+
If provided, directs output to a file instead of stdout.
121+
``--using``:
122+
If provided, determines which connection should be used. Default is
123+
``default``.
109124

110125
.. warning:
111126
112-
This command does NOT update the ``schema.xml`` file for you. You have to
127+
This command does NOT update the ``schema.xml`` file for you. You either
128+
have to specify a ``filename`` flag or have to
113129
copy-paste (or redirect) the output to the correct file. Haystack has no
114130
way of knowing where your Solr is setup (or if it's even on the same
115131
machine), hence the manual step.

0 commit comments

Comments
 (0)