如何使用Lucene Query查询Alfresco特定节点下的空文件夹?
Got it, let's get that query working for you! The problem with your original attempt is that Alfresco's Lucene implementation doesn't recognize the "Children is empty" syntax—we need to use the built-in metadata properties that Alfresco tracks for nodes.
Correct Lucene Query
Here's the adjusted query that will return all empty folders under your target path:
+PATH:"/app:company_home/cm:contexts/cm:ctx_exploitation/cm:runs/cm:Run_322645//." +@cm\:isFolder:true +@cm\:childCount:0
Breakdown of Each Part
+PATH:"/app:company_home/cm:contexts/cm:ctx_exploitation/cm:runs/cm:Run_322645//.": This part stays as you had it—it targets all nodes under the specified path (the//.ensures we include all sub-levels underRun_322645).+@cm\:isFolder:true: This filters results to only include folders (excludes files we don't care about here). The\escapes the colon since it's a special character in Lucene.+@cm\:childCount:0: Alfresco automatically maintains acm:childCountproperty for every node, which counts direct child nodes. Setting this to0ensures we only get folders with no children.
Why Your Original Query Failed
Alfresco doesn't support natural language-style checks like "Children is empty" in Lucene queries. You have to leverage pre-populated metadata properties provided by Alfresco—cm:childCount is the right tool for this job.
If you prefer an alternative way to write the empty check, you could also use:
+NOT @cm\:childCount:[1 TO *]
This does the same thing (excludes any folder with 1 or more children), but @cm\:childCount:0 is more straightforward.
内容的提问来源于stack exchange,提问作者CHHIBI AMOR

