Bookstack: Random Incorrect Search Behavior

Created on 26 Jan 2017  路  3Comments  路  Source: BookStackApp/BookStack

Bug Report

  • BookStack Version: 0.14.1
  • PHP Version: 7.1.1
  • MySQL Version: mysql Ver 15.1 Distrib 10.1.21-MariaDB
  • OS: Arch Linux
Description of the issue

First, great work so far on BookStack! Recently, I encountered weird behavior of the search function, i.e., search terms are not found. In the following I list two examples for reproducing the bug:

  • I use 'XXX' in my notes to indicate a TODO. However, BookStack cannot find those occurrences anywhere. However, if I put something like 'XXXXXXXX' in a page, the above search term will find it as a part result. I am not 100% sure on this one, but it seems that BookStack has problems with short search queries (<5 characters) and often cannot find them.
  • Another example, words with a 'x' can often not be found. If this is written on a page 'Xenus maxus carxus' and you search for 'x', only the 'x' in 'maxus' is highlighted. It should highlight all 'x' occurrences in the three words (as it does for working search queries).

I think I traced the problem down to app/Entity.php in function fullTextSearchQuery(...) line 188 ($search = $search->whereRaw('MATCH(' . $fields . ') AGAINST(? IN BOOLEAN MODE)', [$termString]);) where the search results are incorrectly filtered. Unfortunately, I am not sure how to fix it.

Expected Behavior

The search returns all occurrences from the search query.

Actual Behavior

The search does randomly not return all occurrences from the search query.

Bug

Most helpful comment

We've run into the same issue here. A colleague pointed it out. We have a page called: Working with GPG we can search for Working but not with or gpg.

All 3 comments

We've run into the same issue here. A colleague pointed it out. We have a page called: Working with GPG we can search for Working but not with or gpg.

ive noticed similar issues with symbols and 'non-words' for example in my system i use [[title to reference another page i have yet to create, or i use qq to reference a todo. neither will return any search results.

i think it might be because symbols and 'non-words' are filtered out by the preg_match_all on line 383 of app/Repos/EntityRepo.php which is where the page searches move to from the controller

Yeah. MySQL full-text search, Which I've used for speed reasons, has proved to be tricky as it tries to be clever and filter overly-common words. Plus, due to the awkward syntax I'm overly-cautiously manually escaping input going to the search which reduces many terms.

I've opened up #271 which is to look into an alternative search system.

For now, Wrapping a search in double quotes "a cat" should convert the search to an exact match which should skip the fulltext search.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

conor-byrne picture conor-byrne  路  3Comments

mackcoding picture mackcoding  路  3Comments

spacesven picture spacesven  路  3Comments

hhk7734 picture hhk7734  路  3Comments

mtnyaeger picture mtnyaeger  路  3Comments