[BUG] Tags with Spaces in Searchbar
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.
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.
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
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.
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 Hatwould be interpreted as "Show me all the files I have that are tagged withBrownANDHat
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+
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.
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
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?
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.
For other multi-word text outside of tags, or for any future API considerations, wrapping strings inside quotations is the way to go.