jcorporation / myMPD

myMPD is a standalone and mobile friendly web mpd client with a tiny footprint and advanced features.
https://jcorporation.github.io/myMPD/
GNU General Public License v3.0
412 stars 63 forks source link

search not working? #379

Closed quantenschaum closed 3 years ago

quantenschaum commented 3 years ago

myMPD version: 6.8.3 from your docker image

There are 2 search boxes in myMPD

  1. in the browse section
  2. in the search section of the UI

In my mpd database in an album called "morning songbirds"

$ mpc search album songbirds
Musik/E/Echoes of Nature/Morning Songbirds/01 Pacific Surf & Songbirds.mp3
Musik/E/Echoes of Nature/Morning Songbirds/02 Predawn.mp3
Musik/E/Echoes of Nature/Morning Songbirds/03 Rain With Pygmy Owl.mp3
Musik/E/Echoes of Nature/Morning Songbirds/04 Marsh.mp3
Musik/E/Echoes of Nature/Morning Songbirds/05 Sparkling Water.mp3
Musik/E/Echoes of Nature/Morning Songbirds/06 Brookside Bords.mp3
Musik/E/Echoes of Nature/Morning Songbirds/07 Bob White, Doves & Cardinals.mp3

It is found by myMPD when searching for in the search tab

image

But when I search for it in the browse tab, it is not found

image

Am I doing something wrong, or is this a bug?

jcorporation commented 3 years ago

Strange, this works in my setup. Please attach the mpd verbose and the myMPD debug log.

quantenschaum commented 3 years ago

Yupp, there is the problem (from mympm log): mympd searches with

"search "((Track == '1') AND (Disc == '1') AND (Album contains 'songbird'))" sort AlbumArtistSort window 0:100"

which does not get any hit, where as search "(Album contains 'songbird')" does.

Why does mympd add (Track == '1') AND (Disc == '1')?

With Track == '1' the search yields the first track of the album, but the files do not have the disk field set in their tags (because there is only one), so querying for it yields nothing.

It is probably done to reduce the amount of returned results, but assumes that the track and disk fields are present and contain the value of 1. This is not guarantied to be the case. It should be something like "track==1 or track is undefined". But this leaves the case of an album without a track==1.

jcorporation commented 3 years ago

Track and Disc is added to get unique album results. If you do not maintain the disc tag you should disable it. Or searches are not possible with mpd.

quantenschaum commented 3 years ago

OK. Where to disable it? Disk tag is maintained, but only for albums with more than one disk.

quantenschaum commented 3 years ago

Or searches are not possible with mpd.

Why not? mpc search album songbird works.

jcorporation commented 3 years ago

If you disable it you would get 2 entries for multidisc albums. You can disable it in settings -> general.

jcorporation commented 3 years ago

Why not? mpc album songbird works.

This is no or search, look at the mpd documentation for the new filter syntax since mpd 0.21. Your search searches the needle songbird in the haystack of album names.

quantenschaum commented 3 years ago

Found the settings.

Typo, I meant mpc search album songbird.This works, I just tried it. Or mpc search "(Album contains 'songbird')".

Of course, the you get multiple results per album, which need to be reduced afterwards.

jcorporation commented 3 years ago

It should be something like "track==1 or track is undefined"

This is not possible with mpd filter syntax.

quantenschaum commented 3 years ago

Your search searches the needle songbird in the haystack of album names.

Yes, that is exactly what I want. Give me all albums with "songbird" in the album name. Isn't this what the search is supposed to do?

jcorporation commented 3 years ago

But that’s only the list of unique album tags. The list has no reference to the associated albumartists.

quantenschaum commented 3 years ago

But that’s only the list of unique album tags.

What do mean by that? - So just from (my) user perspective. Given the album view (one cover per album) and a search box for album title, I would expect to get all the albums with the entered string in their name. This should be independent of the presence and value of any other tag fields, like track, disk or albumartist.

jcorporation commented 3 years ago

In this view you can search also by artist, genre etc. An album title is not unique, think about albums like greatest hits.

quantenschaum commented 3 years ago

Yes, sure. But what do you mean by "unique"? You will get many albums, all those, that have the search string in their name, no only a single (unique) one. You can of course filter by other fields as well. (Boolean operations other than AND, will say OR, would be cool as well. There are ==, !=, ..., but can I search for (album contains song OR album contains bird)?)

