Skip to content

Instantly share code, notes, and snippets.

@mythmon
Created February 4, 2013 22:36
Show Gist options
  • Save mythmon/4710376 to your computer and use it in GitHub Desktop.
Save mythmon/4710376 to your computer and use it in GitHub Desktop.
I think I can't filter by null.
(InteractiveConsole)
>>> from questions.models import Question
>>> Question.search().values_dict()[0]
{u'product': [u'firefox'], u'updated': 1356126726, u'question_num_answers': 0, u'question_is_solved': False, u'question_has_answers': False, u'question_is_locked': True, u'topic': [u'websites'], u'question_tag': [u'Firefox 17.0', u'websites', u'desktop', u'Windows XP'], u'id': 944987, u'question_has_helpful': False, u'question_locale': None, u'created': 1356126726, u'url': u'/questions/944987', u'question_title': u'Jquery? One of the most used Java Scripts, Causing major problems.', u'question_content': u'<SNIP>', u'question_num_votes_past_week': 0, u'question_answer_creator': [], u'question_answer_content': [], u'question_creator': u'ProfNeal', u'model': u'questions_question', u'question_num_votes': 1, u'indexed_on': 1360015129}
>>> print _['question_locale']
None
>>> Question.search().filter(question_locale=None).values_dict()[0]
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/mythmon/src/kitsune/vendor/src/elasticutils/elasticutils/__init__.py", line 467, in __getitem__
return list(new)[0]
File "/home/mythmon/src/kitsune/vendor/src/elasticutils/elasticutils/__init__.py", line 706, in __iter__
return iter(self._do_search())
File "/home/mythmon/src/kitsune/vendor/src/elasticutils/elasticutils/__init__.py", line 645, in _do_search
hits = self.raw()
File "/home/mythmon/src/kitsune/vendor/src/elasticutils/elasticutils/contrib/django/__init__.py", line 201, in raw
hits = super(S, self).raw()
File "/home/mythmon/src/kitsune/vendor/src/elasticutils/elasticutils/__init__.py", line 700, in raw
hits = es.search(qs, self.get_indexes(), self.get_doctypes())
File "/home/mythmon/src/kitsune/vendor/packages/pyes/pyes/es.py", line 841, in search
return self._query_call("_search", body, indexes, doc_types, **query_params)
File "/home/mythmon/src/kitsune/vendor/packages/pyes/pyes/es.py", line 251, in _query_call
response = self._send_request('GET', path, body, querystring_args)
File "/home/mythmon/src/kitsune/vendor/packages/pyes/pyes/es.py", line 223, in _send_request
raise_if_error(response.status, decoded)
File "/home/mythmon/src/kitsune/vendor/packages/pyes/pyes/convert_errors.py", line 68, in raise_if_error
raise excClass(msg, status, result)
SearchPhaseExecutionException: Failed to execute phase [query], total failure; shardFailures {[b9ZLwu8WTKqUoDJ7V8UDZw][sumo_sumo-20121227][0]: SearchParseException[[sumo_sumo-20121227][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"filter": {"and": [{"term": {"model": "questions_question"}}, {"term": {"question_locale": null}}]}, "size": 1}]]]; nested: QueryParsingException[[sumo_sumo-20121227] No field specified for term filter]; }{[b9ZLwu8WTKqUoDJ7V8UDZw][sumo_sumo-20121227][1]: SearchParseException[[sumo_sumo-20121227][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"filter": {"and": [{"term": {"model": "questions_question"}}, {"term": {"question_locale": null}}]}, "size": 1}]]]; nested: QueryParsingException[[sumo_sumo-20121227] No field specified for term filter]; }{[b9ZLwu8WTKqUoDJ7V8UDZw][sumo_sumo-20121227][2]: SearchParseException[[sumo_sumo-20121227][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"filter": {"and": [{"term": {"model": "questions_question"}}, {"term": {"question_locale": null}}]}, "size": 1}]]]; nested: QueryParsingException[[sumo_sumo-20121227] No field specified for term filter]; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment