Kar*_*lom 5 postgresql full-text-search
我正在使用 Postgresql 9.6,我想运行这样的查询:
\n\nselect post_id \nfrom comments \nwhere to_tsvector(\'pg_catalog.persian\', comments.body) @@ to_tsquery(\'pg_catalog.persian\', \'\xda\xa9\xd8\xaa\xd8\xa7\xd8\xa8\') ;\nRun Code Online (Sandbox Code Playgroud)\n\n但波斯语不在 postgresql 字典支持的语言之列:
\n\npostgres=# \\dF\n List of text search configurations\n Schema | Name | Description \n------------+------------+---------------------------------------\n pg_catalog | danish | configuration for danish language\n pg_catalog | dutch | configuration for dutch language\n pg_catalog | english | configuration for english language\n pg_catalog | finnish | configuration for finnish language\n pg_catalog | french | configuration for french language\n pg_catalog | german | configuration for german language\n pg_catalog | hungarian | configuration for hungarian language\n pg_catalog | italian | configuration for italian language\n pg_catalog | norwegian | configuration for norwegian language\n pg_catalog | portuguese | configuration for portuguese language\n pg_catalog | romanian | configuration for romanian language\n pg_catalog | russian | configuration for russian language\n pg_catalog | simple | simple configuration\n pg_catalog | spanish | configuration for spanish language\n pg_catalog | swedish | configuration for swedish language\n pg_catalog | turkish | configuration for turkish language\n(16 rows)\nRun Code Online (Sandbox Code Playgroud)\n\n所以我得到错误:
\n\n\n\n\n错误:文本搜索配置“pg_catalog.persian”不存在
\n
我的默认数据库配置是英语:
\n\npostgres=# show default_text_search_config;\n default_text_search_config \n----------------------------\n pg_catalog.english\n(1 row)\nRun Code Online (Sandbox Code Playgroud)\n\n我已经尝试过pg_catalog.simple,但它返回任何内容,而\xda\xa9\xd8\xaa\xd8\xa7\xd8\xa8.
所以我想知道在这种情况下如何进行全文搜索以获得相关的波斯语结果?
\n小智 5
用这个。
\n\nselect post_id \nfrom comments \nwhere to_tsvector(\'simple\', comments.body) @@ to_tsquery(\'simple\', \'\xda\xa9\xd8\xaa\xd8\xa7\xd8\xa8\') ;\nRun Code Online (Sandbox Code Playgroud)\n\n或者
\n\nselect post_id \nfrom comments \nwhere to_tsvector(\'simple\', comments.body) @@ to_tsquery(\'\xda\xa9\xd8\xaa\xd8\xa7\xd8\xa8\') ;\nRun Code Online (Sandbox Code Playgroud)\n\n或者使用这个扩展:
\n\nhttps://pgroonga.github.io/tutorial/
\n| 归档时间: |
|
| 查看次数: |
1716 次 |
| 最近记录: |