Allow for complex search JSON, including sort
Allow for complex search JSON, including sort

Elasticsearch allows for sorting and a few other advanced search features, but they require the JSON request to be formatted with top-level keys other than just "query". Previously, Flashlight limited the JSON post to only the "query" key. The proposed change near line 22 would allow for a more complex query to be submitted.

If the JSON object contains a top-level key named "query", then the JSON will be passed as-is. If it does not contain the "query" key, it will automatically be added (keeping this change reverse-compatible).

Example 1 (same as previous behavior): 

    { "term": { "user": "kimchy" } } 

would be converted to:

    { "query": { "term": { "user": "kimchy" } } }

Example 2 (additional new behavior):

    { "query": { "term": { "user": "kimchy" } }, "sort": [{ "name": { "order": "desc" } }] }

would be submitted as-is because it already contains the top-level "query" key.
Bloggify/elasticfire