今天(2021年12月31日),我在12.26号无意间在朋友圈看到了Gauss松鼠会发的海报,于是看这个教程。进行了学习及考试,由于这几天太忙,现在把做的作业文章补上,12.26号下午和晚上都在做这个作业,大概22:00终于完成了实验的每日章节练习,并完成了考试,推荐给了一个朋友一起学习,一起测试,在共同努力下,考取了100分的好成绩,总体感觉这个课程还是很不错的,初步渐入的学习openGauss数据库,并且在12.30号还有活动直播:openGauss与PostgreSQL核心技术解读及优势对比"
章节练习一共21天,下面是第20天的作业内容。

20、学习openGauss全文检索
1.用tsvector @@ tsquery和tsquery @@ tsvector完成两个基本文本匹配
SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector @@ 'cat & rat'::tsquery AS RESULT;
SELECT 'fat & cow'::tsquery @@ 'a fat cat sat on a mat and ate a fat rat'::tsvector AS RESULT;
=========================
2.创建表且至少有两个字段的类型为 text类型,在创建索引前进行全文
检索
CREATE SCHEMA tsearch;
CREATE TABLE tsearch.pgweb(id int, body text, title text, last_mod_date date);
INSERT INTO tsearch.pgweb VALUES(1, 'China, officially the People''s Republic of China(PRC), located in Asia, is the world''s most populous state.', 'China', '2010-1-1');
INSERT INTO tsearch.pgweb VALUES(2, 'America is a rock band, formed in England in 1970 by multi-instrumentalists Dewey Bunnell, Dan Peek, and Gerry Beckley.', 'America', '2010-1-1');
INSERT INTO tsearch.pgweb VALUES(3, 'England is a country that is part of the United Kingdom. It shares land borders with Scotland to the north and Wales to the west.', 'England','2010-1-1');
SELECT id, body, title FROM tsearch.pgweb WHERE to_tsvector(body) @@ to_tsquery('america');
=========================
3.创建GIN索引
CREATE INDEX pgweb_idx_1 ON tsearch.pgweb USING gin(to_tsvector('english', body));
=========================
4.清理数据
drop schema tsearch cascade;




