opensearch-project / sql

Query your data using familiar SQL or intuitive Piped Processing Language (PPL)
https://opensearch.org/docs/latest/search-plugins/sql/index/
Apache License 2.0
120 stars 139 forks source link

Whether or not support sort filter operation by sql #301

Open smallAttr opened 2 years ago

smallAttr commented 2 years ago

Is your feature request related to a problem? Please describe. Whether or not support sort filter operation by sql? for example:

  1. put data to es index: PUT /my_index/blogpost/2 { "title": "Investment secrets", "body": "What they don't tell you ...", "tags": [ "shares", "equities" ], "comments": [ { "name": "Mary Brown", "comment": "Lies, lies, lies", "age": 42, "stars": 1, "date": "2014-10-18" }, { "name": "John Smith", "comment": "You're making it up!", "age": 28, "stars": 2, "date": "2014-10-16" } ] }
  2. dsl expression GET /_search { "query": { "nested": { "path": "comments", "filter": { "range": { "comments.date": { "gte": "2014-10-01", "lt": "2014-11-01" } } } } }, "sort": { "comments.stars": { "order": "asc", "mode": "min", "nested_filter": { "range": { "comments.date": { "gte": "2014-10-01", "lt": "2014-11-01" } } } } } }

Describe the solution you'd like so, how to do resolve it by sql? up to now , can not find any relevant information?

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

smallAttr commented 2 years ago

@chloe-zh please

chloe-zh commented 2 years ago

Hi @smallAttr unfortunately we have not supported nested fields in sql new engine yet, so the new engine is not able to execute queries like your example. But I'm not sure if old engine supports it or not, I will try it out later and respond here.

Besides, for sort and filter for plain fields, you can try ,order by for sort and where for filter.