Support force prefix search when unmatured token is 2 characters or more #341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
現在、GroongaではTokenBigramで最後のトークン(TOKEN_LAST)が1文字トークン(UNMATURED)の場合、強制前方一致フラグtoken_cursor->force_prefixが設定されることにより、1文字トークンで検索される場合でも勝手にうまくヒットするようになっています。
しかし、TokenTrigramにすると2文字トークンは最後のトークンでないため(以下の例では最後のトークンは章)、強制前方一致フラグが設定されず、2文字トークンを含むとうまくヒットしなくなります。
そこで、UNMATUREDトークンの場合、TOKEN_LASTではなくトークンの最後の文字がクエリの末尾であることを示すTOKEN_REACH_ENDの場合に強制前方一致フラグを設定するようにしてやれば、TokenTrigramの場合に2文字トークンが含まれても勝手にうまくヒットするようになると思います。
よければご検討ください。