lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Help: Creating another handler and template to display document attributes
Date Thu, 02 Feb 2012 01:26:37 GMT
I'm not following exactly what you're after here in detail, but I think this will help:


See slides 24 and 25.  Note the use of $id in the /document request handler definition using
parameter substitution, a really cool technique.


On Feb 1, 2012, at 17:17 , Yuhao wrote:

> Like the title says, I want to create a "page" to display a bunch of document attributes.
 I accomplished this by creating a new handler and a template for it.  However, I'm having
trouble pulling up the details of the document in the new handler.  Here's my code.  Is this
a good way to do it?  I first pass the doc ID to the handler, which I then use to pull up
the details.  
> ********************************* BEGIN *******************************
> #set($id = $params.get("id"))
> ## Note: id is the same thing as "Entrez ID"
> #foreach ($doc in $response.results)
>   #if ($doc.getFieldValue('Entrez ID') == $id) ## Only show attrs for the current doc
>     #foreach ($field_name in $doc.getFieldNames())
>       <b>$field_name</b>: $doc.getFieldValue($field_name)<br/><br/>
>     #end
>   #end
> #end
> ********************************* END *******************************
> This approach requires the document to be in the search results.  The way I pass the
ID to the handler right now, is to simply add "id=$id" to the URL, without the rest of the
querystring that was used to conceive the current query.  I need to get the rest of the querystring
and pass them along to the handler to ensure the document is in the search result.  However,
I don't know of a good way.  I tried the following code:
> #set($querystring = "")
> #foreach ($param in $request.params.getParameterNamesIterator())
>   #set($querystring = $querystring + "&$param=$esc.url($request.params.get($param))"
> #end
> Unfortunately, the above code returns a lot of unnecessary params that are not part of
the querystring, and it fails to put the document in the search result.  Is there a better
way to get the URL querystring (and just the querystring, not other environment parameters)?

View raw message