在 PostgreSQL 9.3 中使用 to_tsvector 时保留一些字符
Preserving some characters when using to_tsvector in PostgreSQL 9.3
我需要像这样处理字符串 "hello world @mention a #hashtag" 并为它们编制索引以便使用 PostgreSQL 进行搜索。我确实需要特别对待@mention 和#hashtag。
以下生成一个 tsvector:
select to_tsvector('hello world @mention a #hashtag')
但是输出看起来像这样:
"'a':4 'hashtag':5 'hello':1 'mention':3 'world':2"
我希望看到“@”保留在 'mention' 前面,# 保留在 'hashtag' 前面。我可以使用 PostgreSQL 执行此操作吗?
我不确定 tsearch 是否适合您的用例。 Tsearch 擅长全文搜索,但听起来你想要关系数据。您能否解析应用程序中的数据并根据#hashtags 和@mentions 创建 tag/user 关系?
我需要像这样处理字符串 "hello world @mention a #hashtag" 并为它们编制索引以便使用 PostgreSQL 进行搜索。我确实需要特别对待@mention 和#hashtag。
以下生成一个 tsvector:
select to_tsvector('hello world @mention a #hashtag')
但是输出看起来像这样:
"'a':4 'hashtag':5 'hello':1 'mention':3 'world':2"
我希望看到“@”保留在 'mention' 前面,# 保留在 'hashtag' 前面。我可以使用 PostgreSQL 执行此操作吗?
我不确定 tsearch 是否适合您的用例。 Tsearch 擅长全文搜索,但听起来你想要关系数据。您能否解析应用程序中的数据并根据#hashtags 和@mentions 创建 tag/user 关系?