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

Commite7f412c

Browse files
author
Artur Zakirov
committed
pg_trgm documentation was corrected
1 parent7bc88be commite7f412c

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

‎doc/src/sgml/pgtrgm.sgml

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@
8585
</entry>
8686
</row>
8787
<row>
88-
<entry><function>substring_similarity(text, text)</function><indexterm><primary>substring_similarity</primary></indexterm></entry>
88+
<entry><function>subword_similarity(text, text)</function><indexterm><primary>subword_similarity</primary></indexterm></entry>
8989
<entry><type>real</type></entry>
9090
<entry>
9191
Returns a number that indicates how similar the first string
92-
to the most similarsubstring of the second string. The range of
92+
to the most similarword of the second string. The range of
9393
the result is zero (indicating that the two strings are completely
9494
dissimilar) to one (indicating that the first string is identical
95-
tosubstring of the secondsubstring).
95+
toone of theword of thesecondstring).
9696
</entry>
9797
</row>
9898
<row>
@@ -145,16 +145,16 @@
145145
<entry>
146146
Returns <literal>true</> if its arguments have a similarity that is
147147
greater than the current similarity threshold set by
148-
<varname>pg_trgm.limit</>.
148+
<varname>pg_trgm.sml_limit</>.
149149
</entry>
150150
</row>
151151
<row>
152-
<entry><type>text</> <literal>&lt;%</literal> <type>text</></entry>
152+
<entry><type>text</> <literal>%&gt;</literal> <type>text</></entry>
153153
<entry><type>boolean</type></entry>
154154
<entry>
155-
Returns <literal>true</> if its arguments have asubstring similarity
156-
that is greater than the currentsubstring similarity threshold set by
157-
<varname>pg_trgm.substring_limit</> parameter.
155+
Returns <literal>true</> if its arguments have asubword similarity
156+
that is greater than the currentsubword similarity threshold set by
157+
<varname>pg_trgm.subword_limit</> parameter.
158158
</entry>
159159
</row>
160160
<row>
@@ -165,6 +165,14 @@
165165
one minus the <function>similarity()</> value.
166166
</entry>
167167
</row>
168+
<row>
169+
<entry><type>text</> <literal>&lt;-&gt;&gt;</literal> <type>text</></entry>
170+
<entry><type>real</type></entry>
171+
<entry>
172+
Returns the <quote>distance</> between the arguments, that is
173+
one minus the <function>subword_similarity()</> value.
174+
</entry>
175+
</row>
168176
</tbody>
169177
</tgroup>
170178
</table>
@@ -174,11 +182,11 @@
174182
<title>GUC Parameters</title>
175183

176184
<variablelist>
177-
<varlistentry id="guc-pgtrgm-limit" xreflabel="pg_trgm.limit">
185+
<varlistentry id="guc-pgtrgm-sml-limit" xreflabel="pg_trgm.sml_limit">
178186
<term>
179-
<varname>pg_trgm.limit</> (<type>real</type>)
187+
<varname>pg_trgm.sml_limit</> (<type>real</type>)
180188
<indexterm>
181-
<primary><varname>pg_trgm.limit</> configuration parameter</primary>
189+
<primary><varname>pg_trgm.sml_limit</> configuration parameter</primary>
182190
</indexterm>
183191
</term>
184192
<listitem>
@@ -189,17 +197,17 @@
189197
</listitem>
190198
</varlistentry>
191199

192-
<varlistentry id="guc-pgtrgm-substring-limit" xreflabel="pg_trgm.substring_limit">
200+
<varlistentry id="guc-pgtrgm-subword-limit" xreflabel="pg_trgm.subword_limit">
193201
<term>
194-
<varname>pg_trgm.substring_limit</> (<type>real</type>)
202+
<varname>pg_trgm.subword_limit</> (<type>real</type>)
195203
<indexterm>
196-
<primary><varname>pg_trgm.substring_limit</> configuration parameter</primary>
204+
<primary><varname>pg_trgm.subword_limit</> configuration parameter</primary>
197205
</indexterm>
198206
</term>
199207
<listitem>
200208
<para>
201-
Sets the currentsubstring similarity threshold that is used by
202-
the <literal>&lt;%</> operator. The threshold must be between
209+
Sets the currentsubword similarity threshold that is used by
210+
the <literal>%&gt;</> operator. The threshold must be between
203211
0 and 1 (default is 0.6).
204212
</para>
205213
</listitem>
@@ -262,20 +270,31 @@ SELECT t, t &lt;-&gt; '<replaceable>word</>' AS dist
262270
</para>
263271

264272
<para>
265-
Also you can use an index on the <structfield>t</> column forsubstring
273+
Also you can use an index on the <structfield>t</> column forsubword
266274
similarity. For example:
267275
<programlisting>
268-
SELECT t,substring_similarity('<replaceable>word</>', t) AS sml
276+
SELECT t,subword_similarity('<replaceable>word</>', t) AS sml
269277
FROM test_trgm
270-
WHERE '<replaceable>word</>' &lt;% t
278+
WHEREt %&gt;'<replaceable>word</>'
271279
ORDER BY sml DESC, t;
272280
</programlisting>
273-
This will return all values in the text column that have asubstring
281+
This will return all values in the text column that have aword
274282
which sufficiently similar to <replaceable>word</>, sorted from best
275283
match to worst. The index will be used to make this a fast operation
276284
even over very large data sets.
277285
</para>
278286

287+
<para>
288+
A variant of the above query is
289+
<programlisting>
290+
SELECT t, t &lt;-&gt;&gt; '<replaceable>word</>' AS dist
291+
FROM test_trgm
292+
ORDER BY dist LIMIT 10;
293+
</programlisting>
294+
This can be implemented quite efficiently by GiST indexes, but not
295+
by GIN indexes.
296+
</para>
297+
279298
<para>
280299
Beginning in <productname>PostgreSQL</> 9.1, these index types also support
281300
index searches for <literal>LIKE</> and <literal>ILIKE</>, for example
@@ -396,4 +415,4 @@ CREATE INDEX words_idx ON words USING GIN (word gin_trgm_ops);
396415
</para>
397416
</sect2>
398417

399-
</sect1>
418+
</sect1>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp