LibrePhotos / librephotos

A self-hosted open source photo management service. This is the repository of the backend.
MIT License
6.81k stars 297 forks source link

Sort search results by most images #301

Open grasponcrypto opened 3 years ago

grasponcrypto commented 3 years ago

Describe the enhancement you'd like When searching, both for images and to tag faces, the results would be better served if returning results with most images first.

Describe why this will benefit the LibrePhotos The majority of the time this would likely serve better than the current result algorithm of what i assume is closest match alphabetically - but thats just guessing on behavior.

Additional context Not sure any is necessary, if so I can expand upon request.

derneuere commented 3 years ago

This here is the search component: https://github.com/LibrePhotos/librephotos-frontend/blob/dev/src/components/CustomSearch.js

It calls this function when it gets mounted: https://github.com/LibrePhotos/librephotos-frontend/blob/349a9347f74999b1ac865b44cb363947096b11f5/src/components/CustomSearch.js#L76

All it currently does is read from util.store.exampleSearchTerms which gets set with this function https://github.com/LibrePhotos/librephotos-frontend/blob/349a9347f74999b1ac865b44cb363947096b11f5/src/actions/utilActions.js#L360-L374

It currently just filters the exampleSearchTerms by the term that the user put in.

The exampleSearchTerms get calculated here: https://github.com/LibrePhotos/librephotos/blob/624b5323b90059b668fb185b35ced6cdd20679f9/api/api_util.py#L120

With the API endpoint specified here: https://github.com/LibrePhotos/librephotos/blob/624b5323b90059b668fb185b35ced6cdd20679f9/ownphotos/urls.py#L227

I think what we want is a new API endpoint, that gets the list of possible search queries sorted by the amount of pictures. This should be then called by custom search every time the input changes.