You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Alex Parvulescu (JIRA)" <ji...@apache.org> on 2011/05/24 14:05:47 UTC

[jira] [Resolved] (JCR-2557) JQOM Multiple Constraints Fail

     [ https://issues.apache.org/jira/browse/JCR-2557?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Parvulescu resolved JCR-2557.
----------------------------------

       Resolution: Won't Fix
    Fix Version/s: 2.3.0
         Assignee: Alex Parvulescu

There are existing functions to work around this usecase. 
If upgrading is not an option or you feel that I need to look closer, please reopen 
this issue

> JQOM Multiple Constraints Fail
> ------------------------------
>
>                 Key: JCR-2557
>                 URL: https://issues.apache.org/jira/browse/JCR-2557
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: query
>    Affects Versions: 2.0.0
>            Reporter: chad davis
>            Assignee: Alex Parvulescu
>            Priority: Critical
>             Fix For: 2.3.0
>
>
> I'm unable to correctly execute the following search logic.  I have a
> folder node with documents and folders in it.  I would like to search
> the folder's contents, but I would NOT like the search to enter the
> child folders.  
> With this in mind, I'm trying to build a search query that hits
> everything in the target folder, but not in the target folders' child
> folders. This leads me to use a descendent node, for the target folder, AND'd
> with a number of NOT descedent nodes, one for each of the child folders of the 
> target folder.  
> I'll describe my query building logic, then show my code.
> 1) Build a source that is a selector of all nt:base nodes in the repo
> 2) build a fullTextSearch constraint with my query string
> 3) build a DescendantNode constraint that limits my hits to descedants
> of my target folder
> 4) build a AND constraint of these first two
> Note: this works just fine so far
> 5) build a DescendentNode constraint for the first of the children
> folders of the target folder
> 6) build a NOT constraint from the descendant constraint in step 5
> 7) build an AND constraint of this NOT and the AND from step 4
> This also works fine.  Here's  the problem area.
> 8) build a DescendantNode constraint for the second of the children
> folders of the target folder
> 9) build a NOT constraint from the desc. constraint from step 8
> 10) build an AND constraint of this NOT and the AND from step 7
> This doesn't work.  Interestingly, it seems like you just can't add
> AND's to the tree; the second child folder NOT'd and AND'd to the
> original query, doesn't work.  Maybe I'm misunderstanding how to
> achieve this.  Here's my code:
> //Select all nt:base
> Source allDocsSelector = qomFactory.selector("nt:base", "allDocs");
> //Build the fullTextSearchConstraint AND'd with the target folder
> Constraint fullTextSearchConstraint =
> buildFullTextSearchConstraint(session, queryString, qomFactory);
> Constraint targetFolderConstraint = buildRootFolderConstraint(session,
> targetFolder, qomFactory);
> And textQueryANDTargetFolderConstraint = qomFactory.and(
> fullTextSearchConstraint, targetFolderConstraint );
> //Build NOT descendant constraints to keep the search out of child folders
> //NOT descendant of "folderOne", one of the child folders of the target folder
> String path = "/BIP/1/1/folderOne/";
> Constraint descendantOfFolderOne = qomFactory.descendantNode("allDocs", path );
> Not notDescendantOfFolderOne = qomFactory.not(descendantOfFolderOne);
> And targetedFullTextANDNotFolderOne =
> qomFactory.and(textQueryANDTargetFolderConstraint,
> notDescendantOfFolderOne );
> String apath = "/BIP/1/1/folderTwo/";
> Constraint descendantOfFolderTwo = qomFactory.descendantNode("allDocs", apath );
> Not notDescendantOfFolderTwo = qomFactory.not(descendantOfFolderTwo);
> And targetedFullTextANDNotFolderOneANDNotFolderTwo =
> qomFactory.and(targetedFullTextANDNotFolderOne,
> notDescendantOfFolderTwo );
> QueryObjectModel queryObjectModel = qomFactory.createQuery(
> allDocsSelector, targetedFullTextANDNotFolderOneANDNotFolderTwo, null,
> null);
> QueryResult results = queryObjectModel.execute();

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira