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
On untagged queries use query for crate names. #1388
Conversation
Currently it is only possible to use the advanced search "crates:" to search for tracks in specific crates. Untagged search queries will only be matched to the track, but not to the crates the track is in. This change allows you to use crates like tags and query them unspecific.
Good idea! @gramanas, any thoughts? |
Yeah, it seems nice! I like it! |
src/library/searchqueryparser.cpp
Outdated
// For untagged strings we search the track fields as well | ||
// as the crate names the track is in. This allows the user | ||
// to use crates like tags | ||
std::unique_ptr<OrNode> gNode = std::make_unique<OrNode>(); |
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.
What does the prefix "g" stand for? Group? Why do we need to introduce another temporary here instead of just storing the OrNode in pNode?
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.
pNode is not of GroupNode subtype and will therefor not have addNode. At least I was not able to get it compiling, maybe with 2 casts, but then I would argue it looks much better with a second variable.
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.
✔️
Nice idea. Please simplify the code as suggested. We should not forget to amend the manual after this feature has been merged. |
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.
The tests are failing and need to be updated.
Unfortuantely Travis doens't notices the test failures!?
The status Travis reports to GitHub is currently meaningless. See https://bugs.launchpad.net/mixxx/+bug/1699689 |
ping @poelzi, could you fix the tests? |
…e/query_crates
Hi @poelzi, do you think you could finish this for the beta release on Friday? |
Add testcase for crates searches. Add a blacklist so special handled searchColumns that are not reflected by a column can be filtered out when building the query.
@Be-ing fixing took longer then I thought. Not because it was complicated, but I did not want to break the API much. I don't like that I ended up with a extra copy of the searchQuery columns, but I tried different API's and I did not like any of those. As this is not a hot path, I think it's OK. I tried caching the filtered list, but then the API got quite ugly downstream. |
src/library/searchqueryparser.cpp
Outdated
@@ -180,14 +191,20 @@ void SearchQueryParser::parseTokens(QStringList tokens, | |||
// For untagged strings we search the track fields as well | |||
// as the crate names the track is in. This allows the user | |||
// to use crates like tags | |||
std::unique_ptr<OrNode> gNode = std::make_unique<OrNode>(); | |||
qDebug() << 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.
remove debug message
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 issues that it would be nice to take care of. @poelzi could you make these quick changes now? If not, I think we should merge this as-is for the beta release.
src/library/searchqueryparser.cpp
Outdated
@@ -180,14 +191,20 @@ void SearchQueryParser::parseTokens(QStringList tokens, | |||
// For untagged strings we search the track fields as well | |||
// as the crate names the track is in. This allows the user | |||
// to use crates like tags | |||
std::unique_ptr<OrNode> gNode = std::make_unique<OrNode>(); | |||
qDebug() << searchColumns; | |||
if (searchColumns.contains("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.
Would this ever be false? If not, please remove the if
statement.
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.
yes. the test cases use this a lot. Also, I'm thinking about the library rewrite branch and some additions I'm planning for the search query there. As I wrote, I did not want to break the API which means that you specify the columns your unnamed query should be matched against. Now we just have special matches as well and those need to be handled.
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.
okay
LGTM thank you! 👍 |
This fails on our ci. Any idea? |
Travis timed out and AppVeyor failed with the infamous vamp-sdk error. This unreliable CI is a big issue! We need to either ask for donations to pay for reliable plans or switch to GitLab and get more reliable CI for free. |
Ping. Ready for merge? |
I don't see any problems, so yes :)
…On 24 December 2017 17:57:00 CET, Be ***@***.***> wrote:
Ping. Ready for merge?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#1388 (comment)
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
|
Can you retarget this PR to the 2.1 branch? Click the Edit button at the top of the page. |
src/library/searchqueryparser.cpp
Outdated
@@ -109,6 +110,16 @@ QString SearchQueryParser::getTextArgument(QString argument, | |||
void SearchQueryParser::parseTokens(QStringList tokens, | |||
QStringList searchColumns, | |||
AndNode* pQuery) const { | |||
// we need to create a filtered columns list that are handled differently | |||
QStringList(queryColumns); |
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.
This is a very uncommon style to declare a local variable! I wasn't even aware that the compiler accepts this construct that looks like invoking a single argument constructor of QStringList and instantly dropping the result.
QStringList queryColumns;
src/library/searchqueryparser.cpp
Outdated
@@ -109,6 +110,16 @@ QString SearchQueryParser::getTextArgument(QString argument, | |||
void SearchQueryParser::parseTokens(QStringList tokens, | |||
QStringList searchColumns, | |||
AndNode* pQuery) const { | |||
// we need to create a filtered columns list that are handled differently | |||
QStringList(queryColumns); | |||
for (const auto& column: 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.
Change the QStringList function parameters to const-ref or use qAsConst(searchColumn) from Qt 5 that Daniel has backported recently. Unfortunately range-based for loops don't play well with Qt's implicit sharing as we noticed.
src/test/searchqueryparsertest.cpp
Outdated
|
||
// Create new crate and add it to the collection | ||
Crate testCrate; | ||
testCrate.setName(searchTerm); |
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.
@poelzi Shouldn't the crate name be set to crateName?
small optimization
I'm now having doubts about whether we should merge this. It could be really confusing if the user is not aware of what is being searched. Maybe it would be better to introduce shorthands for queries so you could type "c:crateName" instead of "crate:crateName:. |
Appveyor 32bits failing build seems to be unrelated to the change. I re-launched the build. |
@Be-ing for me this change cause the expected behavior. I use crates like tags and want to search for them. I have a plan for a 2.2 change that will calm your concerns ;) |
Could you explain what that is? |
@Be-ing the internal search api already has this functionality, the fields a unnamed query parameter is searched in. Currently it's just a fixed list of all useful columns, but I want to have a it selectable in the advanced functionality button next to the search field. So, if you don't like that unnamed queries search in crates, you can disable it. |
The difference is that hardcoded listed of columns are metadata from files and shown as columns in the library table. On the other hand, crates only exist in Mixxx's database and are not currently listed as a column in the library table. Your idea to make the fields searched by unqualified query strings customizable is interesting. I'm wondering if that much flexibility is really useful. |
Since this seems to be a controversial feature. Lets postpone it to 2.2. |
I think we should merge this. What do you think? |
The code seems to be ok now. Unfortunately the code gets more and more fragmented and his really hard to reason about. All the logic is split among different files and classes with literal strings triggering different code paths. In the end all this query parsing and composition needs to be rewritten, sometimes. |
Target branch is still 2.1?? |
Yes. This is usually the down-side when going in small steps ... |
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.
Wrong target branch!
This is not 2.1, because it is not a bugfix. 2.2 is ok for me. |
2.2 is ok, even if it is a new feature. I don't expect any serious issues. |
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.
Target branch 2.2 or master are both ok for me.
Thank you all for working on this branch! |
As this is a new feature, it should not be in 2.2. I don't know how it is in that branch now because this was actually merged to master. |
I found the current behavior not obvious and only understood the real power of the search engine while digging through the code.
Currently it is only possible to use the advanced search "crates:" to search
for tracks in specific crates. Untagged search queries will only be matched to
the track, but not to the crates the track is in.
This change allows you to use crates like tags and query them unspecific.
If you use genre as top level folder, you often end up with tracks from different genres in albums and compilations. This change allows you to create a crate like your genre folder and simply query for both at the same time.