PostgreSQL中的全文索引(不是“英语”还是“简单”)?

时间:2010-12-09 22:41:41

标签: postgresql

我需要在数据库中存储几十万个HTML文档,并能够搜索它们。但不仅仅是内容 - 我需要搜索以匹配类名,脚本名称和id值(以及其他内容),这些值可能在文档中的HTML标记中显示为属性。我尝试使用to_tsvector('english',tableColumn)和to_tsvector('simple',tableColumn),但似乎都不匹配标记中属性的内容。具体来说,我这样做了:

create index an_index on myTable using gin (to_tsvector('simple',tableColumn))

然后:

select url from myTable where to_tsvector ('simple', tableContent) @@ to_tsquery ('myscript.js')

我希望它能够检索包含对myscript.js的引用的所有文档。但它没有返回任何结果。

是否有可能使用全文搜索获得我想要的结果?

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

尝试改为。

SELECT url FROM myTable WHERE tableColumn @@ to_tsquery ('simple','myscript.js')