-
-
Notifications
You must be signed in to change notification settings - Fork 238
Expand file tree
/
Copy pathz_17_pg_textsearch.out
More file actions
27 lines (25 loc) · 1.03 KB
/
z_17_pg_textsearch.out
File metadata and controls
27 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- Test pg_textsearch extension (BM25 ranked text search)
create schema ts;
create table ts.docs (
id serial primary key,
content text
);
insert into ts.docs (content) values
('PostgreSQL is a powerful relational database system'),
('BM25 is a ranking function used in search engines');
create index docs_bm25_idx on ts.docs using bm25(content) with (text_config='english');
-- Verify BM25 index was created
select indexname, indexdef from pg_indexes
where schemaname = 'ts' and indexname = 'docs_bm25_idx';
indexname | indexdef
---------------+------------------------------------------------------------------------------------------------
docs_bm25_idx | CREATE INDEX docs_bm25_idx ON ts.docs USING bm25 (content) WITH (text_config='english')
(1 row)
-- Verify BM25 search returns results (check count, not exact scores)
select count(*) from ts.docs where content <@> 'database' < 1.0;
count
-------
1
(1 row)
drop schema ts cascade;
NOTICE: drop cascades to table ts.docs