Bookstack: Chinese search cannot find words in the middle of a sentence.

Created on 31 Mar 2018  ·  11Comments  ·  Source: BookStackApp/BookStack

For Bug Reports

  • BookStack Version: v0.20.0

When the word I'm looking for is the first word, or there's a space in front of it, it's ok.
i01

But if the word is in the middle of a sentence, it cannot be found.
i02

Whether this is a full-text retrieval of related issues?

Thanks!

Most helpful comment

Hi,all the guys,I fixed this problem in v0.28.3.Just add a '%' in SearchService.php.
In detail.
in \app\Entities\SearchService.php,about line 196.
modify
$query->orWhere('term', 'like', $inputTerm . '%');
to
$query->orWhere('term', 'like', '%'.$inputTerm . '%');
Just try.

All 11 comments

The same problem in version: v0.25.1, I have just tried BookStack...

The same problem in version: v0.24.3, I use a docker

still the same problem in v26.4. hope it could get solved. thanks

you can use "成功" for search, maybe the word segmentation has the bug, hope fix it

Confirmed this issue still in v0.27.5
One of my team member is hesitating because of this. Would like to see it fixed.

Hope fix this issue soon.

Sorry about this issue. It essentially stems from my unfamiliarity with non-English text.

At the moment BookStack splits up page content, on certain characters such as spaces and some punctuation, into terms which are put in the database for indexing then a "Starts With" match of those are checked against on a normal search.

As @sosize has mentioned, you can wrap a search in quotes, at which point BookStack will perform a "contains" against the content directly instead of the above "Starts With". This is not the default simply due to performance. ("Starts With" searches can use indexes much more effectively than "Contains").

I'm not really sure how we could utilise the "Starts With" system for such characters. Perhaps the search should default to a "Contains" search if such characters are found in a term?

@ssddanbrown Can this be set as config control ?Select “Starts With” or “Contains” for search type.

More is hope full-text search.

Or how to quickly modify the code?

can i replace all the "startWith" with "contains",or how to modify the source code ,sorry ,i'm a noob

Hi,all the guys,I fixed this problem in v0.28.3.Just add a '%' in SearchService.php.
In detail.
in \app\Entities\SearchService.php,about line 196.
modify
$query->orWhere('term', 'like', $inputTerm . '%');
to
$query->orWhere('term', 'like', '%'.$inputTerm . '%');
Just try.

@ssddanbrown hi, can above fix be merge to the source?
after modify SearchService.php now I can search both chinese and english in text body.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

conor-byrne picture conor-byrne  ·  3Comments

marcvef picture marcvef  ·  3Comments

Abijeet picture Abijeet  ·  3Comments

mackcoding picture mackcoding  ·  3Comments

mtnyaeger picture mtnyaeger  ·  3Comments