Skip to content
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

Merged
merged 7 commits into from Jul 24, 2018

Conversation

poelzi
Copy link
Contributor

@poelzi poelzi commented Nov 21, 2017

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.

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.
@Be-ing
Copy link
Contributor

Be-ing commented Nov 21, 2017

Good idea! @gramanas, any thoughts?

@poelzi poelzi changed the title On untagged queries us token as crates name. On untagged queries use query for crate names. Nov 21, 2017
@gramanas
Copy link
Contributor

Yeah, it seems nice! I like it!

// 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>();
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@uklotzde
Copy link
Contributor

Nice idea. Please simplify the code as suggested.

We should not forget to amend the manual after this feature has been merged.

Copy link
Contributor

@uklotzde uklotzde left a 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!?

@Be-ing
Copy link
Contributor

Be-ing commented Nov 25, 2017

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

@uklotzde uklotzde added this to the 2.1.0 milestone Nov 25, 2017
@Be-ing
Copy link
Contributor

Be-ing commented Dec 2, 2017

ping @poelzi, could you fix the tests?

@Be-ing
Copy link
Contributor

Be-ing commented Dec 19, 2017

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.
@poelzi
Copy link
Contributor Author

poelzi commented Dec 21, 2017

@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.

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug message

Copy link
Contributor

@Be-ing Be-ing left a 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.

@@ -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")) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

@Be-ing
Copy link
Contributor

Be-ing commented Dec 22, 2017

LGTM thank you! 👍

@daschuer
Copy link
Member

This fails on our ci. Any idea?

@Be-ing
Copy link
Contributor

Be-ing commented Dec 22, 2017

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.

@Be-ing
Copy link
Contributor

Be-ing commented Dec 24, 2017

Ping. Ready for merge?

@poelzi
Copy link
Contributor Author

poelzi commented Dec 24, 2017 via email

@Be-ing
Copy link
Contributor

Be-ing commented Dec 24, 2017

Can you retarget this PR to the 2.1 branch? Click the Edit button at the top of the page.

@poelzi poelzi changed the base branch from master to 2.1 December 25, 2017 04:23
@@ -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);
Copy link
Contributor

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;

@@ -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) {
Copy link
Contributor

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.

@Be-ing Be-ing added the library label Dec 27, 2017

// Create new crate and add it to the collection
Crate testCrate;
testCrate.setName(searchTerm);
Copy link
Contributor

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?

@Be-ing
Copy link
Contributor

Be-ing commented Jan 6, 2018

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:.

@sblaisot
Copy link
Member

sblaisot commented Jan 7, 2018

Appveyor 32bits failing build seems to be unrelated to the change. I re-launched the build.

@poelzi
Copy link
Contributor Author

poelzi commented Jan 7, 2018

@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 ;)
For my usecase, I have primary folder genre and then band or label. I often filter for zenon or psytrance for example, but want to have results form crates in this as well. It can also have genre it's only a primary selection.

@Be-ing
Copy link
Contributor

Be-ing commented Jan 7, 2018

I have a plan for a 2.2 change that will calm your concerns ;)

Could you explain what that is?

@poelzi
Copy link
Contributor Author

poelzi commented Jan 7, 2018

@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.

@Be-ing
Copy link
Contributor

Be-ing commented Jan 7, 2018

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.

@daschuer
Copy link
Member

Since this seems to be a controversial feature. Lets postpone it to 2.2.

@daschuer daschuer modified the milestones: 2.1.0, 2.2.0 Mar 22, 2018
@Be-ing Be-ing modified the milestones: 2.2.0, 2.3.0 Jun 23, 2018
@daschuer
Copy link
Member

I think we should merge this. What do you think?

@uklotzde
Copy link
Contributor

uklotzde commented Jul 24, 2018

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.

@uklotzde
Copy link
Contributor

Target branch is still 2.1??

@daschuer
Copy link
Member

Yes. This is usually the down-side when going in small steps ...
What do you think is a suitable the target branch?

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong target branch!

@daschuer
Copy link
Member

This is not 2.1, because it is not a bugfix. 2.2 is ok for me.

@daschuer daschuer changed the base branch from 2.1 to master July 24, 2018 21:31
@uklotzde
Copy link
Contributor

2.2 is ok, even if it is a new feature. I don't expect any serious issues.

Copy link
Contributor

@uklotzde uklotzde left a 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.

@daschuer
Copy link
Member

Thank you all for working on this branch!

@daschuer daschuer merged commit dbd47d5 into mixxxdj:master Jul 24, 2018
@Be-ing
Copy link
Contributor

Be-ing commented Aug 2, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
2.3 release
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

7 participants