# Path: seeker/templatetags/seeker.py
# @register.filter
# def seeker_format(value):
#     if value is None:
#         return ''
#     # TODO: settings for default list separator and date formats?
#     if isinstance(value, datetime.datetime):
#         return value.strftime('%m/%d/%Y %H:%M:%S')
#     if isinstance(value, datetime.date):
#         return value.strftime('%m/%d/%Y')
#     if hasattr(value, '__iter__') and not isinstance(value, six.string_types):
#         return ', '.join(force_text(v) for v in value)
#     return force_text(value)
# 
# Path: seeker/mapping.py
# DEFAULT_ANALYZER = getattr(settings, 'SEEKER_DEFAULT_ANALYZER', 'snowball')
# 
# Path: seeker/signals.py



from django.conf import settings
from django.contrib import messages
from django.http import Http404, JsonResponse, QueryDict, StreamingHttpResponse
from django.shortcuts import redirect, render
from django.template import Context, RequestContext, loader, TemplateDoesNotExist
from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.http import urlencode
from django.utils.safestring import mark_safe
from django.views.generic import View
from elasticsearch_dsl.utils import AttrList
from seeker.templatetags.seeker import seeker_format
from .mapping import DEFAULT_ANALYZER
from .signals import search_complete
        from .models import SavedSearch
import elasticsearch_dsl as dsl
import six
import collections
import inspect
import re
        Returns the "saved_search" GET parameter if it's in the proper format, otherwise returns None.
        """
        saved_search_vals = [val for val in self.request.GET.getlist('saved_search') if val]
        if len(saved_search_vals) == 1 and saved_search_vals[0].isdigit():
            return saved_search_vals[0]
        return None

    def get_facet_data(self, initial=None, exclude=None):
        if initial is None:
            initial = {}
        facets = collections.OrderedDict()
        for f in self.get_facets():
            if f.field != exclude:
                facets[f] = self.request.GET.getlist(f.field) or initial.get(f.field, [])
        return facets

    def get_search_fields(self, mapping=None, prefix=''):
        if self.search:
            return self.search
        elif mapping is not None:
            fields = []
            for field_name in mapping:
                if mapping[field_name].to_dict().get('analyzer') == DEFAULT_ANALYZER:
                    fields.append(prefix + field_name)
                if hasattr(mapping[field_name], 'properties'):
                    fields.extend(self.get_search_fields(mapping=mapping[field_name].properties, prefix=prefix + field_name + '.'))
            return fields
        else:
            return self.get_search_fields(mapping=self.document._doc_type.mapping)


# Path: seeker/templatetags/seeker.py
# @register.filter
# def seeker_format(value):
#     if value is None:
#         return ''
#     # TODO: settings for default list separator and date formats?
#     if isinstance(value, datetime.datetime):
#         return value.strftime('%m/%d/%Y %H:%M:%S')
#     if isinstance(value, datetime.date):
#         return value.strftime('%m/%d/%Y')
#     if hasattr(value, '__iter__') and not isinstance(value, six.string_types):
#         return ', '.join(force_text(v) for v in value)
#     return force_text(value)
# 
# Path: seeker/mapping.py
# DEFAULT_ANALYZER = getattr(settings, 'SEEKER_DEFAULT_ANALYZER', 'snowball')
# 
# Path: seeker/signals.py



# Path: seeker/views.py
from django.conf import settings
from django.contrib import messages
from django.http import Http404, JsonResponse, QueryDict, StreamingHttpResponse
from django.shortcuts import redirect, render
from django.template import Context, RequestContext, loader, TemplateDoesNotExist
from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.http import urlencode
from django.utils.safestring import mark_safe
from django.views.generic import View
from elasticsearch_dsl.utils import AttrList
from seeker.templatetags.seeker import seeker_format
from .mapping import DEFAULT_ANALYZER
from .signals import search_complete
        from .models import SavedSearch
import elasticsearch_dsl as dsl
import six
import collections
import inspect
import re

        Returns the "saved_search" GET parameter if it's in the proper format, otherwise returns None.
        """
        saved_search_vals = [val for val in self.request.GET.getlist('saved_search') if val]
        if len(saved_search_vals) == 1 and saved_search_vals[0].isdigit():
            return saved_search_vals[0]
        return None

    def get_facet_data(self, initial=None, exclude=None):
        if initial is None:
            initial = {}
        facets = collections.OrderedDict()
        for f in self.get_facets():
            if f.field != exclude:
                facets[f] = self.request.GET.getlist(f.field) or initial.get(f.field, [])
        return facets

    def get_search_fields(self, mapping=None, prefix=''):
        if self.search:
            return self.search
        elif mapping is not None:
            fields = []
            for field_name in mapping:
                if mapping[field_name].to_dict().get('analyzer') == DEFAULT_ANALYZER:
                    fields.append(prefix + field_name)
                if hasattr(mapping[field_name], 'properties'):
                    fields.extend(self.get_search_fields(mapping=mapping[field_name].properties, prefix=prefix + field_name + '.'))
            return fields
        else:
            return self.get_search_fields(mapping=self.document._doc_type.mapping)


    def get_search_query_type(self, search, keywords, analyzer=DEFAULT_ANALYZER):