textsearch_jaじゃなくてtextsearchの問題だった・・・かも?
先週、to_tsquery()に渡した英語トークン末尾が欠けるという現象を書いたんだけど、ちょっと勘違いしていた。
textsearch_jaの問題ではなく、textseach自体の仕様 or 問題なのかも。
test=# SELECT to_tsquery('tennis'); to_tsquery ------------ 'tenni' (1 row)
で、よくよく文書を見てみるとデバッグ用の関数があるので、それでもうちょっと調べてみることに。
test=# SELECT alias, description, token, dictionaries, dictionary, lexemes FROM ts_debug('tennis'); alias | description | token | dictionaries | dictionary | lexemes -----------+-----------------+--------+----------------+--------------+--------- asciiword | Word, all ASCII | tennis | {english_stem} | english_stem | {tenni} (1 row) test=# test=# SELECT alias, description, token, dictionaries, dictionary, lexemes FROM ts_debug('baseball'); alias | description | token | dictionaries | dictionary | lexemes -----------+-----------------+----------+----------------+--------------+----------- asciiword | Word, all ASCII | baseball | {english_stem} | english_stem | {basebal} (1 row)
うーむ、lexemes (トークンを認識した辞書が生成した語彙素)がそもそもこういう風に変化してしまうものらしい。これは英語固有の何か理由があるんだろうか。
語尾が切れるのではなく、変化するトークンのパターンもある。
test=# SELECT alias, description, token, dictionaries, dictionary, lexemes FROM ts_debug('baby'); alias | description | token | dictionaries | dictionary | lexemes -----------+-----------------+-------+----------------+--------------+--------- asciiword | Word, all ASCII | baby | {english_stem} | english_stem | {babi} (1 row) test=#
baby の場合だと、末尾のyがiに変化するっぽい。textsearchの辞書の仕様がそうなっているからだとしか言いようがないのだろうか・・・?