Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 284 invoked from network); 30 Nov 2010 16:56:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Nov 2010 16:56:25 -0000 Received: (qmail 66662 invoked by uid 500); 30 Nov 2010 16:56:24 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 66614 invoked by uid 500); 30 Nov 2010 16:56:24 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 66605 invoked by uid 99); 30 Nov 2010 16:56:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 16:56:23 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jzitting@adobe.com designates 64.18.1.181 as permitted sender) Received: from [64.18.1.181] (HELO exprod6og101.obsmtp.com) (64.18.1.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 16:56:16 +0000 Received: from source ([192.150.8.22]) by exprod6ob101.postini.com ([64.18.5.12]) with SMTP ID DSNKTPUsmm8bQwTyG3eAMT8uUN3HpM8y5PiH@postini.com; Tue, 30 Nov 2010 08:55:56 PST Received: from inner-relay-1.corp.adobe.com (inner-relay-1.corp.adobe.com [153.32.1.51]) by outbound-smtp-2.corp.adobe.com (8.12.10/8.12.10) with ESMTP id oAUGtqVV015873 for ; Tue, 30 Nov 2010 08:55:53 -0800 (PST) Received: from nacas01.corp.adobe.com (nacas01.corp.adobe.com [10.8.189.99]) by inner-relay-1.corp.adobe.com (8.12.10/8.12.10) with ESMTP id oAUGtqtm011712 for ; Tue, 30 Nov 2010 08:55:52 -0800 (PST) Received: from excas02.corp.adobe.com (10.8.188.212) by nacas01.corp.adobe.com (10.8.189.99) with Microsoft SMTP Server (TLS) id 8.2.254.0; Tue, 30 Nov 2010 08:55:52 -0800 Received: from eurhub01.eur.adobe.com (10.128.4.30) by excas02.corp.adobe.com (10.8.188.212) with Microsoft SMTP Server (TLS) id 8.2.254.0; Tue, 30 Nov 2010 08:55:51 -0800 Received: from jzitting.dev.day.com (10.131.197.63) by eurhub01.eur.adobe.com (10.128.4.111) with Microsoft SMTP Server id 8.2.254.0; Tue, 30 Nov 2010 16:55:49 +0000 Message-ID: <4CF52C92.6010907@adobe.com> Date: Tue, 30 Nov 2010 17:55:46 +0100 From: Jukka Zitting Organization: Adobe User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc11 Lightning/1.0b2pre Thunderbird/3.0.4 MIME-Version: 1.0 To: "users@jackrabbit.apache.org" Subject: Re: XPATH to JCR-SQL2 Query translation References: In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Hi, On 26/11/10 16:36, Juan Diego Botiva Leon wrote: > I'm upgrading Jackrabbit from 1.6.1 to 2.1.1 and I need to translate > an XPath query to JCR-SQL2, the query is as follows: > > /jcr:root/some_node//element(*, > mynt:document)[jcr:contains(jcr:content, 'textToFind')] > > I tried the following (removing the path constraint because I > couldn't find how to do it) > > SELECT * FROM [mynt:document] AS doc WHERE CONTAINS(doc.*, > 'textToFind') > > But I get no results and the original query returns 23 nodes. Can you > help me with this as I checked the JCR 2.0 SQL-2 Grammar (Railroad > diagrams) and the jackrabbit-spi-commons test cases but still I'm not > sure how to use CONTAINS and how to restrict the query to a specific > path. Thanks in advance. You can use the ISDESCENDANTNODE constraint [1] in SQL2 to limit your query to a specific subtree. Note that this constraint is slightly different from the descendant-or-self axis ("//") in XPath, as it doesn't match the ancestor node under which you're querying. To duplicate the descendant-or-self axis functionality in SQL2 you can combine ISDESCENDANTNODE and ISSAMENODE [2] constraints like this: SELECT * FROM [mynt:document] WHERE ISDESCENDANTNODE('/some_node') OR ISSAMENODE('/some_node') Can you please try the SQL2 query with the latest Jackrabbit snapshot to see if you're still having problem getting the same results as with the XPath query? Full text queries with SQL2 should work much better now with the JCR-2715 improvements. [1] http://www.day.com/specs/jcr/2.0/6_Query.html#DescendantNode [2] http://www.day.com/specs/jcr/2.0/6_Query.html#SameNode BR, Jukka Zitting