Skip to content

Commit 78adc9a

Browse files
committed
Fixed a bug where RealTimeSearchIndex was erroneously included in index discovery. Thanks to dedsm for the report & original patch!
1 parent 4264cbb commit 78adc9a

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

haystack/utils/loading.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,14 @@ def __init__(self):
139139
self._facet_fieldnames = {}
140140

141141
def collect_indexes(self):
142-
from haystack.indexes import SearchIndex, BasicSearchIndex, ModelSearchIndex
143-
base_classes = [Indexable, SearchIndex, BasicSearchIndex, ModelSearchIndex]
142+
from haystack.indexes import SearchIndex, BasicSearchIndex, ModelSearchIndex, RealTimeSearchIndex
143+
ignored_classes = [
144+
Indexable,
145+
SearchIndex,
146+
BasicSearchIndex,
147+
ModelSearchIndex,
148+
RealTimeSearchIndex
149+
]
144150
indexes = []
145151

146152
for app in settings.INSTALLED_APPS:
@@ -150,7 +156,7 @@ def collect_indexes(self):
150156
continue
151157

152158
for item_name, item in inspect.getmembers(search_index_module, inspect.isclass):
153-
if not item in base_classes and issubclass(item, Indexable):
159+
if not item in ignored_classes and issubclass(item, Indexable):
154160
# We've got an index. Check if we should be ignoring it.
155161
class_path = "%s.search_indexes.%s" % (app, item_name)
156162

tests/multipleindex/search_indexes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
from multipleindex.models import Foo, Bar
33

44

5+
# To test additional ignores...
6+
class BaseIndex(indexes.SearchIndex):
7+
text = indexes.CharField(document=True, model_attr='body')
8+
9+
def get_model(self):
10+
return Foo
11+
12+
513
class FooIndex(indexes.SearchIndex):
614
text = indexes.CharField(document=True, model_attr='body')
715

@@ -10,7 +18,7 @@ def get_model(self):
1018

1119

1220
# Import the old way & make sure things don't explode.
13-
from haystack.indexes import SearchIndex
21+
from haystack.indexes import SearchIndex, RealTimeSearchIndex
1422

1523

1624
class BarIndex(indexes.SearchIndex):

tests/multipleindex_settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@
1515
'PATH': os.path.join('tmp', 'test_whoosh_query'),
1616
},
1717
}
18+
19+
HAYSTACK_EXCLUDED_INDEXES = [
20+
'multipleindex.search_indexes.BaseIndex',
21+
]
22+

0 commit comments

Comments
 (0)