You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passed site doesn't to SearchQuerySet(site=my_site) doesn't get transferred to xapian backend.
If you do this in your view code:
searchqueryset = SearchQuerySet(site=site)
That site that you have specified gets lost when using the xapian
backend by xapian_backend.py. xapian_backend ends up using the default
site instance from haystack.sites which might not be the one you want
to use. In my case, I've subclassed SearchSite in a custom class that
knows not to use the Django ORM.
This patch has two problems: 1) It's a patch that involves two
different projects and 2) I don't know how to add tests to prove it.
Current versions:
django-haystack: (1, 1, 0, 'alpha')
xapian-haystack: (1, 1, 1, 'beta')
If you apply the following change to xapian-haystack/
xapian_backend.py:
diff --git a/xapian_backend.py b/xapian_backend.py
index ec648a7..7036d69 100755
--- a/xapian_backend.py
+++ b/xapian_backend.py
@@ -795,16 +795,18 @@ class SearchQuery(BaseSearchQuery):
It acts as an intermediary between the SearchQuerySet and the SearchBackend itself.
"""
def init(self, backend=None):
def init(self, backend=None, site=None):
"""
Create a new instance of the SearchQuery setting the backend
as
specified. If no backend is set, will use the Xapian SearchBackend.
Optional arguments:
``backend`` -- The ``SearchBackend`` to use (default =
None)
`site` -- The site to use in the new `SearchBackend`
if it
needs to be created (default = None)
"""
super(SearchQuery, self).**init**(backend=backend)
self.backend = backend or SearchBackend()
self.backend = backend or SearchBackend(site=site)
def run(self, spelling_query=None):
try:
And the following change to django-haystack/haystack/query.py:
diff --git a/haystack/query.py b/haystack/query.py
index 4fc96a0..503e2e9 100644
--- a/haystack/query.py
+++ b/haystack/query.py
@@ -13,7 +13,7 @@ class SearchQuerySet(object):
Supports chaining (a la QuerySet) to narrow the search.
"""
def init(self, site=None, query=None):
Passed site doesn't to SearchQuerySet(site=my_site) doesn't get transferred to xapian backend.
If you do this in your view code:
That site that you have specified gets lost when using the xapian
backend by xapian_backend.py. xapian_backend ends up using the default
site instance from haystack.sites which might not be the one you want
to use. In my case, I've subclassed SearchSite in a custom class that
knows not to use the Django ORM.
This patch has two problems: 1) It's a patch that involves two
different projects and 2) I don't know how to add tests to prove it.
Current versions:
If you apply the following change to xapian-haystack/
xapian_backend.py:
diff --git a/xapian_backend.py b/xapian_backend.py
index ec648a7..7036d69 100755
--- a/xapian_backend.py
+++ b/xapian_backend.py
@@ -795,16 +795,18 @@ class SearchQuery(BaseSearchQuery):
It acts as an intermediary between the
SearchQuerySet
and theSearchBackend
itself."""
"""
Create a new instance of the SearchQuery setting the backend
as
specified. If no backend is set, will use the Xapian
SearchBackend
.None)
if it
def run(self, spelling_query=None):
try:
And the following change to django-haystack/haystack/query.py:
diff --git a/haystack/query.py b/haystack/query.py
index 4fc96a0..503e2e9 100644
--- a/haystack/query.py
+++ b/haystack/query.py
@@ -13,7 +13,7 @@ class SearchQuerySet(object):
Supports chaining (a la QuerySet) to narrow the search.
"""
def init(self, site=None, query=None):
Then the site you pass when you create a SearchQuerySet instance gets
used in the xapian backend.
The text was updated successfully, but these errors were encountered: