jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (JCR-2557) JQOM Multiple Constraints Fail
Date Tue, 24 May 2011 15:53:48 GMT

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

Jukka Zitting updated JCR-2557:
-------------------------------

    Fix Version/s:     (was: 2.3.0)

> 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
>
> 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

Mime
View raw message