Skip to content

Commit 88b90ab

Browse files
committed
Merge pull request #61 from lyhabc/patch-20
校对test-parser.sgml文件
2 parents d2a3bbe + 052b1b5 commit 88b90ab

File tree

1 file changed

+97
-2
lines changed

1 file changed

+97
-2
lines changed

postgresql/doc/src/sgml/test-parser.sgml

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,43 @@
77
<primary>test_parser</primary>
88
</indexterm>
99

10+
<!--
11+
<para>
12+
<filename>test_parser</> is an example of a custom parser for full-text
13+
search. It doesn't do anything especially useful, but can serve as
14+
a starting point for developing your own parser.
15+
</para>
16+
-->
17+
18+
<para>
19+
<filename>dblink</>是一个在数据库会话中支持连接其他<productname>PostgreSQL</>
20+
数据库的模块。
21+
</para>
22+
23+
1024
<para>
1125
<filename>test_parser</> 是一个自定义的全文搜索解析器的例子。它不做特别有用的工作,但是可以作为开发一个自己的解析器的起点。
1226
</para>
27+
28+
<!--
29+
<para>
30+
<filename>test_parser</> recognizes words separated by white space,
31+
and returns just two token types:
32+
33+
<programlisting>
34+
mydb=# SELECT * FROM ts_token_type('testparser');
35+
tokid | alias | description
36+
-------+-------+---------------
37+
3 | word | Word
38+
12 | blank | Space symbols
39+
(2 rows)
40+
</programlisting>
41+
42+
These token numbers have been chosen to be compatible with the default
43+
parser's numbering. This allows us to use its <function>headline()</>
44+
function, thus keeping the example simple.
45+
</para>
46+
-->
1347

1448
<para>
1549
<filename>test_parser</> 识别以空格分隔的单词,并且返回两种令牌类型:
@@ -23,17 +57,49 @@ mydb=# SELECT * FROM ts_token_type('testparser');
2357
(2 rows)
2458
</programlisting>
2559

26-
这些令牌数字被选择来兼容默认的解析器编号。这允许我们可以使用<function>headline()</>函数,从而保持例子的简单。
60+
这些令牌数字被选择来兼容默认的解析器编号。这让我们可以使用<function>headline()</>函数,从而保持例子的简单。
2761
</para>
2862

63+
<!--
64+
<title>Usage</title>
65+
-->
66+
2967
<sect2>
3068
<title>用法</title>
3169

70+
<!--
71+
<para>
72+
Installing the <literal>test_parser</> extension creates a text search
73+
parser <literal>testparser</>. It has no user-configurable parameters.
74+
</para>
75+
-->
76+
3277
<para>
33-
安装<literal>test_parser</>扩展,创建一个文本搜索的解析器testparser。它没有用户可配置参数。
78+
安装<literal>test_parser</>扩展,创建一个文本搜索解析器testparser。它没有用户可配置参数。
3479

3580
</para>
3681

82+
<!--
83+
<para>
84+
You can test the parser with, for example,
85+
86+
<programlisting>
87+
mydb=# SELECT * FROM ts_parse('testparser', 'That''s my first own parser');
88+
tokid | token
89+
-------+--------
90+
3 | That's
91+
12 |
92+
3 | my
93+
12 |
94+
3 | first
95+
12 |
96+
3 | own
97+
12 |
98+
3 | parser
99+
</programlisting>
100+
</para>
101+
-->
102+
37103
<para>
38104
你可以像下面的例子这样测试该解析器,
39105

@@ -53,6 +119,35 @@ mydb=# SELECT * FROM ts_parse('testparser', 'That''s my first own parser');
53119
3 | parser
54120
</programlisting>
55121
</para>
122+
123+
<!--
124+
<para>
125+
Real-world use requires setting up a text search configuration
126+
that uses the parser. For example,
127+
128+
<programlisting>
129+
mydb=# CREATE TEXT SEARCH CONFIGURATION testcfg ( PARSER = testparser );
130+
CREATE TEXT SEARCH CONFIGURATION
131+
132+
mydb=# ALTER TEXT SEARCH CONFIGURATION testcfg
133+
mydb-# ADD MAPPING FOR word WITH english_stem;
134+
ALTER TEXT SEARCH CONFIGURATION
135+
136+
mydb=# SELECT to_tsvector('testcfg', 'That''s my first own parser');
137+
to_tsvector
138+
-------------------------------
139+
'that':1 'first':3 'parser':5
140+
(1 row)
141+
142+
mydb=# SELECT ts_headline('testcfg', 'Supernovae stars are the brightest phenomena in galaxies',
143+
mydb(# to_tsquery('testcfg', 'star'));
144+
ts_headline
145+
-----------------------------------------------------------------
146+
Supernovae &lt;b&gt;stars&lt;/b&gt; are the brightest phenomena in galaxies
147+
(1 row)
148+
</programlisting>
149+
</para>
150+
-->
56151

57152
<para>
58153
实际使用需要配置一个文本搜索配置项来使用这个解析器。例如,

0 commit comments

Comments
 (0)