Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. **SQL2**
  2.  
  3. All nodes with a specific name
  4. ```sql
  5. SELECT * FROM [nt:unstructured] AS node
  6. WHERE ISDESCENDANTNODE(node, "/search/in/path")
  7. AND NAME() = "nodeName"
  8. ```
  9.  
  10. All pages below content path
  11. ```sql
  12. SELECT * FROM [cq:Page] AS page
  13. WHERE ISDESCENDANTNODE(page ,"/search/in/path")
  14. ```
  15.  
  16. All components of a specific type
  17. ```sql
  18. SELECT * FROM [nt:unstructured] AS comp
  19. WHERE ISDESCENDANTNODE(comp, "/search/in/path")
  20. AND [sling:resourceType] = "componentType"
  21. ```
  22.  
  23. All nodes where a property contains some String
  24. ```sql
  25. SELECT * FROM [nt:unstructured] AS node
  26. WHERE ISDESCENDANTNODE(node, "/search/in/path")
  27. AND CONTAINS([propertyName], "someString")
  28. ```
  29.  
  30. Date property of child node is greater than
  31. ```sql
  32. SELECT page.* FROM [cq:Page] AS page
  33. INNER JOIN [nt:base] AS jcrcontent ON ISCHILDNODE(jcrcontent, page)
  34. WHERE ISDESCENDANTNODE(page, "/content/path/to/page")
  35. AND jcrcontent.[cq:lastModified] >= CAST("2015-06-02T00:00:00.000Z" AS DATE)
  36. ```
  37.  
  38. Every page with specific name
  39. ```sql
  40. SELECT * FROM [cq:Page] AS page
  41. WHERE ISDESCENDANTNODE(page, "/search/in/path")
  42. AND name() = "pageName"
  43. ```
  44.  
  45. **XPATH**
  46.  
  47. Property not empty
  48. ```
  49. /jcr:root/content/path/to/page//nodeName[@propertyName != ""]
  50. ```
  51.  
  52. Specific property contains
  53. ```
  54. /jcr:root/content/path/to/page//nodeName[jcr:contains(@propertyName,'someValue')]
  55. ```
  56.  
  57. Any property contains
  58. ```
  59. /jcr:root/content/path/to/page//*[jcr:contains(., 'someValue')]
  60. ```
  61.  
  62. AND operation (for more than one property)
  63. ```
  64. /jcr:root/content/path/to/page//*[@firstPropertyName = "someValue", @secondPropertyName != "anotherValue"]
  65. ```
  66.  
  67. Get all jcr:content nodes that
  68. * have a specific resourceType
  69. * have any property that contains a specific (text-) value
  70. * have a "grandchild" node, which has a specific resourceType
  71. * have a "grandchild" node, which has a property called "date" greater than "2012-06-01" and less than "2016-07-01"
  72. and order the result by the date property in descending order.
  73. ```
  74. /jcr:root/content/path/to/node//element(*,cq:PageContent)[@sling:resourceType="someType" and jcr:contains(., "someValue") and */*/@sling:resourceType="anotherType" and */*/@date >= xs:dateTime("2012-06-01T00:00:00.000+02:00") and */*/@date <= xs:dateTime("2016-07-01T00:00:00.000+02:00")] order by pathto/grandchild/@date descending
  75. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement