Query Language Specification
Last modified by Vincent Massol on 2024/11/19 16:12
Description
Query Language Specification
XWQL is JPQL superset. See JPQL specification.
XWiki-specific extensions in XWQL:
- short form queries:
- "where " means "select doc.fullName where "
- "from [where ]" means "select doc.fullName from Document as doc, [where ]"
- special syntax for XWiki objects in "from" and "where" clauses:
- "from doc.object(Class) as obj"
- "where doc.object(Class).prop = 'something'"
Query | XWQL (chosen method) | HQL (Current method) | XPath (Current QueryPlugin method, with unimplemented child axis support) | Method 1 | Method 2 | Method 3 | Method 4 |
Query listing all documents | empty query | empty query | /*/* | empty query | empty query | empty query | empty query |
Query listing all documents create after a date | where doc.creationDate > '2008-01-01' | where [doc.]creationDate > '2008-01-01' | /*/*[@creationDate > '2008-01-01'] | where [doc.]creationDate > '2008-01-01' | where [doc.]creationDate > '2008-01-01' | where [doc.]creationDate > '2008-01-01' | where [doc.]creationDate > '2008-01-01' |
Query listing all documents last updated by a user | where doc.author = 'XWiki.LudovicDubost' | where [doc.]author = 'XWiki.LudovicDubost' | /*/*[@author = 'XWiki.LudovicDubost'] | where [doc.]author = 'XWiki.LudovicDubost' | where [doc.]author = 'XWiki.LudovicDubost' | where [doc.]author = 'XWiki.LudovicDubost' | where [doc.]author = 'XWiki.LudovicDubost' |
Query listing all documents with a class | from doc.object(XWiki.XWikiUsers) as user | , BaseObject as obj where doc.fullName = obj.name and obj.className = 'XWiki.XWikiUsers' | /*/*[obj/XWiki/XWikiUsers] | from XWiki.XWikiUsers | where [doc.]XWiki.XWikiUsers | where [doc.]class = 'XWiki.XWikiUsers' | , XWiki.XWikiUsers as user where [doc.]id = user.docId |
Query on document with a class with a filter | where doc.author = 'XWiki.LudovicDubost' and doc.object(XWiki.XWikiUsers).email like '%xwiki.com' | , BaseObject as obj, StringProperty as prop where doc.fullName = obj.name and obj.className = 'XWiki.XWikiUsers' and obj.id=prop.id.id and prop.id.name='email' and prop.value like '%xwiki.com' and [doc.]author ='XWiki.LudovicDubost' | /*/*[@author='XWiki.LudovicDubost' and obj/XWiki/XWikiUsers/@xp:email like '%xwiki.com'] | from XWiki.XWikiUsers as user where user.email like '%xwiki.com' and [doc.]author='XWiki.LudovicDubost' | where [[doc.]XWiki.XWikiUsers and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]author = 'XWiki.LudovicDubost' | where [[doc.]class = 'XWiki.XWikiUsers' and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]author = 'XWiki.LudovicDubost' | , XWiki.XWikiUsers as user where [doc.]id = user.docId and user.email like '%.xwiki.com' and [doc.]author = 'XWiki.LudovicDubost' |
Query with 2 classes | where doc.object(XWiki.XWikiUsers).email like '%xwiki.com' and doc.object(XWiki.ArticleClass).content like '%ludovic%' | , BaseObject as obj, StringProperty as prop, BaseObject as obj2, LargeStringProperty as contentprop where doc.fullName = obj.name and obj.className = 'XWiki.XWikiUsers' and obj.id=prop.id.id and prop.id.name='email' and prop.value like '%xwiki.com' and doc.fullName=obj2.name and obj2.className='XWiki.ArticleClass' and obj2.id=contentprop.id.id and contentprop.id.name='content' and contentprop.value like '%ludovic%' | /*/*[obj/XWiki/XWikiUsers/@xp:email like '%xwiki.com' and obj/XWiki/ArticleClass/@xp:content like '%ludovic%'] | from XWiki.XWikiUsers as user, XWiki.ArticleClass as article where user.email like '%xwiki.com' and article.content like '%ludovic%' | where [[doc.]XWiki.XWikiUsers and] [[doc.]XWiki.ArticleClass and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]XWiki.ArticleClass like '%ludovic%' | where [[doc.]class = 'XWiki.XWikiUsers' and] [[doc.]class = 'XWiki.ArticleClass' and] [doc.]XWiki.XWikiUsers.email like '%xwiki.com' and [doc.]XWiki.ArticleClass like '%ludovic%' | ,XWiki.XWikiUsers as user, XWiki.ArticleClass as article where [doc.]id = user.docId and [doc.]id=article.docId and user.email like '%.xwiki.com' and article.content like '%ludovic%' |
Query | XWQL | HQL |
Search blogs per category | where doc.fullName <> 'XWiki.ArticleClassTemplate' and :category member of doc.object(XWiki.ArticleClass).category | , BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.name=doc.fullName and obj.className='XWiki.ArticleClass' and obj.name<>'XWiki.ArticleClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='local' order by doc.creationDate desc |
List all tags | select distinct obj.tags from Document doc, doc.object(XWiki.TagClass) as obj | select distinct tag from BaseObject as obj, DBStringListProperty as prop join prop.list as tag where obj.className='XWiki.TagClass' and obj.id=prop.id.id and prop.id.name='tags' |