pgroonga / pgroonga

PGroonga is a PostgreSQL extension to use Groonga as index. PGroonga makes PostgreSQL fast full text search platform for all languages!
https://pgroonga.github.io/
Other
547 stars 23 forks source link

pgroonga_highlight_html doesn't support phrase search #69

Closed awh-tokyo closed 6 years ago

awh-tokyo commented 6 years ago

It seems like pgroonga_highlight_html doesn't support a phrase search:

select pgroonga_highlight_html('one two three four five', array['"two three"', 'five'])

outputs

one two three four <span class="keyword">five</span>
kou commented 6 years ago

It should be worked in the future version.

kou commented 6 years ago

You can use it with PGroonga 2.0.7:

CREATE TABLE memos (
  content text
);

CREATE INDEX pgroonga_content_index
          ON memos
       USING pgroonga (content)
        WITH (tokenizer='TokenNgram("report_source_location", true)');

SELECT pgroonga_highlight_html('one two three four five',
                               ARRAY['two three', 'five'],
                               'pgroonga_content_index');
--                               pgroonga_highlight_html                              
-- -----------------------------------------------------------------------------------
--  one<span class="keyword"> two three</span> four<span class="keyword"> five</span>
-- (1 row)

See also: https://pgroonga.github.io/reference/functions/pgroonga-highlight-html.html