new function for tsquery creartion

From: Victor Drobny <v(dot)drobny(at)postgrespro(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Subject: new function for tsquery creartion
Date: 2017-07-19 16:43:51
Message-ID: fe931111ff7e9ad79196486ada79e268@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear all,

Now Postgres has a few functions to create tsqueries for full text
search. The main one is the to_tsquery function that allows to make
query with any operation. But to make correct query all of the operators
should be specified explicitly. In order to make it easier postgres has
functions like plainto_tsquery and phraseto_tsquery which allow to make
tsqueries from strings. But they are not flexible enough.

Let me introduce new function for full text search query creation(which
is called 'queryto_tsquery'). It takes 'google like' query string and
translates it to tsquery.
The main features are the following:
All the text inside double quotes would be treated as a phrase("a b c"
-> 'a <-> b <-> c')
New operator AROUND(N). It matches if the distance between words(or
maybe phrases) is less than or equal to N.
Alias for !('-rat' is the same as '!rat')
Alias for |('dog OR cat' is the same as 'dog | cat')

As a plainto_tsquery and phraseto_tsquery it will fill operators by
itself, but already placed operations won't be ignored. It allows to
combine two approaches.

In the attachment you can find patch with the new features, tests and
documentation for it.
What do you think about it?

Thank you very much for the attention!

--
------
Victor Drobny
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachment Content-Type Size
queryto_tsquery.patch text/x-diff 32.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-07-19 16:53:34 Re: Something for the TODO list: deprecating abstime and friends
Previous Message Tom Lane 2017-07-19 16:39:07 Re: tupconvert.c API change in v10 release notes