title: Django Rest Framework Elastic Search: RequestError 400 parsing_exception
body: <p>When trying to query for event documents that match this condition, I'm getting a parsing exception and I'm not sure what's causing it. This is occurring in my custom get_queryset method. In my get_query in my document view set I'm getting an error.</p>
  
  <pre><code>def get_queryset(self):
      qs = super().get_queryset()
      user = self.request.user
  
      if hasattr(user, 'userprofile'):
          user_universities = user.userprofile.universities.all().values_list("id")
          user_universities_campus = user.userprofile.universities.all().values_list("main_campus__id")
  
  
          query = query | Q('bool', must=[
              Q('match', visibility_scope=Event.UNIVERSITY),
              Q('bool', must=[
                  Q('terms', university__id=list(user_universities)),
                  Q('bool', should=[
                      Q('terms', university__main_campus__id=list(user_universities)),
                      Q('terms', university__main_campus__id=list(user_universities_campus))
                  ])
              ])
          ])
  
      qs = qs.query(query)
      return qs
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <pre><code>        if self.count == 0 and not self.allow_empty_first_page:
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\django\utils\functional.py", line 80, in __get__
          res = instance.__dict__[self.name] = self.func(instance)
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\django\core\paginator.py", line 91, in count
          return c()
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\elasticsearch_dsl\search.py", line 679, in count
          **self._params
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\elasticsearch\client\utils.py", line 84, in _wrapped
          return func(*args, params=params, **kwargs)
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\elasticsearch\client\__init__.py", line 529, in count
          "POST", _make_path(index, doc_type, "_count"), params=params, body=body
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\elasticsearch\transport.py", line 358, in perform_request
          timeout=timeout,
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 261, in perform_request
          self._raise_error(response.status, raw_data)
        File "C:\Users\fendy\.virtualenvs\cul\lib\site-packages\elasticsearch\connection\base.py", line 182, in _raise_error
          status_code, error_message, additional_info
      elasticsearch.exceptions.RequestError: RequestError(400, 'parsing_exception', '[terms] unknown token [END_ARRAY] after [university.id]')
  </code></pre>
  
  <p>Query String printout:</p>
  
  <pre><code>Bool(should=[Bool(must=[Match(visibility_scope=2), Bool(must=[Terms(university__id=[(42809,)]), Bool(should=[Terms(university__main_campus__id=[(42809,)]), Terms(university__main_campus__id=[(None,)])])])]), Match(visibility_scope=0)])
  </code></pre>