Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8B3C310D32 for ; Sat, 31 Aug 2013 09:21:47 +0000 (UTC) Received: (qmail 22971 invoked by uid 500); 31 Aug 2013 09:21:46 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 22925 invoked by uid 500); 31 Aug 2013 09:21:40 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 22917 invoked by uid 99); 31 Aug 2013 09:21:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Aug 2013 09:21:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Aug 2013 09:21:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6DB132388AB8; Sat, 31 Aug 2013 09:21:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1519163 - in /jackrabbit/oak/trunk/oak-lucene/src: main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java Date: Sat, 31 Aug 2013 09:21:15 -0000 To: oak-commits@jackrabbit.apache.org From: alexparvulescu@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130831092115.6DB132388AB8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: alexparvulescu Date: Sat Aug 31 09:21:14 2013 New Revision: 1519163 URL: http://svn.apache.org/r1519163 Log: OAK-985 The query engine doesn't properly extract the node type information from queries with conditions on jcr:primaryType - workaround for the lucene index Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1519163&r1=1519162&r2=1519163&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java Sat Aug 31 09:21:14 2013 @@ -47,6 +47,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; +import org.apache.jackrabbit.JcrConstants; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.index.aggregate.NodeAggregator; @@ -470,6 +471,10 @@ public class LuceneIndex implements Full if ("rep:excerpt".equals(name)) { continue; } + // TODO OAK-985 + if (JcrConstants.JCR_PRIMARYTYPE.equals(name)) { + continue; + } String first = null; String last = null; Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java?rev=1519163&r1=1519162&r2=1519163&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexAggregationTest.java Sat Aug 31 09:21:14 2013 @@ -228,4 +228,31 @@ public class LuceneIndexAggregationTest assertQuery(matchOnlyTitleOr, "xpath", ImmutableList.of("/myFolder")); } + @Test + public void testNodeTypes() throws Exception { + + Tree folder = root.getTree("/").addChild("myFolder"); + folder.setProperty(JCR_PRIMARYTYPE, NT_FOLDER, Type.NAME); + Tree file = folder.addChild("myFile"); + file.setProperty(JCR_PRIMARYTYPE, NT_FILE, Type.NAME); + file.setProperty("jcr:title", "title"); + file.setProperty("jcr:description", "description"); + + Tree resource = file.addChild(JCR_CONTENT); + resource.setProperty(JCR_PRIMARYTYPE, "nt:resource", Type.NAME); + resource.setProperty("jcr:lastModified", Calendar.getInstance()); + resource.setProperty("jcr:encoding", "UTF-8"); + resource.setProperty("jcr:mimeType", "text/plain"); + resource.setProperty(binaryProperty(JCR_DATA, + "the quick brown fox jumps over the lazy dog.")); + + root.commit(); + + String matchContentSimple = "//*[(jcr:contains(., 'dog')) and @jcr:primaryType = 'nt:file']"; + assertQuery(matchContentSimple, "xpath", ImmutableList.of("/myFolder/myFile")); + + String matchContentDouble = "//*[(jcr:contains(., 'dog')) and (@jcr:primaryType = 'nt:file' or @jcr:primaryType = 'nt:folder')]"; + assertQuery(matchContentDouble, "xpath", ImmutableList.of("/myFolder", "/myFolder/myFile")); + } + }