Bug 5095 - Comment search is broken
: Comment search is broken
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Web Interface
: 6.5.2
: PC Windows XP
: P2 normal (vote)
: ---
Assigned To: Squeezebox QA Team email alias
http://forums.slimdevices.com/showthr...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-05-31 02:02 UTC by Jim McAtee
Modified: 2008-12-18 11:12 UTC (History)
3 users (show)

See Also:
Category: ---


Attachments
patch (387 bytes, patch)
2007-05-31 11:32 UTC, KDF
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jim McAtee 2007-05-31 02:02:13 UTC
Recent revision of 6.5.3.  In the Advanced Search, no matter what I search for in comments I can't raise any results.  I've tried both partial strings and exact strings, including exact case, but always get 'No search results'.  Examining the database, the comments appear to be correctly read from the (flac) file tags.
Comment 1 Jim McAtee 2007-05-31 09:08:18 UTC
I enabled SQL debugging and here's the query that was run when I searched for the string 'mfsl'.  Looks like 'mfsl' is being turned into 'HASH 0X6CE724C'.

SELECT COUNT( * )
FROM tracks me
     LEFT JOIN contributor_track contributorTracks
               ON ( contributorTracks.track = me.id )
     LEFT JOIN comments comments ON ( comments.track = me.id )
WHERE ( ( ( comments.value LIKE ? ) )
  AND ( ( contributorTracks.role = ? )
   OR ( contributorTracks.role = ? )
   OR ( contributorTracks.role = ? )
   OR ( contributorTracks.role = ? ) ) )
	 
'%HASH 0X6CE724C%', '1', '2', '4', '5'

Comment 2 slutz 2007-05-31 11:02:32 UTC
It's the official 6.5.2 build no nighly or other build.
It's in Slim/Web/Pages/Search.pm

The original code is:

# Normalize the string queries
#
# Turn the track_title into track.title for the query.
# We need the _'s in the form, because . means hash key.
if ($newKey =~ s/_(titlesearch|namesearch|value)$/\.$1/) {

$params->{$key} = { 'like' => Slim::Utils::Text::searchStringSplit($params->{$key}) };
}

# Wildcard searches
if ($newKey =~ /comment/ || $newKey =~ /lyrics/) {

$params->{$key} = { 'like' => Slim::Utils::Text::searchStringSplit($params->{$key}) };
}

The line "if ($newKey =~ s/_(titlesearch|namesearch|value)" catches the comments_value (was comments in 6.5.1) and produces the hash. If you change to the following it works again:

# Normalize the string queries
#
# Turn the track_title into track.title for the query.
# We need the _'s in the form, because . means hash key.
if (!$newKey =~ /comment/ && $newKey =~ s/_(titlesearch|namesearch|value)$/\.$1/) {

$params->{$key} = { 'like' => Slim::Utils::Text::searchStringSplit($params->{$key}) };
}

# Wildcard searches
if ($newKey =~ /comment/ || $newKey =~ /lyrics/) {

$params->{$key} = { 'like' => Slim::Utils::Text::searchStringSplit($params->{$key}) };
$newKey =~ s/_(value)$/\.$1/;
}

Ok, it's not beautiful but it works.
And this is a change in 6.5.2 that I don't understand. It's simply renamed from comments to comments_value without considering the side effects of the "_"/"." and hashing.
Comment 3 Spies Steven 2007-05-31 11:05:05 UTC
I see the same behavior that Jim describes on Windows XP. However on Mac OS X no matter what I put in the Advance Search Comment field the result will be all the tracks in the library. Only if I leave the field blank will I get 'No search results'.
Comment 4 KDF 2007-05-31 11:32:11 UTC
Created attachment 2030 [details]
patch

The problem is the second searchStringSplit causing the already handled comment_value key to be processed again into the hash.

comments_value has to be used in the form because "comments.value" from a web template is interpreted as a hash <key.value>.  comments_value gets changed to comments.value in Search.pm so that the query will use the correct table and field <table.field>.
Comment 5 Jim McAtee 2007-05-31 12:04:20 UTC
(In reply to comment #4)
> Created an attachment (id=2030) [edit]
> patch

That works on my WinXP Pro server.

Why the platform difference in behavior?  In the forums Michael Herger reported that comment searches were working fine for him - I'd assume that was on a Linux server.
Comment 6 Michael Herger 2007-05-31 12:38:05 UTC
Yes, I'm running slimserver on Linux.

One more question: do you use wildcards "my text*" or just the string you're looking for? (Both is working for me...)
Comment 7 KDF 2007-05-31 12:39:42 UTC
no idea.  I'm not on michael's system (perhaps he wasn't searching on ONLY a comment).  It is just as strange to read claims that it worked previously.  Without the comments_value field, the sql was failing with an error due to an invalid "comment" field. this is what was fixed as part of bug 4797)

as for the osx difference, I think we need the d_sql log output to make any sort of judgement on that.  
Comment 8 KDF 2007-05-31 12:42:58 UTC
you'd have to ask dan about the wildcards. I seem to recall that * is ignored, as we always do a search for the given string as part of another.  I expect searching for foo*bar will give you proper wildcard-type results.  My feeling is that the comment in the code is a bit of a misnomer.
Comment 9 Jim McAtee 2007-05-31 12:51:22 UTC
(In reply to comment #6)
> One more question: do you use wildcards "my text*" or just the string you're
> looking for? (Both is working for me...)

My guess is that the '*' is simply getting stripped out when the search term in normalized. I can search for either

remaster

or

@#$%^remaster%$#!~

and get the same results.
Comment 10 KDF 2007-05-31 18:24:03 UTC
fixed in trunk at change 12178
and in 6.5.3 at change 12179
Comment 11 Spies Steven 2007-06-01 11:23:36 UTC
Works for me on both Mac OS X & Win XP.
Comment 12 James Richardson 2008-12-15 12:31:38 UTC
This bug has been fixed in the 7.3.0 release version of SqueezeCenter!

Please download the new version from http://www.slimdevices.com/su_downloads.html if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.