public inbox for [email protected]  
help / color / mirror / Atom feed
Example not producing shown output
6+ messages / 4 participants
[nested] [flat]

* Example not producing shown output
@ 2019-11-25 12:05 PG Doc comments form <[email protected]>
  2019-11-25 14:23 ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: PG Doc comments form @ 2019-11-25 12:05 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/functions-textsearch.html
Description:

Page: https://www.postgresql.org/docs/12/functions-textsearch.html

Examples should have specified 'english'.

Instead:
   to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')

which returns fale on my own blank installation of Postgre (Serbian locale
Windows OS) instead of true:
   to_tsvector('english', 'fat cats ate rats') @@ to_tsquery('cat & rat')


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Example not producing shown output
  2019-11-25 12:05 Example not producing shown output PG Doc comments form <[email protected]>
@ 2019-11-25 14:23 ` Daniel Gustafsson <[email protected]>
  2019-11-26 18:28   ` Re: Example not producing shown output Alvaro Herrera <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Daniel Gustafsson @ 2019-11-25 14:23 UTC (permalink / raw)
  To: [email protected]; [email protected]

> On 25 Nov 2019, at 13:05, PG Doc comments form <[email protected]> wrote:
> 
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/12/functions-textsearch.html
> Description:
> 
> Page: https://www.postgresql.org/docs/12/functions-textsearch.html
> 
> Examples should have specified 'english'.
> 
> Instead:
>   to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')
> 
> which returns fale on my own blank installation of Postgre (Serbian locale
> Windows OS) instead of true:
>   to_tsvector('english', 'fat cats ate rats') @@ to_tsquery('cat & rat')


I agree with this complaint, mainly since other examples on the page do specify
english where required AFAICT, this makes it consistent.  The attached diff
adds the english configuration directive to @@ and @@@.

The examples on chapter 12.1 all have the same issue, but adding 'english' to
all of them in order to make them work out of the box everywhere doesn't seem
like an improvement to the docs so those are left as is.

cheers ./daniel





Attachments:

  [application/octet-stream] textsearch_english.diff (1.2K, 2-textsearch_english.diff)
  download | inline diff:
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 57a1539506..cc29d2ed47 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -9889,14 +9889,14 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
         <entry> <literal>@@</literal> </entry>
         <entry><type>boolean</type></entry>
         <entry><type>tsvector</type> matches <type>tsquery</type> ?</entry>
-        <entry><literal>to_tsvector('fat cats ate rats') @@ to_tsquery('cat &amp; rat')</literal></entry>
+        <entry><literal>to_tsvector('english', 'fat cats ate rats') @@ to_tsquery('english', 'cat &amp; rat')</literal></entry>
         <entry><literal>t</literal></entry>
        </row>
        <row>
         <entry> <literal>@@@</literal> </entry>
         <entry><type>boolean</type></entry>
         <entry>deprecated synonym for <literal>@@</literal></entry>
-        <entry><literal>to_tsvector('fat cats ate rats') @@@ to_tsquery('cat &amp; rat')</literal></entry>
+        <entry><literal>to_tsvector('english', 'fat cats ate rats') @@@ to_tsquery('english', 'cat &amp; rat')</literal></entry>
         <entry><literal>t</literal></entry>
        </row>
        <row>


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Example not producing shown output
  2019-11-25 12:05 Example not producing shown output PG Doc comments form <[email protected]>
  2019-11-25 14:23 ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
@ 2019-11-26 18:28   ` Alvaro Herrera <[email protected]>
  2019-11-27 13:59     ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Alvaro Herrera @ 2019-11-26 18:28 UTC (permalink / raw)
  To: Daniel Gustafsson <[email protected]>; +Cc: [email protected]; [email protected]

On 2019-Nov-25, Daniel Gustafsson wrote:

> > On 25 Nov 2019, at 13:05, PG Doc comments form <[email protected]> wrote:

> > Examples should have specified 'english'.
> > 
> > Instead:
> >   to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')
> > 
> > which returns fale on my own blank installation of Postgre (Serbian locale
> > Windows OS) instead of true:
> >   to_tsvector('english', 'fat cats ate rats') @@ to_tsquery('cat & rat')
> 
> I agree with this complaint, mainly since other examples on the page do specify
> english where required AFAICT, this makes it consistent.

Hmm.  I'm not sure that it's an improvement to make all the examples
alike; that means we would not provide examples of the simpler syntax.
And because other examples already show that it's possible to indicate
the language, I'm not sure it's strictly necessary to do so here.

Maybe this complaint could be addressed by indicating in a note that
some examples might not work identically if run under a different
locale.  Or perhaps we can add a second line in the example cell for the
@@ operator, to make it clear that both forms can be used.  Users can be
expected to apply some intuition from that point onwards.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Example not producing shown output
  2019-11-25 12:05 Example not producing shown output PG Doc comments form <[email protected]>
  2019-11-25 14:23 ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
  2019-11-26 18:28   ` Re: Example not producing shown output Alvaro Herrera <[email protected]>
