On Dec 5, 2007 2:55 PM, Christophe Lombart <[EMAIL PROTECTED]> wrote:

> ...I'm wondering what is the best way to search resources with Sling (mainly
> with MicroSling in the first time)....

> ...Do I have to make a specific servlet and map it to a resource called
> "/search" (which is not in the repo of course) ?...

The easiest way is probably to create this /search node, and set its
sling:resourceType to point to a specific script (or servlet).

Then, in the script, use
node.getSession().getWorkspace().getQueryManager() to create your
query, run it (based on request parameters) and get a NodeIterator.

While iterating over the results, you can use sling.include(path) to
use the (micro)sling request processing to render the nodes, or just
render them "locally" in the iteration if that's convenient.

Creating a /list/contributedBy node and requesting
/list/contributedBy/someone should also work in a similar way to
search for contributedBy="someone", by mapping /list/contributedBy to
a search script which gets the "someone" suffix from the
RequestPathInfo. That's an interesting use-case for the recent "go up
the path or not for GET requests" discussions, but I'm not sure if
that currently works.

-Bertrand

Reply via email to