...
- OpenSSH client - port forwarding
connect to DSpace server and forward its port 8080 to localhost (machine we're connecting from) port 1234
makes mydspace.edu:8080 accessible via localhost:1234 (type http://localhost:1234Code Block ssh -L 1234:127.0.0.1:8080 mydspace.edu
in browser address bar)
ssh -L 1234:127.0.0.1:8080 mydspace.edu; also opens ssh shellCode Block
exit ssh to terminate port forwarding
Alternatively:
run with -N and -f flags if you want ssh to go to background;Code Block ssh -N -f -L 1234:127.0.0.1:8080 mydspace.edu
kill the ssh process to terminate port forwarding - Putty client - port forwarding
The same with Putty:Code Block Connection - SSH - Tunnels Source port: 8080 Destination: localhost:1234 Local Auto Add
- OpenSSH client - SOCKS proxy
connect to DSpace server and run a SOCKS proxy server on localhost port 1234; configure browser to use localhost:1234 as SOCKS proxy and remove "localhost" and "127.0.0.1" from addresses that bypass this proxy
all browser requests now originate from dspace server (source IP is dspace server's IP) - dspace is the proxy server
type http://localhost:8080in browser address bar - localhost here is the dspace server
Code Block ssh -D 1234 mydspace.edu
Note about Putty as SOCKS proxy - while it can be configured, it raises a security exception when Solr is accessed. If you figure this out, please add this method here.
Accessing Solr
Solr cores
DSpace contains a so-called multicore installation of Solr. That means that there are multiple Solr indexes and configurations sharing one Solr codebase. If you're familiar with Apache HTTPD, it is analogous to multiple virtual hosts running on one Apache server (separate configuration and webpages), except that individual Solr cores are accessible via different URL (as opposed to virtualhost IP:port).
...
Note:
facet.field=epersonid — You want to group by epersonid, which is the user id.
type:0 — Interested in bitstreams only
Querying Solr from XMLUI
Since Solr returns its responses in XML, it's possible and easy to call custom Solr queries from XMLUI, process the XML response with XSLT and display the results in human-readable form on the HTML page.
There are two ways how to do that - synchronously in Cocoon or asynchronously using AJAX (JavaScript) after the page is loaded. Solr queries are usually very fast, so only synchronous calls will be shown here.
You can include another XML document to be processed by XSLT using the document() function. The parameter to this function is an XML document to process. This can be either a static .xml file stored on the server or a URL, which will be fetched at time of processing. For Solr, the latter is what we need. Furthermore, we need to distinguish templates for processing this external XML document as opposed to the input XML document. We'll do this using the mode
attribute.
Code Block | ||||
---|---|---|---|---|
| ||||
<xsl:apply-templates select="document('http://localhost:8080/select?q=search.resourcetype:2&sort=dc.date.accessioned_dt%20desc&rows=1&fl=dc.date.accessioned_dt&omitHeader=true'))"
mode="solr-response"/>
|
Now we need to define a template with the same mode that matches elements contained in the Solr response XML:
Code Block | ||||
---|---|---|---|---|
| ||||
<xsl:template match="/response/result/doc/date" mode="solr-response">
Last item was imported: <xsl:value-of select="text()"/>
</xsl:template>
|
Furthermore, we don't want to hardcode the http://localhost:8080
Solr URL, because this can be changed in config file and it would break the template. So we'll call a Java function from XSLT to retrieve the configured Solr URL. See the complete example in the next section.
Examples
Date of last deposited item
For description of the query parameters, see above.
- Add confman namespace and "confman" to exclude-result-prefixes.
Code Block XML XML <xsl:stylesheet ... xmlns:confman="org.dspace.core.ConfigurationManager" exclude-result-prefixes="... confman">
- Add this simple template to process Solr result. More complex date formatting can be done easily in XSLT 2.0 (see XSLT 2.0 spec), however Cocoon still uses XSLT 1.0 (see DS-995). It is currently also possible to call Java functions to do date formatting.
Code Block XML XML <xsl:template match="/response/result/doc/date" mode="lastItem"> Last item was imported: <xsl:value-of select="substring(text(), 1, 10)"/> </xsl:template>
- Add the following code to the place where you want the resulting text to appear:
For example, to add it after the list of Recent items in Mirage, override its template like this:Code Block XML XML <xsl:variable name="solr-search-url" select="confman:getProperty('discovery', 'search.server')"/> <xsl:apply-templates select="document(concat($solr-search-url, '/select?q=search.resourcetype:2&sort=dc.date.accessioned_dt%20desc&rows=1&fl=dc.date.accessioned_dt&omitHeader=true'))" mode="lastItem"/>
Code Block XML XML <xsl:template match="dri:referenceSet[@type = 'summaryList' and @n='site-last-submitted']" priority="2"> <xsl:apply-templates select="dri:head"/> <!-- Here we decide whether we have a hierarchical list or a flat one --> <xsl:choose> <xsl:when test="descendant-or-self::dri:referenceSet/@rend='hierarchy' or ancestor::dri:referenceSet/@rend='hierarchy'"> <ul> <xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/> </ul> </xsl:when> <xsl:otherwise> <ul class="ds-artifact-list"> <xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/> </ul> </xsl:otherwise> </xsl:choose> <xsl:variable name="solr-search-url" select="confman:getProperty('discovery', 'search.server')"/> <xsl:apply-templates select="document(concat($solr-search-url, '/select?q=search.resourcetype:2&sort=dc.date.accessioned_dt%20desc&rows=1&fl=dc.date.accessioned_dt&omitHeader=true'))" mode="lastItem"/> </xsl:template>
Guidepost
Other pages on this wiki describing Solr and Discovery.
...