Skip to content

Commit e66b7e2

Browse files
committed
enh: sort search results by creation date instead of score and modified date
1 parent 8fa9800 commit e66b7e2

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
0.17.5
22
- fix: error handling when connection to server fails on download (#75)
33
- enh: add `CKANAPI.hostname`
4+
- enh: sort search results by creation date instead of score and modified date
45
- ref: replace `user_list` with `user_autocomplete`
56
- ref: replace `search_dataset` with `search_dataset_via_api`
67
in `APIInterrogator`; `search_dataset` is now only free text search.

dcoraid/dbmodel/db_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def search_dataset_via_api(self,
137137
circles: list[str] = None,
138138
collections: list[str] = None,
139139
circle_collection_union: bool = False,
140+
sort_solr: str = "metadata_created desc",
140141
limit: int = 100):
141142
"""Search datasets via the CKAN API
142143
@@ -155,6 +156,11 @@ def search_dataset_via_api(self,
155156
sets. Otherwise (default), search only for datasets that
156157
are at least member of one of the circles and one of the
157158
collections.
159+
sort_solr: str
160+
SOLR search ordering. By default, sort according to dataset
161+
creation date `'metadata_created desc'`. The CKAN default is
162+
`'score desc, metadata_modified desc'`.
163+
https://docs.ckan.org/en/latest/api/index.html#ckan.logic.action.get.package_search
158164
limit: int
159165
limit number of search results; Set to 0 to get all results
160166
"""
@@ -216,6 +222,7 @@ def search_dataset_via_api(self,
216222
fq=final_fq,
217223
include_private=(self.mode == "user"),
218224
rows=rows,
225+
sort=sort_solr,
219226
start=num_retrieved,
220227
)
221228
if np.isinf(num_total):

0 commit comments

Comments
 (0)