On Fri, Jun 26, 2015 at 8:05 AM, Robert Haas <robertmh...@gmail.com> wrote:
> I would be fine with adding a *compact* example of this kind to the
> table that begins section 8.14.3.  I probably would not back-patch it,
> because the absence of that example is not an error in the
> documentation, but I will not complain if someone else does.

How about the attached? It's a compact refinement of my original
example of more complicated jsonb containment.

I still think it would be a good idea to go back to 9.4. I have reason
to believe that people are getting confused on this point.

-- 
Peter Geoghegan
diff --git a/doc/src/sgml/json.sgml b/doc/src/sgml/json.sgml
index 118fb35..f5c8fca 100644
--- a/doc/src/sgml/json.sgml
+++ b/doc/src/sgml/json.sgml
@@ -300,11 +300,21 @@ SELECT '{"foo": {"bar": "baz"}}'::jsonb @&gt; '{"foo": {}}'::jsonb;
    The general principle is that the contained object must match the
    containing object as to structure and data contents, possibly after
    discarding some non-matching array elements or object key/value pairs
-   from the containing object.
+   from the containing object.  Containment is <emphasis>nested</>.
    But remember that the order of array elements is not significant when
    doing a containment match, and duplicate array elements are effectively
    considered only once.
+   This example shows containment with complex nesting:
   </para>
+<programlisting>
+-- By convention, the "doc" jsonb column has an object at the top
+-- level.  Each object contains a "tags" array, which itself
+-- contains key/value pairs.  Often, "term" tags are available among
+-- tag pairs.
+--
+-- Return "site_name" where at least these two terms appear:
+SELECT doc->'site_name' from websites where doc @&gt; '{"tags":[{"term":"paris" }, {"term":"food"}]}';
+</programlisting>
 
   <para>
    As a special exception to the general principle that the structures
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to