Last active
March 31, 2016 14:54
-
-
Save etianen/74b69ac2a61c1722121fd1325216f01c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
from watson import search as watson | |
search_engine_1 = watson.SearchEngine("engine_1") | |
search_engine_2 = watson.SearchEngine("engine_2") | |
class YourAppConfig(AppConfig): | |
name = "customer" | |
def ready(self): | |
search_engine_1.register(self.get_model("ModelA")) | |
search_engine_1.register(self.get_model("ModelB")) | |
search_engine_2.register(self.get_model("ModelC")) | |
search_engine_2.register(self.get_model("ModelD")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import url, patterns | |
from my_project import views | |
urlpatterns = [ | |
url("^search-1/$", views.SearchEngine1View.as_view()), | |
url("^search-2/$", views.SearchEngine2View.as_view()), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from watson.views import SearchView | |
from my_project.search import search_engine_1, search_engine_1 | |
class SearchEngine1View(SearchView): | |
def get_queryset(self): | |
"""Returns the initial queryset.""" | |
return search_engine_1.search(self.query, models=self.get_models(), exclude=self.get_exclude()) | |
class SearchEngine2View(SearchView): | |
def get_queryset(self): | |
"""Returns the initial queryset.""" | |
return search_engine_2.search(self.query, models=self.get_models(), exclude=self.get_exclude()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment