title: Django Elastic Search DSL with faceted Search
body: <p>I am using ElasticSearch-DSL with my Django App to search for products.
  I am able to fetch the results and put them in my template (search.html) and it is working as expected.</p>
  
  <p>I did some research but could not figure out how to add faceted search to my templates and how to implement faceted search.</p>
  
  <p>My documents.py </p>
  
  <pre><code>from django_elasticsearch_dsl import Document
  from django_elasticsearch_dsl.registries import registry
  from products.models import Products
  from elasticsearch_dsl import FacetedSearch, TermsFacet, DateHistogramFacet
  
  
  @registry.register_document
  class CarDocument(Document):
      class Index:
          # Name of the Elasticsearch index
          name = 'cars'
          # See Elasticsearch Indices API reference for available settings
          settings = {'number_of_shards': 1,
                      'number_of_replicas': 1}
  
  
  
      class Django:
          model = Products # The model associated with this Document
  
          # The fields of the model you want to be indexed in Elasticsearch
          fields = [
              'body_id',
              'product_make',
              'model_name',
              'product_id',
              'model_id', 
              'variant',
              'transmission',
              'bodystyle',
              'yom',
              'status',
              'ex_showroom',
              'registration_fees',
              'insurance',
              'handling_charges',
              'fastag',
              'on_road_price',
              'min_price',
              'max_price',
              'rating',
  
          ]
  
          # Ignore auto updating of Elasticsearch when a model is saved
          # or deleted:
          # ignore_signals = True
  
          # Don't perform an index refresh after every update (overrides global setting):
          # auto_refresh = False
  
          # Paginate the django queryset used to populate the index with the specified size
          # (by default it uses the database driver's default setting)
          # queryset_pagination = 5000
  </code></pre>
  
  <p>and my views.py code is mentioned below:</p>
  
  <pre><code>from django.shortcuts import render
  from elasticsearch_dsl import Q
  from elasticsearch_dsl.query import MultiMatch
  # Create your views here.
  from search.documents import CarDocument
  from products.models import Products
  from django.core.paginator import (
      Paginator, Page, EmptyPage, PageNotAnInteger
  )
  from django.utils.functional import LazyObject
  
  def search(request):
     q = request.GET.get('q')
     if q:
         #cars = CarDocument.search().query("match", model_name=q)
        q = request.GET.get('q', None)
        query1 = MultiMatch(query=q,  fields=['product_make', 'bodystyle','model_name','variant','transmission','yom'],fuzziness='AUTO')
  
        s = CarDocument.search().query(query1)
        total = s.count()
        s= s[0:total]
        cars = s.execute()
  
        paginator = Paginator(cars, 100)
        page = request.GET.get('page')
        cars = paginator.get_page(page)
     else:
        cars = ''
  
  
     return render(request, 'search/search.html', {'cars': cars})
  
  def product_detail(request,*args, **kwargs):
  
      return render(request, 'product_details.html', {})
  </code></pre>
  
  <p>My urls.py</p>
  
  <pre><code>urlpatterns = [
      url(r'^$', home_view, name='home'),
      url(r'^home/', home_view, name='home'),
      url(r'^search/', search, name='search'),
      url(r'^select/', select, name='select'),
      url('ajax/home_view/',home_view, name='ajax_load_models'),
      url(r'^carmodels/(?P&lt;product_make&gt;\w+)/(?P&lt;model_name&gt;\w+)/$', product_detail, name='product_detail'),
      ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  
  <p>My question is what changes should I make and where to use faceted search on product_make, body_style, max-min price range, etc.</p>