appbaseio / reactivesearch

Search UI components for React and Vue
https://opensource.appbase.io/reactivesearch
Apache License 2.0
4.9k stars 466 forks source link

sortBy doesn't work in MultiDropdownList anymore. #2058

Open allendol opened 2 years ago

allendol commented 2 years ago

We use Reactiveasearch pointing to ElasticSeacrh 6.x Recently we migrated ElasticSeacrh 6.8 to ElasticSeacrh 8.x Now sortBy doesn't work in MultiDropdownList . I have to comment it in order I see data in MultiDropdownList.

Describe the bug

To Reproduce

Steps to reproduce the behavior:

Expected behavior

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

siddharthlatest commented 2 years ago

@allendol Can you share a CSB where this issue is replicable?

allendol commented 2 years ago

@siddharthlatest where can I share? Is there any sandbox I can use?

siddharthlatest commented 2 years ago

@allendol You can take this as a base: https://codesandbox.io/s/compassionate-forest-g9ej6f, and update to point to an ES instance where this issue can be reproduced.

allendol commented 2 years ago

@siddharthlatest stupid question. When I change something in above, how can I save and run it?

waotaa commented 2 years ago

with version: "@appbaseio/reactivesearch-vue@1.30.0"

I also recently upgraded my packages and experience an error with the sortBy. In singlelists and multilists with for example sortBy="asc"

The error I get in my console is: {"error":{"root_cause":[{"type":"aggregation_execution_exception","reason":"Invalid aggregation order path [_term]. The provided aggregation [_term] either does not exist, or is a pipeline aggregation and cannot be used to sort the buckets."}

allendol commented 2 years ago

@siddharthlatest I have narrowed down the problem. When I am using ElasticSearch 6 the query generated from ReactiveSearch is as below. {"preference":"Selected Dis"} {"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"should":[{"terms":{"supt.keyword":["Supply and Service"]}}]}}]}}]}},"size":0,"aggs":{"office.keyword":{"terms":{"field":"office.keyword","size":1000,"order":{"_term":"asc"}}}}} In above _term used to to the order by. This is working. In ELasticSearch 8. "_term":"asc" gives error In ELasticSearch 8. the query should be converted to _key":"desc" But the version of ReactiveSearch I have it doesn't generate _key":"desc". It still generated _term":"asc" and this is giving error. Query below order by count which I don't want. I want to be ordered by name not count. {"preference":"Selected Dis"} {"query":{"bool":{"must":[{"bool":{"must":[{"bool":{"should":[{"terms":{"supt.keyword":["Supply and Service"]}}]}}]}}]}},"size":0,"aggs":{"office.keyword":{"terms":{"field":"office.keyword","size":1000,"order":{"_count":"asc"}}}}} The error I get is: "reason": "_Invalid aggregation order path [_term]. Cannot find aggregation named [term]" Environment: Elasticsearch 8 and old Reactivesearch

siddharthlatest commented 2 years ago

@allendol Which version of the library are you using? I can't reproduce this in v3.38.3 (or above), the network request sent does use _key to sort on, tested with MultiDropdownList component:

{"preference":"BookSensor"}
{"query":{"match_all":{}},"size":0,"aggs":{"original_series.keyword":{"terms":{"field":"original_series.keyword","size":100,"order":{"_key":"asc"}}}}}

Can you share a CodeSandbox where the issue is reproducible?