lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject Re: solr + cocoon problem
Date Tue, 16 Jan 2007 23:30:56 GMT
On Tue, 2007-01-16 at 16:19 -0500, Walter Lewis wrote:
> wrote:
> > Any ideas on how to implement a cocoon layer above solr?

I just finished a forrest plugin (in the whiteboard, our testing ground
in forrest) that is doing what you asked for and some pagination.
Forrest is cocoon based so you just have to build the plugin jar and add
it to your cocoon project. Please ask on the forrest list if you have

> You're far from the only one approaching solr via cocoon ... :)
> The approach we took, passes the search parameters to a "solrsearch" 
> stylesheet, the heart of which is a <cinclude> block that embeds the 
> solr results.  A further transformation prepares the results of the solr 
> query for display.

That was my first version for above plugin as well, but since forrest
makes use of the cocoon crawler I needed something with a default search
string for offline generation.

You should have a closer look on

For the original use case of this thread I added a generator:

<map:generator name="solr-search"
        src="org.apache.forrest.solr.client.SolrSearchGenerator" />

and as well a paginator transformer that calculates the next pages based on start, rows and

 <map:transformer logger="sitemap.transformer.solr" name="solr" pool-max="16" 
        src="org.apache.forrest.solr.client.SolrQueryTransformer" />

We use it as follows:

<!-- Will dispatch a query against the solr server -->
      <map:match pattern="solr-search.xml">
        <map:generate type="solr-search">
<!-- You would replace this with your own. In forrest we have a property system for that
<property name="" value="http://localhost:8983/solr/select"/>
          <map:parameter name="destinationUrl" value="{}"/>
<!-- here we add the pagination to the sax from the generator will result in something
<result name="response" numFound="17" start="0">
 <paginator found="17" start="0" rows="10" pages="2">
  <page id="1" queryString="q=forrest&amp;hl=true&amp;rows=10&amp;version=2.2&amp;indent=on&amp;hl.fl=content&amp;fl=id,title&amp;Search=Search&amp;start=0"
  <page id="2" queryString="q=forrest&amp;hl=true&amp;rows=10&amp;version=2.2&amp;indent=on&amp;hl.fl=content&amp;fl=id,title&amp;Search=Search&amp;start=10"/>
        <map:transform type="solr"/>
<!-- here we transform the solr response into xdocs (forrest internal format)
the pagination:
<xsl:template match="paginator">
      <title>Result pages</title>
        <xsl:for-each select="page">
          <xsl:variable name="current" select="@current"/>
            <xsl:when test="$current='true'">
              <xsl:text> </xsl:text><xsl:value-of select="@id"/><xsl:text>
              <a href="{concat($searchForm,'?',@queryString)}">
                <xsl:value-of select="@id"/>
        <map:transform src="resources/stylesheets/solrQueryResult-to-xdocs.xsl">
          <map:parameter name="searchForm" value="{request:servletPath}"/>
        <map:serialize type="xml"/>

You may be interested in the update generator as well. 

Please give feedback to 

It really needs more testing besides myself, you could be the first to provide feedback.

<map:generator name="solrUpdate"

<!-- Update generator will send the command to the solr server and
        generate the server response -->
      <map:match pattern="**.do">
        <map:generate type="solrUpdate" src="cocoon:/{1}">
          <map:parameter name="destinationUrl" value="{properties:solr.update.url}"/>
        <map:serialize type="xml"/>



"Together we stand, divided we fall!" 
Hey you (Pink Floyd)

View raw message