@ 2019-11-27 13:59     ` Daniel Gustafsson <[email protected]>
  2019-11-28 14:22       ` Re: Example not producing shown output Alvaro Herrera <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Daniel Gustafsson @ 2019-11-27 13:59 UTC (permalink / raw)
  To: Alvaro Herrera <[email protected]>; +Cc: [email protected]; [email protected]

> On 26 Nov 2019, at 19:28, Alvaro Herrera <[email protected]> wrote:

> Or perhaps we can add a second line in the example cell for the
> @@ operator, to make it clear that both forms can be used.  Users can be
> expected to apply some intuition from that point onwards.

Wouldn't it be more intuitive to add such a second line under to_tsvector, or
expand the Description field to cover a brief discussion covering this? 

cheers ./daniel





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Example not producing shown output
  2019-11-25 12:05 Example not producing shown output PG Doc comments form <[email protected]>
  2019-11-25 14:23 ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
  2019-11-26 18:28   ` Re: Example not producing shown output Alvaro Herrera <[email protected]>
  2019-11-27 13:59     ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
@ 2019-11-28 14:22       ` Alvaro Herrera <[email protected]>
  2019-12-18 03:27         ` Re: Example not producing shown output Bruce Momjian <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Alvaro Herrera @ 2019-11-28 14:22 UTC (permalink / raw)
  To: Daniel Gustafsson <[email protected]>; +Cc: [email protected]; [email protected]

On 2019-Nov-27, Daniel Gustafsson wrote:

> > On 26 Nov 2019, at 19:28, Alvaro Herrera <[email protected]> wrote:
> 
> > Or perhaps we can add a second line in the example cell for the
> > @@ operator, to make it clear that both forms can be used.  Users can be
> > expected to apply some intuition from that point onwards.
> 
> Wouldn't it be more intuitive to add such a second line under to_tsvector, or
> expand the Description field to cover a brief discussion covering this? 

I don't know.  The problem is that the line for to_tsvector is a lot
further down the page in table 9.42, and it contains a lot of other
stuff, so people trying their first examples based on table 9.41 would
not see it and will be as surprised as the OP was when it doesn't work
under their locale.

I think enlarging the description for the @@ entry is not out of the
question, but trying to explain too much about the locale there seems a
bit out of place.  This is why I suggested to add another Note box below
the table.

If I misunderstood what you meant, please be more specific.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Example not producing shown output
  2019-11-25 12:05 Example not producing shown output PG Doc comments form <[email protected]>
  2019-11-25 14:23 ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
  2019-11-26 18:28   ` Re: Example not producing shown output Alvaro Herrera <[email protected]>
  2019-11-27 13:59     ` Re: Example not producing shown output Daniel Gustafsson <[email protected]>
  2019-11-28 14:22       ` Re: Example not producing shown output Alvaro Herrera <[email protected]>
@ 2019-12-18 03:27         ` Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Bruce Momjian @ 2019-12-18 03:27 UTC (permalink / raw)
  To: Alvaro Herrera <[email protected]>; +Cc: Daniel Gustafsson <[email protected]>; [email protected]; [email protected]

On Thu, Nov 28, 2019 at 11:22:20AM -0300, Alvaro Herrera wrote:
> On 2019-Nov-27, Daniel Gustafsson wrote:
> 
> > > On 26 Nov 2019, at 19:28, Alvaro Herrera <[email protected]> wrote:
> > 
> > > Or perhaps we can add a second line in the example cell for the
> > > @@ operator, to make it clear that both forms can be used.  Users can be
> > > expected to apply some intuition from that point onwards.
> > 
> > Wouldn't it be more intuitive to add such a second line under to_tsvector, or
> > expand the Description field to cover a brief discussion covering this? 
> 
> I don't know.  The problem is that the line for to_tsvector is a lot
> further down the page in table 9.42, and it contains a lot of other
> stuff, so people trying their first examples based on table 9.41 would
> not see it and will be as surprised as the OP was when it doesn't work
> under their locale.
> 
> I think enlarging the description for the @@ entry is not out of the
> question, but trying to explain too much about the locale there seems a
> bit out of place.  This is why I suggested to add another Note box below
> the table.
> 
> If I misunderstood what you meant, please be more specific.

Would adding more doc places where we set the session language to
English help here, rather than doing it in the function calls?

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +






^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2019-12-18 03:27 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 12:05 Example not producing shown output PG Doc comments form <[email protected]>
2019-11-25 14:23 ` Daniel Gustafsson <[email protected]>
2019-11-26 18:28   ` Alvaro Herrera <[email protected]>
2019-11-27 13:59     ` Daniel Gustafsson <[email protected]>
2019-11-28 14:22       ` Alvaro Herrera <[email protected]>
2019-12-18 03:27         ` Bruce Momjian <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox