-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DATETIME__lt lookup results in ParseException for Elasticsearch #45
Comments
Hi, Thanks for the (detailed) report. I'll have a closer look at it when I've got a bit more time. I'm a little busy this week, so please be patient with me =) |
If it helps I just tried downgrading Django to 1.8.9 and Django Haystack to 2.4.1 (to fix another issue I was having with building the index through the haystack management options) and the issue is still there :( |
No, the problem is in drf-haystack, probably because the |
Hello, I've also added some test cases for your issue. |
Hi, So I replaced in my requirements.txt. Never referenced a specific branch from my requirements.txt from github, is that done correctly? I have 9 items indexed. 1 created on April 22 2016 and then 8 created on April 23 2016 ?submission__gt=2016-04-21 So unless I did anything wrong with referencing the branch it appears to have the same problem :( SMALL OFF TOPIC: But when I click the narrow_url for either of them, the result is always Submission facet specification in the serializer: All other facets I have work perfectly |
Hmm, thats weird. I did notice one thing in your
It seems like you have only inherited from If it works with a simpler index, try to build up from there. |
I only inherit indexes.SearchIndex at the top level, I dont want to index the abstract classes I have. The three classes I want to Index all inherit from indexes.Indexable (ModelItem, ModelFamily, ModelRepository). I will try something simpler and see if I can get anywhere |
Here is the whole stacktrace, forgot to add that to the original post Failed to query Elasticsearch using '(submission:({* TO "2016\-04\-24"}) AND submission:({* TO "2016\\\-04\\\-24"}))': TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[_bfbRn60RyC2qSP-3bKyiw][haystack][0]: SearchParseException[[haystack][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["model.modelitem", "model.modelrepository", "model.modelfamily"]}}, "query": {"query_string": {"query": "(submission:({* TO \\"2016\\\\-04\\\\-24\\"}) AND submission:({* TO \\"2016\\\\\\\\\\\\-04\\\\\\\\\\\\-24\\"}))", "default_operator": "AND", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "size": 1, "from": 0, "highlight": {"fields": {"text": {"store": "yes"}}}}]]]; nested: ElasticsearchParseException[failed to parse date field [2016\\-04\\-24], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2016\\-04\\-24" is malformed at "\\-04\\-24"]; }]')
Traceback (most recent call last):
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 516, in search
_source=True)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 531, in search
doc_type, '_search'), params=params, body=body)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 307, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 93, in perform_request
self._raise_error(response.status, raw_data)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 105, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
RequestError: TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[_bfbRn60RyC2qSP-3bKyiw][haystack][0]: SearchParseException[[haystack][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["model.modelitem", "model.modelrepository", "model.modelfamily"]}}, "query": {"query_string": {"query": "(submission:({* TO \\"2016\\\\-04\\\\-24\\"}) AND submission:({* TO \\"2016\\\\\\\\\\\\-04\\\\\\\\\\\\-24\\"}))", "default_operator": "AND", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "size": 1, "from": 0, "highlight": {"fields": {"text": {"store": "yes"}}}}]]]; nested: ElasticsearchParseException[failed to parse date field [2016\\-04\\-24], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2016\\-04\\-24" is malformed at "\\-04\\-24"]; }]')
Failed to query Elasticsearch using '(submission:({* TO "2016\-04\-24"}) AND submission:({* TO "2016\\\-04\\\-24"}))': TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[_bfbRn60RyC2qSP-3bKyiw][haystack][0]: SearchParseException[[haystack][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["model.modelitem", "model.modelrepository", "model.modelfamily"]}}, "query": {"query_string": {"query": "(submission:({* TO \\"2016\\\\-04\\\\-24\\"}) AND submission:({* TO \\"2016\\\\\\\\\\\\-04\\\\\\\\\\\\-24\\"}))", "default_operator": "AND", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "highlight": {"fields": {"text": {"store": "yes"}}}}]]]; nested: ElasticsearchParseException[failed to parse date field [2016\\-04\\-24], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2016\\-04\\-24" is malformed at "\\-04\\-24"]; }]')
Traceback (most recent call last):
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 516, in search
_source=True)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 531, in search
doc_type, '_search'), params=params, body=body)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 307, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 93, in perform_request
self._raise_error(response.status, raw_data)
File "/home/ari/Workspace/DTU/moccasin-backend/env/local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 105, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
RequestError: TransportError(400, u'SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[_bfbRn60RyC2qSP-3bKyiw][haystack][0]: SearchParseException[[haystack][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"filtered": {"filter": {"terms": {"django_ct": ["model.modelitem", "model.modelrepository", "model.modelfamily"]}}, "query": {"query_string": {"query": "(submission:({* TO \\"2016\\\\-04\\\\-24\\"}) AND submission:({* TO \\"2016\\\\\\\\\\\\-04\\\\\\\\\\\\-24\\"}))", "default_operator": "AND", "default_field": "text", "auto_generate_phrase_queries": true, "analyze_wildcard": true}}}}, "from": 0, "highlight": {"fields": {"text": {"store": "yes"}}}}]]]; nested: ElasticsearchParseException[failed to parse date field [2016\\-04\\-24], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2016\\-04\\-24" is malformed at "\\-04\\-24"]; }]')
[27/Apr/2016 13:53:14] "GET /api/model/search/?submission__lt=2016-04-24 HTTP/1.1" 200 52 |
I think I might have solved it? I have In my view If I change it to Now I get 10x results for ?submission__lt=2016-04-24 So might be a problem with the other two filter backends? I got this idea from looking at your tests and wondering why they worked :) |
Changed my requirements.txt to reference drf-haystack==1.5.6 again. Works there as well. |
Ah, hehe, nice spotted! Autocomplete should probably have a separate view. |
Could you please just confirm and close the issue? |
Hi guys,
Great project :)
I am however in a bit of a pickle. Ive setup ElasticSearch, Django Haystack and drf-haystack in my project and it mostly seems to work great. Ive tried a lot of things and I am completely stumped so I am hoping someone here might have an idea whats going on :)
But when I execute this query (submission is a datetime):
I get 0 results and the following error in my PyCharm console:
But when I execute
Setup:
OS: Ubuntu 15.10
Python: 2.7.10
Elasticsearch: 1.6.2
From requirements.txt:
Django: 1.9.1
Haystack: 2.5.dev0 (Else it doesnt work with Django 1.9)
drf-haystack==1.5.6
elasticsearch==1.9.0
I’ve tried downgrading Django to 1.8 and Haystack to 2.4 but I had the same error. I’ve tried a few other combinations of versions but there is always something that breaks :) Usually the same error or facet search didnt work.
I ran the same query using the python shell (using just haystack):
Which led me to believe this has something to do with drf-haystack :) Any help would be greatly appreciated, I am completely stumped on how to fix this.
The faceted search works for all fields, apart from the submission field. When I click the narrow_url (that has a count of 6) and execute that query, it returns 0 results. Maybe that is related somehow?
Well here is my code if that helps:
urls.py:
views.py:
search_indexes.py:
All template _text.txt files look like this (model item, model family and model repository) :
The text was updated successfully, but these errors were encountered: