Re: Full text search ts_heading strange result - Mailing list pgsql-general

From Tom Lane
Subject Re: Full text search ts_heading strange result
Date
Msg-id 6020.1343257463@sss.pgh.pa.us
Whole thread Raw
In response to Full text search ts_heading strange result  (Johann Spies <jspies@sun.ac.za>)
Responses Re: Full text search ts_heading strange result  (Johann Spies <jspies@sun.ac.za>)
List pgsql-general
Johann Spies <jspies@sun.ac.za> writes:
> I am beginning to use the full text search facilities in Postgresql
> (9.0) and find the result of this query a bit strange:

> query:

> SELECT  ts_headline('simple',title, to_tsquery('kerkreg|(church & polity)'))
> from akb_articles A
> where A.tsv@@ 'kerkreg|(church & polity)'

> Result

> "Kerkvereniging en <b>Kerkreg</b>: Geskiedenis, beginsel en praktyk.(<b>Church</b> unity and <b>church</b> polity:
History,principle and practice.)" 

> Why is 'polity' not highlighted?

I believe the problem is that the one-argument form of to_tsquery() uses
the default TS configuration, which you have probably not got set to
"simple".  For me, the default TS configuration is "english", which will
stem "polity" as "politi":

regression=# select to_tsquery('(polity & church)');
     to_tsquery
---------------------
 'politi' & 'church'
(1 row)

However the "simple" configuration doesn't do anything to that lexeme:

regression=# select to_tsquery('simple', '(polity & church)');
     to_tsquery
---------------------
 'polity' & 'church'
(1 row)

So what you've got is ts_headline() parsing the given title against
the "simple" configuration and getting "polity", but the tsquery is
looking for "politi", hence no match.

In short: omit the 'simple' argument from the ts_headline call, and
things should play together better.  You could alternatively insert
to_tsquery('simple', '(polity & church)'), but that won't exactly
match what the @@ in WHERE is doing: that's going to use the default
configuration.

            regards, tom lane

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: Smaller data types use same disk space
Next
From: Tom Lane
Date:
Subject: Re: Smaller data types use same disk space