Author: sergiykarpenko
Date: 2010-08-03 10:10:08 -0400 (Tue, 03 Aug 2010)
New Revision: 2865
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/and-constraint.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/escaping-like-statements.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-nodes.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-mixin-type.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-primary-type.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-case-insensitive.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/like-constraint.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/not-constraint.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/or-constraint.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-comparison.xml
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-existance-constraint.xml
Modified:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml
Log:
EXOJCR-869: jcr-query-usecases ported
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/and-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/and-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/and-constraint.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.ANDConstraint">
+ <title>AND Constraint</title>
+
+ <para>Find all fairytales with a page count more than 90 pages.</para>
+
+ <para>How does it sound in jcr terms - Find all nodes with mixin type
+ 'mix:title' where the property 'jcr:description' equals
"fairytale" and
+ whose "prop_pagecount" property value is less than 90.</para>
+
+ <note>
+ <para>See also <link
linkend="JCR.MultiValuePropertyComparison">Multivalue
+ Property Comparison</link>.</para>
+ </note>
+
+ <section>
+ <title>Repository Structure:</title>
+
+ <para>The repository contains mix:title nodes, where prop_pagecount has
+ different values.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="War and peace"
+ jcr:description="novel" prop_pagecount=1000</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="Cinderella"
+ jcr:description="fairytale" prop_pagecount=100</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Puss in Boots"
+ jcr:description="fairytale" prop_pagecount=60</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE jcr:description =
'fairytale' AND prop_pagecount > 90";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)[@jcr:description='fairytale'
and @prop_pagecount > 90]";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document2".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is:<table>
+ <title>Table content</title>
+
+ <tgroup cols="5">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>jcr:description</entry>
+
+ <entry>prop_pagecount</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>Cinderella</entry>
+
+ <entry>fairytale</entry>
+
+ <entry>100</entry>
+
+ <entry>/document2</entry>
+
+ <entry>7086</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/escaping-like-statements.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/escaping-like-statements.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/escaping-like-statements.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.EscapinginLIKEStatements">
+ <title>Escaping in LIKE Statements</title>
+
+ <para>Find all nodes with a mixin type 'mix:title' and whose property
+ 'jcr:title' starts with 'P%ri'.</para>
+
+ <para>As you see "P%rison break" contains the symbol '%'. This
symbol is
+ reserved for LIKE comparisons. So what we can do?</para>
+
+ <para>Within the LIKE pattern, literal instances of percent ("%") or
+ underscore ("_") must be escaped. The SQL ESCAPE clause allows the
+ definition of an arbitrary escape character within the context of a single
+ LIKE statement. The following example defines the backslash ' \' as escape
+ character:</para>
+
+ <programlisting>SELECT * FROM mytype WHERE a LIKE 'foo\%' ESCAPE
'\'</programlisting>
+
+ <para>XPath does not have any specification for defining escape symbols, so
+ we must use the default escape character (' \').</para>
+
+ <section>
+ <title>Repository structure</title>
+
+ <para>The repository contains mix:title nodes, where jcr:title can have
+ different values.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="Star wars"
+ jcr:description="Dart rules!!"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="P%rison break"
+ jcr:description="Run, Forest, run ))"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Panopticum"
+ jcr:description="It's imagine film"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE jcr:title LIKE 'P#%ri%'
ESCAPE '#'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)[jcr:like(@jcr:title,
'P\\%ri%')]";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetch result</title>
+
+ <para>Lets get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document2".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>The table content is <table>
+ <title>Table content</title>
+
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>jcr:description</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>P%rison break</entry>
+
+ <entry>Run, Forest, run ))</entry>
+
+ <entry>/document2</entry>
+
+ <entry>7452</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-nodes.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-nodes.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-all-nodes.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.FindAllNodes">
+ <title>Find All Nodes</title>
+
+ <para>Find all nodes in the repository. Only those nodes are found to which
+ the session has READ permission. See also <ulink
+ url="JCR.AccessControl">Access Control</ulink>.</para>
+
+ <section>
+ <title>Repository structure:</title>
+
+ <para>Repository contains many different nodes.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>folder1 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (nt:file)</para>
+ </listitem>
+
+ <listitem>
+ <para>folder2 (nt:folder)</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document2 (nt:unstructured)</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (nt:folder)</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM nt:base";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,nt:base)";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetch result</title>
+
+ <para>Lets get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "folder1",
+
"folder2","document1","document2","document3", and
each other nodes in
+ workspace if they are here.</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is</para>
+
+ <table>
+ <title>Table content</title>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>/folder1</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/document1</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/folder2</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/folder2/document2</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>/folder1/folder2/document3</entry>
+
+ <entry>1000</entry>
+ </row>
+
+ <row>
+ <entry>...</entry>
+
+ <entry>...</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-mixin-type.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-mixin-type.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-mixin-type.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.FindNodesByMixinType">
+ <title>Find Nodes by Mixin Type</title>
+
+ <para>Find all nodes in repository, that contain a mixin type
+ "mix:title".</para>
+
+ <section>
+ <title>Repository structure:</title>
+
+ <para>The repository contains nodes with different primary types and mixin
+ types.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 primarytype = "nt:unstructured" mixintype =
+ "mix:title"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 primarytype = "nt:file" mixintype =
+ "mix:lockable"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 primarytype = "nt:file" mixintype =
+ "mix:title"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetch result</title>
+
+ <para>Lets get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>The NodeIterator will return "document1" and
"document3".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is <table>
+ <title>Table content</title>
+
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>...</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>First document</entry>
+
+ <entry>...</entry>
+
+ <entry>/document1</entry>
+
+ <entry>2674</entry>
+ </row>
+
+ <row>
+ <entry>Second document</entry>
+
+ <entry>...</entry>
+
+ <entry>/document3</entry>
+
+ <entry>2674</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-primary-type.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-primary-type.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-by-primary-type.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.FindNodesByPrimaryType">
+ <title>Find Nodes by Primary Type</title>
+
+ <para>Find all nodes whose primary type is "nt:file".</para>
+
+ <section>
+ <title>Repository structure:</title>
+
+ <para>The repository contains nodes with different primary types and mixin
+ types.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 primarytype = "nt:unstructured" mixintype =
+ "mix:title"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 primarytype = "nt:file" mixintype =
+ "mix:lockable"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 primarytype = "nt:file" mixintype =
+ "mix:title"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM nt:file";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,nt:file)";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetch result</title>
+
+ <para>Lets get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document2" and
"document3".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>The table content is <table>
+ <title>Table content</title>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry> /document2</entry>
+
+ <entry>2674</entry>
+ </row>
+
+ <row>
+ <entry>/document3</entry>
+
+ <entry>2674</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-case-insensitive.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-case-insensitive.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/find-nodes-case-insensitive.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.FindNodesCaseInsensitive">
+ <title>Find Nodes in a Case-Insensitive Way</title>
+
+ <para>Find all nodes with a mixin type 'mix:title' and where the
property
+ 'jcr:title' equals 'casesensitive' in lower or upper
case.</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>The repository contains mix:title nodes, whose jcr:title properties
+ have different values.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title)
jcr:title="CaseSensitive"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title)
jcr:title="casesensitive"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title)
jcr:title="caseSENSITIVE"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query Execution</title>
+
+ <itemizedlist>
+ <listitem>
+ <para>UPPER case</para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE UPPER(jcr:title) =
'CASESENSITIVE'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement =
"//element(*,mix:title)[fn:upper-case(@jcr:title)='CASESENSITIVE']";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <itemizedlist>
+ <listitem>
+ <para>LOWER case</para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE LOWER(jcr:title) =
'casesensitive'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement =
"//element(*,mix:title)[fn:lower-case(@jcr:title)='casesensitive']";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document1", "document2" and
"document3"
+ (in all examples).</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is: <table>
+ <title>Table content</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry> jcr:title</entry>
+
+ <entry>...</entry>
+
+ <entry>jcr:path</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>CaseSensitive</entry>
+
+ <entry>...</entry>
+
+ <entry>/document1</entry>
+ </row>
+
+ <row>
+ <entry>casesensitive</entry>
+
+ <entry>...</entry>
+
+ <entry>/document2</entry>
+ </row>
+
+ <row>
+ <entry>caseSENSITIVE</entry>
+
+ <entry>...</entry>
+
+ <entry>/document3</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Modified:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml 2010-08-03
13:58:16 UTC (rev 2864)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/jcr-query-usecases.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -1,324 +1,322 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<chapter id="JCR.QueryUsecases">
- <title>JCR Query Usecases</title>
-
- <section>
- <title>Intro</title>
-
- <para>JCR supports two query languages - JCR and XPath. A query, whether
- XPath or SQL, specifies a subset of nodes within a workspace, called the
- result set. The result set constitutes all the nodes in the workspace that
- meet the constraints stated in the query.</para>
- </section>
-
- <section>
- <title>Query Lifecycle</title>
-
- <section>
- <title>Query Creation and Execution</title>
-
- <para><emphasis
role="bold">SQL</emphasis></para>
-
- <programlisting>// get QueryManager
-QueryManager queryManager = workspace.getQueryManager();
-// make SQL query
-Query query = queryManager.createQuery("SELECT * FROM nt:base ", Query.SQL);
-// execute query
-QueryResult result = query.execute();</programlisting>
-
- <para><emphasis
role="bold">XPath</emphasis></para>
-
- <programlisting>// get QueryManager
-QueryManager queryManager = workspace.getQueryManager();
-// make XPath query
-Query query = queryManager.createQuery("//element(*,nt:base)", Query.XPATH);
-// execute query
-QueryResult result = query.execute();</programlisting>
- </section>
-
- <section>
- <title>Query Result Processing</title>
-
- <programlisting>// fetch query result
-QueryResult result = query.execute();</programlisting>
-
- <para>Now we can get result in an iterator of nodes:</para>
-
- <programlisting>NodeIterator it = result.getNodes();</programlisting>
-
- <para>or we get the result in a table:</para>
-
- <programlisting>// get column names
-String[] columnNames = result.getColumnNames();
-// get column rows
-RowIterator rowIterator = result.getRows();
-while(rowIterator.hasNext()){
- // get next row
- Row row = rowIterator.nextRow();
- // get all values of row
- Value[] values = row.getValues();
-}</programlisting>
- </section>
-
- <section>
- <title>Scoring</title>
-
- <para>The result returns a score for each row in the result set. The
- score contains a value that indicates a rating of how well the result
- node matches the query. A high value means a better matching than a low
- value. This score can be used for ordering the result.</para>
-
- <para>eXo JCR Scoring is a mapping of Lucene scoring. For a more
- in-depth understanding, please study <ulink
-
url="http://lucene.apache.org/java/2_4_1/scoring.html">Lucene
- documentation</ulink>.</para>
-
- <para>jcr:score counted in next way - (lucene score)*1000f.</para>
-
- <para>Score may be increased for specified nodes, see <ulink
- url="Index Boost Value">Index Boost Value</ulink></para>
-
- <para>Also, see an example <ulink url="JCR.Order by
Score">JCR.Order by
- Score</ulink></para>
- </section>
- </section>
-
- <section>
- <title>Query Examples</title>
-
- <section>
- <title>Query result settings</title>
-
- <itemizedlist>
- <listitem>
- <para><link linkend="JCR.SetOffsetandSetLimit">Set Offset
And
- Limit</link></para>
- </listitem>
-
- <!--listitem>
- <xi:include href="offset-and-limit.xml"
-
xmlns:xi="http://www.w3.org/2001/XInclude" />
- </listitem-->
- </itemizedlist>
- </section>
-
- <section>
- <title>Type Constraints</title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="JCR.Find All Nodes">JCR.Find All
- Nodes</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Find Nodes by Primary
Type">JCR.Find Nodes by
- Primary Type</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Find Nodes by Mixin Type">JCR.Find
Nodes by
- Mixin Type</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section>
- <title>Property Constraints</title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="JCR.Property Comparison">JCR.Property
- Comparison</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.LIKE Constraint">JCR.LIKE
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Escaping in LIKE
Statements">JCR.Escaping in
- LIKE Statements</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.NOT Constraint">JCR.NOT
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.AND Constraint">JCR.AND
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.OR Constraint">JCR.OR
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Property Existence
Constraint">JCR.Property
- Existence Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Upper and Lower Case
Constraints">JCR.Upper
- and Lower Case Constraints</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Date Property Comparison">JCR.Date
Property
- Comparison</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Node Name Constraint">JCR.Node
Name
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Multivalue Property
Comparison">JCR.Multivalue
- Property Comparison</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section>
- <title>Path Constraint</title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="JCR.Exact Path Constraint">JCR.Exact
Path
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Child Node Constraint">JCR.Child
Node
- Constraint</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Find All Descendant Nodes">JCR.Find
All
- Descendant Nodes</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section>
- <title>Ordering specifing</title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="JCR.Order by Property">JCR.Order by
- Property</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Order by Descendant Node
Property">JCR.Order
- by Descendant Node Property</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Order by Score">JCR.Order by
- Score</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Order by Path or Name">JCR.Order by
Path or
- Name</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section>
- <title><ulink url="Fulltext Search">Fulltext
Search</ulink></title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="JCR.Fulltext Search by
Property">JCR.Fulltext
- Search by Property</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink
- url="JCR.Fulltext Search by All Properties">JCR.Fulltext Search
by
- All Properties</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink
- url="Find nt:file document by content of child jcr:content
node>Aggregation rule">Find
- nt:file document by content of child jcr:content node>Aggregation
- rule</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink
- url="How to set new Analyzer. Accent symblos ignoring>JCR.Ignore
Accent Symbols">How
- to set new Analyzer. Accent symblos ignoring>JCR.Ignore Accent
- Symbols</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
-
- <section>
- <title>Indexing rules and additional features</title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="Aggregation rule">Aggregation
rule</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="JCR.Search Result
Highlighting">JCR.Search Result
- Highlighting</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="Index Boost Value">Index Boost
- Value</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink
- url="Exclusion from the Node Scope Index>JCR.Node Scope
Index">Exclusion
- from the Node Scope Index>JCR.Node Scope
Index</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink
- url="Regular expressions as property name in indexing rule > Regexp
Indexing Rule">Regular
- expressions as property name in indexing rule > Regexp Indexing
- Rule</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="Synonim Provider">Synonim
Provider</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="Spell Checking">Spell
Checking</ulink></para>
- </listitem>
-
- <listitem>
- <para><ulink url="Find Similar Nodes">Find Similar
- Nodes</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
- </section>
-
- <section>
- <title>Tips and tricks</title>
-
- <itemizedlist>
- <listitem>
- <para><ulink url="Xpath and numbers in node names">Xpath
and numbers
- in node names</ulink></para>
- </listitem>
- </itemizedlist>
- </section>
-</chapter>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="JCR.QueryUsecases">
+ <title>JCR Query Usecases</title>
+
+ <section>
+ <title>Intro</title>
+
+ <para>JCR supports two query languages - JCR and XPath. A query, whether
+ XPath or SQL, specifies a subset of nodes within a workspace, called the
+ result set. The result set constitutes all the nodes in the workspace that
+ meet the constraints stated in the query.</para>
+ </section>
+
+ <section>
+ <title>Query Lifecycle</title>
+
+ <section>
+ <title>Query Creation and Execution</title>
+
+ <para><emphasis
role="bold">SQL</emphasis></para>
+
+ <programlisting>// get QueryManager
+QueryManager queryManager = workspace.getQueryManager();
+// make SQL query
+Query query = queryManager.createQuery("SELECT * FROM nt:base ", Query.SQL);
+// execute query
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// get QueryManager
+QueryManager queryManager = workspace.getQueryManager();
+// make XPath query
+Query query = queryManager.createQuery("//element(*,nt:base)", Query.XPATH);
+// execute query
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Query Result Processing</title>
+
+ <programlisting>// fetch query result
+QueryResult result = query.execute();</programlisting>
+
+ <para>Now we can get result in an iterator of nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();</programlisting>
+
+ <para>or we get the result in a table:</para>
+
+ <programlisting>// get column names
+String[] columnNames = result.getColumnNames();
+// get column rows
+RowIterator rowIterator = result.getRows();
+while(rowIterator.hasNext()){
+ // get next row
+ Row row = rowIterator.nextRow();
+ // get all values of row
+ Value[] values = row.getValues();
+}</programlisting>
+ </section>
+
+ <section>
+ <title>Scoring</title>
+
+ <para>The result returns a score for each row in the result set. The
+ score contains a value that indicates a rating of how well the result
+ node matches the query. A high value means a better matching than a low
+ value. This score can be used for ordering the result.</para>
+
+ <para>eXo JCR Scoring is a mapping of Lucene scoring. For a more
+ in-depth understanding, please study <ulink
+
url="http://lucene.apache.org/java/2_4_1/scoring.html">Lucene
+ documentation</ulink>.</para>
+
+ <para>jcr:score counted in next way - (lucene score)*1000f.</para>
+
+ <para>Score may be increased for specified nodes, see <ulink
+ url="Index Boost Value">Index Boost Value</ulink></para>
+
+ <para>Also, see an example <link
linkend="JCR.OrderByScore">Order by
+ Score</link></para>
+ </section>
+ </section>
+
+ <section>
+ <title>Query Examples</title>
+
+ <section>
+ <title>Query result settings</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><link linkend="JCR.SetOffsetandSetLimit">Set Offset
And
+ Limit</link></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Type Constraints</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><link linkend="JCR.FindAllNodes">Find All
Nodes</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.FindNodesByPrimaryType">Find
Nodes by
+ Primary Type</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.FindNodesByMixinType">Find Nodes
by Mixin
+ Type</link></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Property Constraints</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><link linkend="JCR.PropertyComparison">Property
+ Comparison</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.LIKEConstraint">LIKE
+ Constraint</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link
linkend="JCR.EscapinginLIKEStatements">Escaping in LIKE
+ Statements</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.NOTConstraint">NOT
Constraint</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.ANDConstraint">AND
Constraint</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.ORConstraint">OR
Constraint</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link
linkend="JCR.PropertyExistenceConstraint">Property
+ Existence Constraint</link></para>
+ </listitem>
+
+ <listitem>
+ <para><link linkend="JCR.FindNodesCaseInsensitive">Upper
and Lower
+ Case Constraints</link></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Date Property Comparison">JCR.Date
Property
+ Comparison</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Node Name Constraint">JCR.Node
Name
+ Constraint</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Multivalue Property
Comparison">JCR.Multivalue
+ Property Comparison</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Path Constraint</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><ulink url="JCR.Exact Path Constraint">JCR.Exact
Path
+ Constraint</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Child Node Constraint">JCR.Child
Node
+ Constraint</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Find All Descendant Nodes">JCR.Find
All
+ Descendant Nodes</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Ordering specifing</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><ulink url="JCR.Order by Property">JCR.Order by
+ Property</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Order by Descendant Node
Property">JCR.Order
+ by Descendant Node Property</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Order by Score">JCR.Order by
+ Score</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Order by Path or Name">JCR.Order by
Path or
+ Name</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title><ulink url="Fulltext Search">Fulltext
Search</ulink></title>
+
+ <itemizedlist>
+ <listitem>
+ <para><ulink url="JCR.Fulltext Search by
Property">JCR.Fulltext
+ Search by Property</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink
+ url="JCR.Fulltext Search by All Properties">JCR.Fulltext Search
by
+ All Properties</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink
+ url="Find nt:file document by content of child jcr:content
node>Aggregation rule">Find
+ nt:file document by content of child jcr:content node>Aggregation
+ rule</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink
+ url="How to set new Analyzer. Accent symblos ignoring>JCR.Ignore
Accent Symbols">How
+ to set new Analyzer. Accent symblos ignoring>JCR.Ignore Accent
+ Symbols</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Indexing rules and additional features</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><ulink url="Aggregation rule">Aggregation
rule</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="JCR.Search Result
Highlighting">JCR.Search Result
+ Highlighting</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="Index Boost Value">Index Boost
+ Value</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink
+ url="Exclusion from the Node Scope Index>JCR.Node Scope
Index">Exclusion
+ from the Node Scope Index>JCR.Node Scope
Index</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink
+ url="Regular expressions as property name in indexing rule > Regexp
Indexing Rule">Regular
+ expressions as property name in indexing rule > Regexp Indexing
+ Rule</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="Synonim Provider">Synonim
Provider</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="Spell Checking">Spell
Checking</ulink></para>
+ </listitem>
+
+ <listitem>
+ <para><ulink url="Find Similar Nodes">Find Similar
+ Nodes</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>List of examples</title>
+
+ <xi:include href="offset-and-limit.xml"
+
xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </section>
+ </section>
+
+ <section>
+ <title>Tips and tricks</title>
+
+ <itemizedlist>
+ <listitem>
+ <para><ulink url="Xpath and numbers in node names">Xpath
and numbers
+ in node names</ulink></para>
+ </listitem>
+ </itemizedlist>
+ </section>
+</chapter>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/like-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/like-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/like-constraint.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.LIKEConstraint">
+ <title>LIKE Constraint</title>
+
+ <para>Find all nodes with mixin type 'mix:title' and where the property
+ 'jcr:title' starts with 'P'.</para>
+
+ <note>
+ <para>See also the article about "<link
linkend="JCR.NOTConstraint">Find
+ all mix:title nodes where jcr:title does NOT start with
'P'</link>"</para>
+ </note>
+
+ <section>
+ <title>Repository structure:</title>
+
+ <para>The repository contains 3 mix:title nodes, where each jcr:title has
+ a different value.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="Star wars"
+ jcr:description="Dart rules!!"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="Prison break"
+ jcr:description="Run, Forest, run ))"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Panopticum"
+ jcr:description="It's imagine film"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE jcr:title LIKE
'P%'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)[jcr:like(@jcr:title,
'P%')]";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetch result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>The NodeIterator will return "document2" and
"document3".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>The table content is <table>
+ <title>Table content</title>
+
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>jcr:description</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>Prison break</entry>
+
+ <entry>Run, Forest, run ))</entry>
+
+ <entry>/document2</entry>
+
+ <entry>4713</entry>
+ </row>
+
+ <row>
+ <entry>Panopticum</entry>
+
+ <entry>It's imagine film</entry>
+
+ <entry>/document3</entry>
+
+ <entry>5150 </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/not-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/not-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/not-constraint.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.NOTConstraint">
+ <title>NOT Constraint</title>
+
+ <para>Find all nodes with a mixin type 'mix:title' and where the
property
+ 'jcr:title' does NOT start with a 'P' symbol</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>The repository contains a mix:title nodes, where the jcr:title has
+ different values.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="Star wars"
+ jcr:description="Dart rules!!"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="Prison break"
+ jcr:description="Run, Forest, run ))"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Panopticum"
+ jcr:description="It's imagine film"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE NOT jcr:title LIKE
'P%'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)[not(jcr:like(@jcr:title,
'P%'))]";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the result</title>
+
+ <para>Let's get the nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document1".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is <table>
+ <title>Table content</title>
+
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>jcr:description</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>Star wars </entry>
+
+ <entry>Dart rules!!</entry>
+
+ <entry>/document1</entry>
+
+ <entry>4713</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/or-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/or-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/or-constraint.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.ORConstraint">
+ <title>OR Constraint</title>
+
+ <para>Find all documents whose title is 'Cinderella' or whose description
is
+ 'novel'.</para>
+
+ <para>How does it sound in jcr terms? - Find all nodes with a mixin type
+ 'mix:title' whose property 'jcr:title' equals "Cinderella" or
whose
+ "jcr:description" property value is "novel".</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>The repository contains mix:title nodes, where jcr:title and
+ jcr:description have different values.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="War and peace"
+ jcr:description="novel"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="Cinderella"
+ jcr:description="fairytale"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Puss in Boots"
+ jcr:description="fairytale"</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query Execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE jcr:title =
'Cinderella' OR jcr:description = 'novel'";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)[@jcr:title='Cinderella' or
@jcr:description = 'novel']";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document1" and
"document2".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is: <table>
+ <title>Table content</title>
+
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry> jcr:title</entry>
+
+ <entry>jcr:description</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>War and peace</entry>
+
+ <entry>novel</entry>
+
+ <entry>/document1</entry>
+
+ <entry>3806</entry>
+ </row>
+
+ <row>
+ <entry>Cinderella</entry>
+
+ <entry>fairytale</entry>
+
+ <entry>/document2</entry>
+
+ <entry>3806</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-comparison.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-comparison.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-comparison.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.PropertyComparison">
+ <title>Property Comparison</title>
+
+ <para>Find all nodes with mixin type 'mix:title' where the
prop_pagecount
+ property contains a value less than 90. Only select the title of each
+ node.</para>
+
+ <section>
+ <title>Repository structure:</title>
+
+ <para>Repository contains several mix:title nodes, where each
+ prop_pagecount contains a different value.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="War and peace"
+ prop_pagecount=1000</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="Cinderella"
+ prop_pagecount=100</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Puss in Boots"
+ prop_pagecount=60</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT jcr:title FROM mix:title WHERE prop_pagecount <
90";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement = "//element(*,mix:title)[@prop_pagecount <
90]/@jcr:title";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetch result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>The NodeIterator will return "document3".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>The table content is <table>
+ <title>Table Content</title>
+
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>jcr:path </entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>Puss in Boots</entry>
+
+ <entry>/document3</entry>
+
+ <entry>1725 </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>
Added:
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-existance-constraint.xml
===================================================================
---
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-existance-constraint.xml
(rev 0)
+++
jcr/branches/1.12.x/docs/reference/en/src/main/docbook/en-US/modules/jcr/searching/property-existance-constraint.xml 2010-08-03
14:10:08 UTC (rev 2865)
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<section id="JCR.PropertyExistenceConstraint">
+ <title>Property Existence Constraint</title>
+
+ <para>Find all nodes with a mixin type 'mix:title' where the property
+ 'jcr:description' does not exist (is null).</para>
+
+ <section>
+ <title>Repository Structure</title>
+
+ <para>The repository contains mix:title nodes, in one of these nodes the
+ jcr:description property is null.</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>root</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>document1 (mix:title) jcr:title="Star wars"
+ jcr:description="Dart rules!!"</para>
+ </listitem>
+
+ <listitem>
+ <para>document2 (mix:title) jcr:title="Prison break"
+ jcr:description="Run, Forest, run ))"</para>
+ </listitem>
+
+ <listitem>
+ <para>document3 (mix:title) jcr:title="Titanic" // The
description
+ property does not exist. This is the node we wish to find.</para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </section>
+
+ <section>
+ <title>Query Execution</title>
+
+ <para><emphasis role="bold">SQL</emphasis></para>
+
+ <programlisting>// make SQL query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String sqlStatement = "SELECT * FROM mix:title WHERE jcr:description IS NULL";
+Query query = queryManager.createQuery(sqlStatement, Query.SQL);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+
+ <para><emphasis
role="bold">XPath</emphasis></para>
+
+ <programlisting>// make XPath query
+QueryManager queryManager = workspace.getQueryManager();
+// create query
+String xpathStatement =
""//element(*,mix:title)[not(@jcr:description)]"";
+Query query = queryManager.createQuery(xpathStatement, Query.XPATH);
+// execute query and fetch result
+QueryResult result = query.execute();</programlisting>
+ </section>
+
+ <section>
+ <title>Fetching the Result</title>
+
+ <para>Let's get nodes:</para>
+
+ <programlisting>NodeIterator it = result.getNodes();
+
+if(it.hasNext())
+{
+ Node findedNode = it.nextNode();
+}</programlisting>
+
+ <para>NodeIterator will return "document3".</para>
+
+ <para>We can also get a table:</para>
+
+ <programlisting>String[] columnNames = result.getColumnNames();
+RowIterator rit = result.getRows();
+while (rit.hasNext())
+{
+ Row row = rit.nextRow();
+ // get values of the row
+ Value[] values = row.getValues();
+}</programlisting>
+
+ <para>Table content is: <table>
+ <title>Table content</title>
+
+ <tgroup cols="4">
+ <thead>
+ <row>
+ <entry>jcr:title</entry>
+
+ <entry>jcr:description</entry>
+
+ <entry>jcr:path</entry>
+
+ <entry>jcr:score</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>Titanic</entry>
+
+ <entry>null</entry>
+
+ <entry>/document3</entry>
+
+ <entry>1947</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table></para>
+ </section>
+</section>