|
From: Kouhei S. <ko...@cl...> - 2016-06-02 03:25:17
|
Hi, PGroonga 1.0.9 has been released! http://groonga.org/en/blog/2016/06/02/pgroonga-1.0.9.html PGroonga is a PostgreSQL extension that makes PostgreSQL fast full text search platform for all languages! Here are changes since 1.0.6: * Supported PostgreSQL 9.6beta1. * [Ubuntu] Supported Xenial Xerus (16.04 LTS). * Added pgroonga.highlight_html function that returns search keyword highlighted HTML. * Added pgroonga.match_positions_byte function that returns locations of keywords in text. * Added pgroonga.query_extract_keywords function that extract keywords from query. * [Windows] Upgraded bundled Groonga to 6.0.3. * [Windows] Upgraded build target PostgreSQL to 9.5.3. * [pgroonga.text_array_term_search_ops_v2 operator class] Added &^> operator that performs prefix search against text[] type value. If any element is matched, the value is matched. * [pgroonga.text_array_term_search_ops_v2 operator class] Added &^~> operator that performs prefix RK search against text[] type value. If any element is matched, the value is matched. This release adds pgroonga.text_array_term_search_ops_v2 operator class. You can use prefix search and prefix RK search against text[] type with this operator class. They are useful to implement input completion on search text box. The following description shows how to use prefix search and prefix RK search. The following description uses an example that implements tag name input completion. First, you need to insert tag names and tag readings. Tag readings should be in Katakana. ---- CREATE TABLE tags ( name text PRIMARY KEY, readings text[] ); INSERT INTO tags VALUES ('PostgreSQL', ARRAY['ポストグレスキューエル', 'ポスグレ']); INSERT INTO tags VALUES ('Groonga', ARRAY['グルンガ']); INSERT INTO tags VALUES ('PGroonga', ARRAY['ピージールンガ']); INSERT INTO tags VALUES ('pglogical', ARRAY['ピージーロジカル']); ---- You need to create indexes against tag names and tag readings. It's important that pgroonga.text_array_term_search_ops_v2 operator class is used for tags.readings. ---- CREATE INDEX pgroonga_tags_index ON tags USING pgroonga (name pgroonga.text_term_search_ops_v2, readings pgroonga.text_array_term_search_ops_v2); ---- Here is a SELECT to use prefix search against tag names such as PostgreSQL and Groonga: ---- SELECT name FROM tags WHERE name &^ 'pos'; -- name -- ------------ -- PostgreSQL -- (1 row) ---- Here is a SELECT to search tags by romanization of Japanese: ---- SELECT name, readings FROM tags WHERE readings &^~> 'pos'; -- name | readings -- ------------+----------------------------------- -- PostgreSQL | {ポストグレスキューエル,ポスグレ} -- (1 row) ---- You can use OR to get both results: ---- SELECT name, readings FROM tags WHERE name &^ 'pos' OR readings &^~> 'pos'; -- name | readings -- ------------+----------------------------------- -- PostgreSQL | {ポストグレスキューエル,ポスグレ} -- (1 row) ---- Here is an example that searches by pi-ji-: ---- SELECT name, readings FROM tags WHERE name &^ 'pi-ji-' OR readings &^~> 'pi-ji-'; -- name | readings -- -----------+-------------------- -- PGroonga | {ピージールンガ} -- pglogical | {ピージーロジカル} -- (2 rows) ---- Thanks, -- kou |