Skip to content
This repository has been archived by the owner. It is now read-only.

API date queries need to be YYYY-MM-DD not YYYY/MM/DD #452

Closed
tmtmtmtm opened this issue May 9, 2014 · 2 comments · Fixed by mysociety/popit.poplus.org#40
Labels

Comments

@tmtmtmtm
Copy link
Contributor

@tmtmtmtm tmtmtmtm commented May 9, 2014

The docs say to do /api/v0.1/search/memberships?q=start_date:[2013/01/01+TO+2013/12/31]

However http://eduskunta.popit.mysociety.org/api/v0.1/search/memberships?q=start_date:[2013/01/01+TO+2013/12/31] 500s:

Express
500 Error: SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[Ea5gAOiqTOeZRKSfXTHfyA][popit_eduskunta][0]: SearchParseException[[popit_eduskunta][0]: from[0],size[30]: Parse Failure [Failed to parse source [{"from":0,"size":30,"query":{"query_string":{"query":"start_date:[2013/01/01 TO 2013/12/31]","lowercase_expanded_terms":true,"analyze_wildcard":false}}}]]]; nested: ElasticSearchParseException[failed to parse date field [2013/01/01], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2013/01/01" is malformed at "/01/01"]; }{[Ea5gAOiqTOeZRKSfXTHfyA][popit_eduskunta][2]: SearchParseException[[popit_eduskunta][2]: from[0],size[30]: Parse Failure [Failed to parse source [{"from":0,"size":30,"query":{"query_string":{"query":"start_date:[2013/01/01 TO 2013/12/31]","lowercase_expanded_terms":true,"analyze_wildcard":false}}}]]]; nested: ElasticSearchParseException[failed to parse date field [2013/01/01], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2013/01/01" is malformed at "/01/01"]; }{[Ea5gAOiqTOeZRKSfXTHfyA][popit_eduskunta][1]: SearchParseException[[popit_eduskunta][1]: from[0],size[30]: Parse Failure [Failed to parse source [{"from":0,"size":30,"query":{"query_string":{"query":"start_date:[2013/01/01 TO 2013/12/31]","lowercase_expanded_terms":true,"analyze_wildcard":false}}}]]]; nested: ElasticSearchParseException[failed to parse date field [2013/01/01], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2013/01/01" is malformed at "/01/01"]; }{[Ea5gAOiqTOeZRKSfXTHfyA][popit_eduskunta][4]: SearchParseException[[popit_eduskunta][4]: from[0],size[30]: Parse Failure [Failed to parse source [{"from":0,"size":30,"query":{"query_string":{"query":"start_date:[2013/01/01 TO 2013/12/31]","lowercase_expanded_terms":true,"analyze_wildcard":false}}}]]]; nested: ElasticSearchParseException[failed to parse date field [2013/01/01], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2013/01/01" is malformed at "/01/01"]; }{[Ea5gAOiqTOeZRKSfXTHfyA][popit_eduskunta][3]: SearchParseException[[popit_eduskunta][3]: from[0],size[30]: Parse Failure [Failed to parse source [{"from":0,"size":30,"query":{"query_string":{"query":"start_date:[2013/01/01 TO 2013/12/31]","lowercase_expanded_terms":true,"analyze_wildcard":false}}}]]]; nested: ElasticSearchParseException[failed to parse date field [2013/01/01], tried both date format [dateOptionalTime], and timestamp number]; nested: IllegalArgumentException[Invalid format: "2013/01/01" is malformed at "/01/01"]; }]
at respond (/data/vhost/popit.mysociety.org/popit/node_modules/popit-api/node_modules/elasticsearch/src/lib/transport.js:225:15)
at checkRespForFailure (/data/vhost/popit.mysociety.org/popit/node_modules/popit-api/node_modules/elasticsearch/src/lib/transport.js:193:7)
at HttpConnector. (/data/vhost/popit.mysociety.org/popit/node_modules/popit-api/node_modules/elasticsearch/src/lib/connectors/http.js:152:7)
at IncomingMessage.bound (/data/vhost/popit.mysociety.org/popit/node_modules/popit-api/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)

http://eduskunta.popit.mysociety.org/api/v0.1/search/memberships?q=start_date:[2013-01-01+TO+2013-12-31] works as expected.

@tmtmtmtm

This comment has been minimized.

Copy link
Contributor Author

@tmtmtmtm tmtmtmtm commented May 9, 2014

As well as changing the documentation (which I would have done, except I'm not sure where the definitive version currently is — popit.poplus.org?), we probably want to handle errors like this better too.

@chrismytton

This comment has been minimized.

Copy link
Member

@chrismytton chrismytton commented May 9, 2014

Until mysociety/popit.poplus.org#3 is tackled the documentation in this repository remains the definitive version. I agree that the error handling in popit is generally a bit lacking, I've opened #453 to track that.

@TomSteinberg TomSteinberg added the EE label Jun 2, 2014
tmtmtmtm added a commit to mysociety/popit.poplus.org that referenced this issue Mar 4, 2015
Ranges are formed as [2013-01-01+TO+2013-12-31] not [2013/01/01+TO+2013/12/31]

Closes mysociety/popit#452
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.