I think, the problem here is, that the mpd search does not return albums, it returns songs (single files) but you want to display them as albums (in the case of the album view).

IMHO it should work like this

  1. build the query sent to mpd, like ((artist == "Kraftwerk") AND (title == "Metall auf Metall")) (do not add any additional fields in order to try to make the search results "unique")
  2. get the result, the individual files
  3. for each file, get the album name (in case of album view) and collect them in a set (reduce them to unique values)
  4. the resulting set of album names are the albums that meet the filter criteria

This works for any view with any filter. filter -> map ->reduce

jcorporation commented 3 years ago

but can I search for (album contains song OR album contains bird)?)

No, this can not be done.

I hopped I could avoid to get the individual files and reduce the result set manually. This method Hase also some disadvantages: higher resource usage and more complicated code

quantenschaum commented 3 years ago

I can totally understand that you did it this way to get it working quickly and to let mpd do all the work handling the db query. And the search is super fast (>100k songs in the db), nice. But the downside is, that it produces wrong/crippled results (compared to my expectations). But I actually doubt that the filter-map-reduce thing would actually cause high resource usage and it is not really complicated, but necessary.

So removing the disc==1 condition would like improve the situation, then you multiple hits, one for each disk, but probably all albums, since very album is very likely to have track 1.

Turning the use of the disk tag off in the settings leads to many untitled empty albums when browsing the album view w/o filters. mympd queries mpd with search "((Track == '1'))". How is it possible that there are empty albums in search results?

image

image

jcorporation commented 3 years ago

I can not reproduce your issue with the untitled empty albums. Are there any errors in the myMPD log or the JavaScript console? Can you grab the api response from the network tab?

Actually myMPD relies on accurately taged files, momentanely I would not implement a workaround as you described, but the behavior should be documented to avoid issues with it.

The mpd database queries have many limitations. Eventually it is better to implement a own tag database in the future instead creating many small workarounds.

quantenschaum commented 3 years ago

I will have into the logs...

Actually it is nice to let mpd do the db search work.

  1. No need to implement it twice.
  2. It's fast
  3. It's consistent with other interfaces to mpd.
jcorporation commented 3 years ago

myMPD v6.9.0 shows now a hint for enabled tags and I added some documentation to the wiki: https://github.com/jcorporation/myMPD/wiki/Tags

jcorporation commented 3 years ago

I will have into the logs...

any news? @quantenschaum

jcorporation commented 3 years ago

I close this stale issue. Do not hesitate to reopen if you can provide logs.

quantenschaum commented 3 years ago

OK. I downloaded some MP3s from the podcast https://www.mdr.de/tweens/podcast/figarino/index.html and placed them in a directory. I set this directory as music_directory in mpd and let it rescan the database with mpc rescan. The downloaded example files were the only files in the library.

Then I entered the album search view in mympd w/o any search string. I looks like this.

image

Clocking on any of the albums show an empty album, not a single track.

The disc field is disabled in mympd, the MPDs log says:

client: [1] process command "search "((Track == '1'))" sort AlbumArtistSort window 0:100"

Running mpc search "((Track == '1'))" yields a list of files like

2017-01-16t0001040100-eiskalte-gefahr.mp3
2017-02-18t1805000100-beatboxing.mp3
2017-12-24t0001030100-der-verruckte-professor.mp3
2018-12-08t1805000100-geschenke.mp3
2018-12-10t0001020100-glasblaser.mp3
2019-02-12t1025000100-gluck.mp3
2019-03-08t1159000100-werwolf.mp3
2019-03-08t1209000100-adventskalender.mp3
2019-03-08t1209000100-bob.mp3
2019-03-08t1209000100-geld.mp3
...

Maybe the tags in the files are not as mympd expects them, but I (as user) expect mympd to handle this correctly.

What is strange here is, that even if mympd treats every file a single file album, all of the albums are empty!

jcorporation commented 3 years ago

I downloaded the last episode of this podcast. The mp3 files are not tagged with id3 (id3v2 -l shows no tag values. Despite missing tags the search (Track == '1') returns a list of files. To solve this myMPD should ignore results with empty album, artist, albumartist tags.