Skip to content

Commit

Permalink
prefix-search-v2: Add when to use pgroonga_condition() (#388)
Browse files Browse the repository at this point in the history
GitHub: GH-335
  • Loading branch information
abetomo authored Oct 7, 2024
1 parent 73cd596 commit cdcdc9a
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
49 changes: 49 additions & 0 deletions _po/ja/reference/operators/prefix-search-v2.po
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ msgid ""
"```sql\n"
"column &^ prefix\n"
"column &^ (prefix, NULL, index_name)::pgroonga_full_text_search_condition\n"
"column &^ pgroonga_condition(prefix, index_name => 'index_name')\n"
"```"
msgstr ""

Expand All @@ -63,6 +64,14 @@ msgstr ""
"イズしたノーマライザーを使用するためのものです。\n"
"2つ目の使い方は、2.4.6から使えます。"

msgid ""
"The third signature has the same meaning as the second signature.\n"
"You should use this signature in 3.1.6 and above.\n"
"See [`pgroonga_condition` function][condition] for details."
msgstr ""
"3つ目の使い方は2つ目と同じ意味です。3.1.6以降は3つ目の構文を使ってください。"
"詳しくは[`pgroonga_condition`関数][condition]をご覧ください。"

msgid "Here is the description of the first signature."
msgstr "以下は1つ目の使い方の説明です。"

Expand Down Expand Up @@ -230,6 +239,40 @@ msgid ""
"```"
msgstr ""

msgid ""
"The same query with [`pgroonga_condition` function][condition] is as follows."
msgstr ""
"同じクエリを[`pgroonga_condition`関数][condition]を使うと以下の通りです。"

msgid ""
"```sql\n"
"EXPLAIN (COSTS OFF)\n"
"SELECT name\n"
" FROM tags\n"
" WHERE name &^ pgroonga_condition('-p_G', index_name => "
"'pgroonga_tag_name_index');\n"
" QUERY "
"PLAN \n"
"-------------------------------------------------------------------------------\n"
" Seq Scan on tags\n"
" Filter: (name &^ '(-p_G,,,,pgroonga_tag_name_index,,)'::"
"pgroonga_condition)\n"
"(2 rows)"
msgstr ""

msgid ""
"SELECT name\n"
" FROM tags\n"
" WHERE name &^ pgroonga_condition('-p_G', index_name => "
"'pgroonga_tag_name_index');\n"
" name\n"
"-----------\n"
" PGroonga\n"
" pglogical\n"
"(2 rows)\n"
"```"
msgstr ""

msgid "## See also"
msgstr "## 参考"

Expand All @@ -256,6 +299,9 @@ msgstr ""
" * [`&^~|`演算子][prefix-rk-search-in-v2]:プレフィックスの配列での前方一致"
"RK検索"

msgid " * [`pgroonga_condition` function][condition]"
msgstr " * [`pgroonga_condition`関数][condition]"

msgid "[prefix-rk-search-v2]:prefix-rk-search-v2.html"
msgstr ""

Expand All @@ -267,3 +313,6 @@ msgstr ""

msgid "[prefix-rk-search-in-v2]:prefix-rk-search-in-v2.html"
msgstr ""

msgid "[condition]:../functions/pgroonga-condition.html"
msgstr ""
30 changes: 30 additions & 0 deletions ja/reference/operators/prefix-search-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ upper_level: ../
```sql
column &^ prefix
column &^ (prefix, NULL, index_name)::pgroonga_full_text_search_condition
column &^ pgroonga_condition(prefix, index_name => 'index_name')
```

多くの場合は1つ目の使い方で十分です。

2つ目の使い方はPGroongaのインデックスが使用されるかどうかに関わらず、カスタマイズしたノーマライザーを使用するためのものです。
2つ目の使い方は、2.4.6から使えます。

3つ目の使い方は2つ目と同じ意味です。3.1.6以降は3つ目の構文を使ってください。詳しくは[`pgroonga_condition`関数][condition]をご覧ください。

以下は1つ目の使い方の説明です。

```sql
Expand Down Expand Up @@ -141,6 +144,29 @@ SELECT name
(2 rows)
```

同じクエリを[`pgroonga_condition`関数][condition]を使うと以下の通りです。

```sql
EXPLAIN (COSTS OFF)
SELECT name
FROM tags
WHERE name &^ pgroonga_condition('-p_G', index_name => 'pgroonga_tag_name_index');
QUERY PLAN
-------------------------------------------------------------------------------
Seq Scan on tags
Filter: (name &^ '(-p_G,,,,pgroonga_tag_name_index,,)'::pgroonga_condition)
(2 rows)

SELECT name
FROM tags
WHERE name &^ pgroonga_condition('-p_G', index_name => 'pgroonga_tag_name_index');
name
-----------
PGroonga
pglogical
(2 rows)
```

## 参考

* [`&^~`演算子][prefix-rk-search-v2]:前方一致RK検索
Expand All @@ -151,10 +177,14 @@ SELECT name

* [`&^~|`演算子][prefix-rk-search-in-v2]:プレフィックスの配列での前方一致RK検索

* [`pgroonga_condition`関数][condition]

[prefix-rk-search-v2]:prefix-rk-search-v2.html

[prefix-search-in-v2]:prefix-search-in-v2.html

[not-prefix-search-in-v2]:not-prefix-search-in-v2.html

[prefix-rk-search-in-v2]:prefix-rk-search-in-v2.html

[condition]:../functions/pgroonga-condition.html
32 changes: 32 additions & 0 deletions reference/operators/prefix-search-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ Prefix search is useful for implementing input completion.
```sql
column &^ prefix
column &^ (prefix, NULL, index_name)::pgroonga_full_text_search_condition
column &^ pgroonga_condition(prefix, index_name => 'index_name')
```

The first signature is enough for most cases.

The second signature is for using custom normalizer even if PGroonga's index is used or not.
The second signature is available since 2.4.6.

The third signature has the same meaning as the second signature.
You should use this signature in 3.1.6 and above.
See [`pgroonga_condition` function][condition] for details.

Here is the description of the first signature.

```sql
Expand Down Expand Up @@ -141,6 +146,29 @@ SELECT name
(2 rows)
```

The same query with [`pgroonga_condition` function][condition] is as follows.

```sql
EXPLAIN (COSTS OFF)
SELECT name
FROM tags
WHERE name &^ pgroonga_condition('-p_G', index_name => 'pgroonga_tag_name_index');
QUERY PLAN
-------------------------------------------------------------------------------
Seq Scan on tags
Filter: (name &^ '(-p_G,,,,pgroonga_tag_name_index,,)'::pgroonga_condition)
(2 rows)

SELECT name
FROM tags
WHERE name &^ pgroonga_condition('-p_G', index_name => 'pgroonga_tag_name_index');
name
-----------
PGroonga
pglogical
(2 rows)
```

## See also

* [`&^~` operator][prefix-rk-search-v2]: Prefix RK search
Expand All @@ -151,10 +179,14 @@ SELECT name

* [`&^~|` operator][prefix-rk-search-in-v2]: Prefix RK search by an array of prefixes

* [`pgroonga_condition` function][condition]

[prefix-rk-search-v2]:prefix-rk-search-v2.html

[prefix-search-in-v2]:prefix-search-in-v2.html

[not-prefix-search-in-v2]:not-prefix-search-in-v2.html

[prefix-rk-search-in-v2]:prefix-rk-search-in-v2.html

[condition]:../functions/pgroonga-condition.html

0 comments on commit cdcdc9a

Please sign in to comment.