2017-07-25 61 views
0

我需要創建一個查詢,其中PARAMS是這樣的:AEM查詢生成器排除在搜索文件夾

queryParams.put("path", "/content/myFolder"); 
queryParams.put("1_property", "myProperty"); 
queryParams.put("1_property.operation", "exists"); 
queryParams.put("p.limit", "-1"); 

但是,我需要排除這種毯子文件夾內的某個路徑,說:"/content/myFolder/wrongFolder"和搜索所有其他文件夾(其編號不斷變化)

有沒有辦法做到這一點?我沒有發現它完全在線。

我也試過unequals操作,因爲父路徑正在保存在JCR屬性中,但仍然沒有運氣。我實際上需要unlike以避免所有路徑出現。但是,有沒有這樣的事情:

path=/main/path/to/search/in 
group.1_property=cq:parentPath 
group.1_property.operation=unequals 
group.1_property.value=/path/to/be/avoided 
group.2_property=myProperty 
group.2_property.operation=exists 
group.p.or=true 
p.limit=-1 
+0

如果SQL2查詢會爲你,那麼你可以爲執行工作這個查詢:select * from [nt:unstructured] as p where (isdescendantnode(p,[/ content/myFolder /]) AND NOT isdescendantnode(p,[/ content/myFolder/wrongFolder /])) (p。*,'myProperty')讓我知道這是否有效。 –

+0

@SumantaPakira,我現在不能使用SQL2,因爲它需要對應用程序進行重大更改。因此,現在只能在查詢構建器中查找解決方案。 –

回答

0

使用QueryBuilder的,你可以執行:

map.put("group.p.not",true) 
map.put("group.1_path","/first/path/where/you/donot/want/to/search") 
map.put("group.2_path","/second/path/where/you/donot/want/to/search") 

而且我已經檢查PredicateGroup的類的API,他們提供了一個setNegated方法。我從來沒有用它自己,但我認爲你可以否定一個組,並將其合併成你喜歡搜索上的路徑共同斷言:

final PredicateGroup doNotSearchGroup = new PredicateGroup(); 
doNotSearchGroup.setNegated(true); 
doNotSearchGroup.add(new Predicate("path").set("path", "/path/where/you/donot/want/to/search")); 

final PredicateGroup combinedPredicate = new PredicateGroup(); 
combinedPredicate.add(new Predicate("path").set("path", "/path/where/you/want/to/search")); 
combinedPredicate.add(doNotSearchGroup); 

final Query query = queryBuilder.createQuery(combinedPredicate); 
+0

group.p.not沒有爲我工作。我嘗試了下面,並得到比以前更多的結果: path =/main/path/where/I/want/to/search group.p.not = true group.1_path =/first/path/where/you/donot/want/to/search group.2_property = myProperty group.2_property.operation = exists group.p.or = true p.limit = -1 –

相關問題