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

[BUG] Tags with Spaces in Searchbar #112

Open
TechCrafterGaming opened this issue May 1, 2024 · 8 comments
Open

[BUG] Tags with Spaces in Searchbar #112

TechCrafterGaming opened this issue May 1, 2024 · 8 comments
Labels
Priority: High An important issue requiring attention Type: Bug Something isn't working as intended Type: Enhancement New feature or request

Comments

@TechCrafterGaming
Copy link
Contributor

If you have a tag that contains spaces and you search for files that contain this tag, it will only work if you remove the spaces in the search bar.

I would say there are 2 simple solutions

On the one hand, you could always remove all spaces from the search line automatically, but I don't know if that could have other problems.

On the other hand, you could take a closer look at the search function and make sure that it can handle such tags.

I would be willing to solve this directly once it has been clarified how we want to approach this.

@Loran425
Copy link
Collaborator

Loran425 commented May 1, 2024

Hmmm this is an interesting question but it will need an opinionated answer, my expectation of how the search would behave if I knew nothing about Tagstudio is that spaces were treated as commas so a search for Brown Hat would be interpreted as "Show me all the files I have that are tagged with Brown AND Hat which would either break or require a great deal of clever code to parse if spaces were removed. my other thought of just replacing spaces with underscores in tag names in the database and search also wouldn't work to resolve this.

I think making people type commas to separate tags is less clean that what we are looking for.

I think a rough way to resolve this and might be only searching for the first word in a tag with spaces so searching for Brown Hat would match on the search Brown.

@CyanVoxel any thoughts on the intended behavior of tags with spaces or spaces in the search query, not necessarily how its implemented but how it should behave? I have some solutions that come to mind for down the road but there's a fair few things between now and those ideas.

@Loran425 Loran425 added the Type: Enhancement New feature or request label May 1, 2024
@TechCrafterGaming
Copy link
Contributor Author

I've just had another idea...
What if you had a kind of autocomplete where tags could be suggested in a list and when a tag was recognized in the search bar it could be displayed as a tag instead of text.
And then you could do the same with concatenations. So that or, and etc are also converted from text.

I think it's hard to imagine exactly what I mean...
I will try to illustrate this graphically later, I hope that will help

@Loran425
Copy link
Collaborator

Loran425 commented May 2, 2024

Haha this was exactly what I was thinking, but since the database swap is still being sorted implementing it right now would just mean re-implementing it with the new system as soon as that goes live.

But if you want to take a swing at it with the current system have at it.

@Qronikarz
Copy link

my expectation of how the search would behave if I knew nothing about Tagstudio is that spaces were treated as commas so a search for Brown Hat would be interpreted as "Show me all the files I have that are tagged with Brown AND Hat

Exactly how Booru programs work. Replacing the space with underscore so "blue sky" becomes "blue_sky". That also means that the whitespace becomes a forbidden character to use in tag names. Of course, it's up to CyanVoxel how to solve this, but it needs to be decided.

What if you had a kind of autocomplete where tags could be suggested in a list and when a tag was recognized in the search bar it could be displayed as a tag instead of text.

Kind of reminds me of how the Spacedrive allows you to search with tags, but I only tested it with few tags so don't know how well it will work when the number of tags grows to 100+ or 500+

@CyanVoxel CyanVoxel added Type: Bug Something isn't working as intended Priority: Critical An issue that requires immediate attention labels May 4, 2024
@The-Stolas
Copy link
Contributor

The-Stolas commented May 23, 2024

Exactly how Booru programs work. Replacing the space with underscore so "blue sky" becomes "blue_sky". That also means that the whitespace becomes a forbidden character to use in tag names. Of course, it's up to CyanVoxel how to solve this, but it needs to be decided.

I second this. During initial testing I tagged my file with "red dead redemption". When searching with "red dead redemption" yeilded no result, my immediate reaction was to try "red_dead_redemption", since I figured the search would behave like a booru library. Omitting spaces during search is functional, it's just not very intuitive (I had to go here to see if it's a bug or not), so it would be nice to see underscore search as an option.

@CyanVoxel CyanVoxel pinned this issue May 23, 2024
@CyanVoxel CyanVoxel added Priority: High An important issue requiring attention and removed Priority: Critical An issue that requires immediate attention labels Jun 7, 2024
@CyanVoxel CyanVoxel added this to the Alpha 9.4 milestone Jun 7, 2024
@PeterBouSaada
Copy link

What about actually adding double quotes to signify that you want to include the space in the tag, like "my tag with spaces" vs my tag without spaces, the latter would be treated as 4 tags. [my, tag, without, spaces] but the first would be one tag [my tag with spaces].

To me personally this would be the most intuitive way to signify a literal string

@MichaelBrunn3r
Copy link

MichaelBrunn3r commented Sep 10, 2024

Double quotes is what I see on most websites I come across and is the most intuitive to me (as a programmer at least). I think JSON and JavaScript do it the same way for Object keys that contain spaces.

Another plus is that it does not change the tag at all. Maybe I misunderstand, but I understand the replacement with '_' as such:

  • Create Tag with spaces a tag
  • Search for it with a_tag

It looks like you are searching for a different tag. Instead:

  • Create Tag a tag
  • Search for it with "a tag"

You search with the same name you gave the tag, just with added delimiters.

Also wouldn't replacement make the use of _ in tags ambiguous?

@CyanVoxel
Copy link
Member

Just so there's no more unnecessary discussion on this, the plan is to leverage the UI to allow for tag "objects" themselves to populate the search alongside normal strings, and will be aided by an autocomplete box similar to this example image. With this setup there will be no need to deal with any character issues for tags as you would with plain string searches.
image
For other multi-word text outside of tags, or for any future API considerations, wrapping strings inside quotations is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High An important issue requiring attention Type: Bug Something isn't working as intended Type: Enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

7 participants