Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite407062

Browse files
author
Artur Zakirov
committed
Added example to README. Added text search configuratio test
1 parent394e9d1 commite407062

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

‎README.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,40 @@ Typical installation procedure may look like this:
2222
After this you can create your own text search configuration:
2323

2424
```sql
25-
CREATETEXT SEARCH CONFIGURATIONrussian_ts (
25+
CREATETEXT SEARCH CONFIGURATIONenglish_ts (
2626
PARSER= tsparser
2727
);
2828

29-
COMMENTONTEXT SEARCH CONFIGURATIONrussian_ts IS'text search configuration forrussian language';
29+
COMMENTONTEXT SEARCH CONFIGURATIONenglish_ts IS'text search configuration forenglish language';
3030

31-
ALTERTEXT SEARCH CONFIGURATIONrussian_ts
31+
ALTERTEXT SEARCH CONFIGURATIONenglish_ts
3232
ADD MAPPING FOR email, file, float, host, hword_numpart,int,
3333
numhword, numword, sfloat, uint, url, url_path, version
3434
WITH simple;
3535

36-
ALTERTEXT SEARCH CONFIGURATION russian_ts
37-
ADD MAPPING FOR asciiword, asciihword, hword_asciipart
38-
WITH russian_stem, english_stem;
36+
ALTERTEXT SEARCH CONFIGURATION english_ts
37+
ADD MAPPING FOR asciiword, asciihword, hword_asciipart,
38+
word, hword, hword_part
39+
WITH english_stem;
40+
```
41+
42+
##Examples
43+
44+
The difference between**tsparser** and**default** parsers is that**tsparser**
45+
gives also unbroken words by underscore character.
3946

40-
ALTERTEXT SEARCH CONFIGURATION russian_ts
41-
ADD MAPPING FOR word, hword, hword_part
42-
WITH russian_stem, russian_stem;
47+
For example:
48+
49+
```sql
50+
SELECT to_tsvector('english_ts','pg_trgm');
51+
to_tsvector
52+
-----------------------------
53+
'pg':2'pg_trgm':1'trgm':3
54+
(1 row)
55+
56+
SELECT to_tsvector('english','pg_trgm');
57+
to_tsvector
58+
-----------------
59+
'pg':1'trgm':2
60+
(1 row)
4361
```

‎expected/pg_tsparser.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,21 @@ SELECT * FROM ts_parse('tsparser', '345 qwe@efd.r '' http://www.com/ http://aew.
175175
1 | qwerty
176176
(139 rows)
177177

178+
-- Test text search configuration with parser
179+
CREATE TEXT SEARCH CONFIGURATION english_ts (
180+
PARSER = tsparser
181+
);
182+
ALTER TEXT SEARCH CONFIGURATION english_ts
183+
ADD MAPPING FOR email, file, float, host, hword_numpart, int,
184+
numhword, numword, sfloat, uint, url, url_path, version
185+
WITH simple;
186+
ALTER TEXT SEARCH CONFIGURATION english_ts
187+
ADD MAPPING FOR asciiword, asciihword, hword_asciipart,
188+
word, hword, hword_part
189+
WITH english_stem;
190+
SELECT to_tsvector('english_ts', 'pg_trgm');
191+
to_tsvector
192+
-----------------------------
193+
'pg':2 'pg_trgm':1 'trgm':3
194+
(1 row)
195+

‎sql/pg_tsparser.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,20 @@ SELECT * FROM ts_token_type('tsparser');
55
SELECT*FROM ts_parse('tsparser','345 qwe@efd.r'' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net teodor@123-stack.net 123_teodor@stack.net 123-teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
66
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
77
<i <b> wow < jqw <> qwerty');
8+
9+
-- Test text search configuration with parser
10+
CREATETEXT SEARCH CONFIGURATION english_ts (
11+
PARSER= tsparser
12+
);
13+
14+
ALTERTEXT SEARCH CONFIGURATION english_ts
15+
ADD MAPPING FOR email, file, float, host, hword_numpart,int,
16+
numhword, numword, sfloat, uint, url, url_path, version
17+
WITH simple;
18+
19+
ALTERTEXT SEARCH CONFIGURATION english_ts
20+
ADD MAPPING FOR asciiword, asciihword, hword_asciipart,
21+
word, hword, hword_part
22+
WITH english_stem;
23+
24+
SELECT to_tsvector('english_ts','pg_trgm');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp