Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

sort criteria on invalid field should report well-formed json error #220

Open
dnesting opened this issue Sep 18, 2015 · 2 comments
Open

Comments

@dnesting
Copy link
Contributor

We've seen this a few times in production. It's not clear how I can reproduce it and it may be the result of someone playing with the API, but we should not generate internal errors as a result of bad user input.

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] 
{"error":"SearchPhaseExecutionException[Failed to execute phase [query_fetch], all shards failed; shardFailures {[7WAeJDHBSg-crOH2AwOEMg][production-school-data][0]: SearchParseException[[production-school-data][0]: query[ConstantScore(*:*)],from[0],size[20]: Parse Failure [Failed to parse source [{\"from\":0,\"size\":20,\"query\":{\"match_all\":{}},\"_source\":{\"exclude\":[\"_*\"]},\"sort\":[{\"advantage\":{\"order\":\"desc\"}}]}]]]; nested: 
SearchParseException[[production-school-data][0]: query[ConstantScore(*:*)],from[0],size[20]: Parse Failure [No mapping found for [advantage] in order to sort on]]; }]","status":400}

…t-1.0.12/lib/elasticsearch/transport/transport/base.rb: 135:in `__raise_transport_error'
…t-1.0.12/lib/elasticsearch/transport/transport/base.rb: 227:in `perform_request'
…/lib/elasticsearch/transport/transport/http/faraday.rb:  20:in `perform_request'
…transport-1.0.12/lib/elasticsearch/transport/client.rb: 119:in `perform_request'
…rch-api-1.0.12/lib/elasticsearch/api/actions/search.rb: 159:in `search'
                       /home/vcap/app/lib/data_magic.rb:  82:in `search'
@ultrasaurus
Copy link
Contributor

Indeed, seems to be someone experimenting with the API. I can reproduce locally with 4 years of College Scorecard data:

http://localhost:3000/v1/schools?sort=advantage:desc

Definitely a bug

@ultrasaurus
Copy link
Contributor

note: in general sort does work. Using the dafault cities data in sample-data, this works: http://localhost:3000/v1/cities?sort=population:desc

However, this doesn't: http://localhost:3000/v1/cities?sort=whatever:desc

this is an issue with error reporting when you try to sort by a field that is not available.

@ultrasaurus ultrasaurus changed the title ElasticSearch BadRequest on match_all with sort criteria sort criteria on invalid field should report well-formed json error Nov 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants