-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty filter bug #19
Fix empty filter bug #19
Conversation
@jmigual Please have a look in this. This is NULL feature was explicit introduced here: Do you remember why? Is there a use case for an empty search query? |
Yes it was introduced to search for tracks that do not have a certain field. I introduced it because in the sorting tree the elements that belong to the "Unknown" tag need to be able to be selected when the user clicks it. For example if I have tracks that do not have artist they'll show all grouped under the "Unknown" tag and when I click it I will expect to see this tracks and, since the tree is a query helper, I introduced the NULL feature. |
But it can't be generated when a user has typed nothing. Maybe a special keyword could be used to generate it, eg |
I added a nullFilterMatcher in SearchQueryParser witch captures paterns like "artist:0" |
But in the way it's now if the user types |
because if the user types |
@daschuer @jmigual Ok, the new null filter matcher matches stuff like Also the old (artist IS NULL) didn't work for me, I got 282 songs in my library without artist. Only 4 of them were shown. So I changed it to ((artist IS NULL) OR (artist LIKE "")) and now it shows everything. From my tests everything works fine, please have a look and comment if you have any problems with what is happening. |
"artist:0" does not work well, because it also stands for as artist containing "0". The original solution was quite natural for me. On one hand you are right that you are narrowing the we search while typing, on the other hand it does not work anyway, because while you type you are actually searching for a track containing "artist" only after the colon the real search starts. @Be-ing what do you think about this? |
I am open to suggestions to change the zero, I don't like it that much either. But I really feel that Also we should change Following the same logic I feel that this whole For the exact match of the crate we just need to add a function in CrateStorage witch instead of creating the query using |
If I remember properly (I have to check it though) the meaning of |
And for the empty search Bye the way @gramanas take in account that if you change the NULL definition you must update the query tree helper in the sidebar so it continues working. |
I did update the query tree helper, it works correctly. About the IS NULL query as I said , I got 282 songs in my library without artist. Only 4 of them were shown with your code. So I changed it to ((artist IS NULL) OR (artist LIKE "")) and now it shows everything. Check in the searchqueryparser.cpp where it generates the IS NULL query. Ok, if you prefer |
What about using
|
That would work, but is IMHO not better then the current solution, because
we do not handle "text" inputs very well. I also think hat his feature can
only discovered by a programmer.
I have ask my wife, to search for missing artists she supprising just types
"artist:"
What do you DJ friends expect?
Am 08.06.2017 4:12 nachm. schrieb "Be" <[email protected]>:
… We may consider to use artist:"" but I like the original behaviour more.
@Be-ing <https://github.com/be-ing> what do you think about this?
What about using artist:="" to explicitly search for an empty field?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABsfInyexxwTVpGGxlV_OEL9FLn0GGe9ks5sCAFcgaJpZM4NynDl>
.
|
I think you are right that |
From a theoretical point of view I prefer continuous functions with consistent behaviour. The more characters you add, the more you narrow your search: No characters -> Match all. But I must agree with @Be-ing. You convinced me with your last argument 👍 We don't need a multitude of possible inputs for the same result when on the other hand we have to introduce ambiguous inputs for handling the missing use cases. |
Ok, I'll fix and push as you said. But then crate: should return all tracks that are not in a crate. We should look at that later. |
Sounds reasonable: "crate:" => all tracks that are not contained in any crate One use case I could think of is to identify all tracks that have not been sorted into crates, yet. |
I did as you said and almost everything works. I am having some trouble with the SearchQueryParserTest.TextFilterEmpty again. No matter what I try, while the sql works fine the match function does not... @uklotzde any ideas? |
} | ||
if (value != "0") { | ||
value = "\"" + value + "\""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a leftover form the artist:0 version?
Yes, I'll remove it. for some reason I didn't see it :/
|
SearchQueryParserTest.TextFilterEmpty fails. There seams to be also an escaping issue. I have a crate "40's" and "crate:40's" does not return any result. Other crates are working fine. |
There is no escaping happening anywhere in the crate filter, @uklotzde @Be-ing it appears I missed that part. I'll try adding it here. About the TextFIlterEmpty test: I believe TextFilterNode::match() has some problems. when the query has an empty string as an argument |
Apparently the SqlNode that was created could not match() as it should so I removed it and made TextFilter to be aware of the empty argument and act accordingly Add escape to crate filter argument
I added escape in crate filter and I think I also fixed the bug. Now for the empty text filter: I modified the TextFilter and the ExactFilter to be aware that the argument is empty. Everything seems to work fine. @jmigual The GLOB clause in the exact filter can't match stuff like this |
if (value.toString().contains(m_argument, Qt::CaseInsensitive)) { | ||
return true; | ||
if (m_argument.isEmpty()) { | ||
if (value.toString().isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both if statements on the 2nd level can be simplified: return
Handling the special case m_argument.isEmpty() separately seems reasonable to me.
In this case I added the GLOB to allow the user to search for things like A solution may be to remove the possibility to search with a glob like |
I am in favour to keep the syntax simple in the first place. artist:bla schould return all artists containing bla, no special character replacement like * or [. With the syntax artist:="" we can do all more technical things we discussed above. We can also invent a new syntax for fully GLOB cause compliant. |
Regarding the issue with GLOB and brackets, I agree with @daschuer that the syntax should remain very simple, so the filters should escape any |
Ok but don't think this is a place to fix such an issue so let's merge this branch and work on it in another. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor style nitpicks, but nothing that needs to hold back merging this.
&m_pTrackCollection->crates(), argument); | ||
} else { | ||
//TODO(gramanas) It should generate a query to | ||
//match all the tracks that are not in a crate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An explicit continue
line here would make it a little easier to read.
//match all the tracks that are not in a crate. | ||
} | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put on one line:
} else {
auto pQuery( | ||
m_parser.parseQuery("comment:", searchColumns, "")); | ||
m_parser.parseQuery("album: ", searchColumns, "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add a test to check that "album: " and "album:" are treated the same.
Works now good. Sorry for the delay. |
No problem, thanks! |
CI: Update Docker image for GitHub pre-commit workflow
When user types "filter:" and nothing after it, the query should return the
whole library since in the search we have just an empty filter.
Basically I removes the
IS NULL
sqlNode that was created inSearchQueryParser::parseTokens