BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

Tag suggestions are inaccurate past 3 characters with tags that have matching prefixes

Open okaeiz opened this issue 4 years ago • 6 comments

Describe the Bug

[ This bug is apparently reproducible only in RTL languages. ] [ Since the issue is language-related, the attached screenshots may help comprehend the problem. ]

When the user intends to add a new tag in a page and searches for a Persian word, only the tags are suggested which START with what the user has typed. For instance, if the user searches for "سلام", the tag suggestions are as follows:

  • سلام
  • سلام بر
  • سلام بر شما

However, if the word that the user has typed is in the middle of a tag, the so-called tag is not suggested. For example, if the tag is "درود و سلام و تهیت", which contains the word "سلام", it is not shown.

Steps to Reproduce

  1. Change the interface language to Persian.
  2. Go to some random page of a book.
  3. Click on "Add a new tag".
  4. Search for a Persian string.
  5. See? Suggested tags are only the ones that start with that string.

Expected Behaviour

One should be able to search any part of the tag name and be able to find it in suggested tags.

Screenshots or Additional Context

A good illustration of this issue is the one below. There is a tag, containing two words.

cap8

When the user searches for the first word with which the tag starts, everything is OK.

photo_2022-09-13_15-58-55

But when the 2nd word is typed, nothing is suggested.

photo_2022-09-13_15-58-56

Browser Details

Google Chrome Version 104.0.5112.102 (Official Build) (64-bit) On Windows 10

Exact BookStack Version

v22.09

PHP Version

No response

Hosting Environment

Ubuntu Server 22.04 (installed via Docker Compose)

okaeiz avatar Sep 13 '22 11:09 okaeiz

Hi @okaeiz, I don't believe this is specific to RTL languages, this is what I'd expect for all languages.

For searches across potentially larger datasets they will commonly be done on a prefix-match search so that database indexes can be taken advantage of. This is the case here, tag names and values are searched via prefix-match since the values are queried via the back-end and database then returned back to show in a list.

ssddanbrown avatar Sep 13 '22 22:09 ssddanbrown

On one hand, I definitely respect the policy and the procedure; On the other hand, when the users do not fully recall the tag name, it seems logical if they could search for a specific part of the tag. However, the searching tool does really have bugs. I will explain it through screenshots. I have created some tags whose prefixes are similar.

cap9

As you can see, there are a few tags whose name start with "random_". The problem is that when I search for the string "random_", some mismatching tag names are suggested.

cap10

I have clearly typed "random_" and I expect to see the following tags:

  • random_tag
  • random_tag_second
  • random_tag_third
  • random_tag_fourth
  • random_tag_fifth

But as you can see, some mismatching tags are shown; such as "randomtag", "randomta" and "randomt". It seems like there is something wrong with underscores. As if when I type an underscore, the searching suddenly stops. So what if I was searching for, like, "random_tag_fifth"? What if there were more than 6 similar tags?

According to what I explained, it seems pretty fine if the user be able to search for any part of the tag and have it suggested.

okaeiz avatar Sep 14 '22 07:09 okaeiz

It seems like there is something wrong with underscores. As if when I type an underscore, the searching suddenly stops. So what if I was searching for, like, "random_tag_fifth"? What if there were more than 6 similar tags?

It's not something wrong with underscores, it's due to tag suggestions only being based upon the first 3 or so characters provided. I can look to address that to better react to most common cases. I'll update this issue to focus on this specific point.

According to what I explained, it seems pretty fine if the user be able to search for any part of the tag and have it suggested.

I'd prefer to keep our current prefix match to retain use of database indexes, since these suggestions are a minor sub-component.

ssddanbrown avatar Sep 19 '22 22:09 ssddanbrown

The above has been addressed as per my comment within 8f3430d3867ca8880c4f259b2c58647eb2b2c5ea so I'll therefore close this off. Will be part of the next feature release.

ssddanbrown avatar Sep 28 '22 12:09 ssddanbrown

@ssddanbrown is this issue really solved? I still encounter problems with searching for tags. It seems like it still matches the prefix. So if the word that I have searched does not exist in the beginning of the tag, it will not be shown.

okaeiz avatar Nov 07 '22 12:11 okaeiz

As said in my previous comments, my preference is to keep prefix matching as it allows efficient usage of database indexes. I closed this off since I addressed a number of things that were causing confusion in the behaviour:

  • Aligned prefix-type filtering with back-end.
  • Increased suggestion search cut-off from 3 to 4.
  • Increased amount of suggestions shown.
  • Ordered suggestions to be name asc, as you'd expect on search.
  • Updated front-end filtering to use full search query, instead of truncated version, for further front-end filtering capability.

ssddanbrown avatar Nov 07 '22 17:11 ssddanbrown