Skip to content

Instantly share code, notes, and snippets.

@kaedroho
Created February 26, 2015 15:44
Show Gist options
  • Save kaedroho/e86e3402936154ccdd79 to your computer and use it in GitHub Desktop.
Save kaedroho/e86e3402936154ccdd79 to your computer and use it in GitHub Desktop.
from wagtail.wagtailsearch.backends import get_search_backend
from wagtail.wagtailsearch.backends.elasticsearch import ElasticSearchResults
class AwesomeQuery(object):
def __init__(self, search_query, campaign, country, language):
self.search_query = search_query
self.campaign = campaign
self.country = country
self.language = language
@property
def queryset(self):
# Just has to return any queryset of Page
# This is used by ElasticSearchResults to find the model to return
return Page.objects.all()
def to_es(self):
# TODO
def search(search_query, campaign, country, language):
s = get_search_backend()
return ElasticSearchResults(s, AwesomeQuery(search_query, campaign, country, language))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment