[ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12575337#action_12575337 ]
Bertrand Delacretaz commented on SLING-307: ------------------------------------------- Patch applied in revision 633842 with the following changes: -Servlet renamed to JsonQueryServlet -content-type was not set -the "rows" parameter was off by one, rows=3 would return 4 rows Also added a simple integration test, in launchpad/webapp, JsonQueryServletTest Thanks for your contribution! Leaving this issue open, as we might want to simplify the querying code by taking advantage of ResourceResolver.findResources() > QueryServlet > ------------ > > Key: SLING-307 > URL: https://issues.apache.org/jira/browse/SLING-307 > Project: Sling > Issue Type: New Feature > Components: Default Servlets > Reporter: Philipp Koch > Assignee: Bertrand Delacretaz > Attachments: queryservlet.patch > > > it would be nice to have a way to specify a jcr query in the url in order to > query the underlying jcr repository. > the attached patch works as follows: > The new query servlet is called if the extension is ".json" and the selector > is set to "query". you can pass following parameters in the url: > statement: jcr query statement (XPATH or SQL) > queryType: xpath or sql (of none is specified xpath is taken) > property: specifies which property (relative path) has to be "put" into the > result set (this parameter can be added multiple times) > excerptPath: specifies the relative node path from where the excerpt has to > be built. > the result is returned as json string. e.g.: > [ > {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage > ... > ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"}, > {"name":"news","rep:excerpt()":"<excerpt><fragment> ... > geometrixx/components/contentpage ... ... ... ... news about > geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"} > ] > example query call: > http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.