Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For description of the query parameters, see above.

  1. Add the confman namespace and "confman" to exclude-result-prefixes.

    Code Block
    XML
    XML
    <xsl:stylesheet
    ...
        xmlns:confman="org.dspace.core.ConfigurationManager"
        exclude-result-prefixes="... confman">
    
  2. Add this simple template to process the Solr query 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>
    
  3. Add the following code to the place where you want the resulting text to appear:

    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&amp;sort=dc.date.accessioned_dt%20desc&amp;rows=1&amp;fl=dc.date.accessioned_dt&amp;omitHeader=true'))"
    mode="lastItem"/>
    

    For example, to add it after the list of Recent items in Mirage, override its template like this:

    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&amp;sort=dc.date.accessioned_dt%20desc&amp;rows=1&amp;fl=dc.date.accessioned_dt&amp;omitHeader=true'))"
    mode="lastItem"/>
    </xsl:template>

...

Warning
titleWarning

It's not officially recommended to change the defaultOperator setting. Some unrelated Discovery features might stop working if you do this. I haven't noticed anything wrong, but you might. If something breaks, make sure to notify us and we'll try to fix it or remove this tip.

Deleting Solr index data

...

titleWarning

...

If for whatever reason you need to delete the data in your index (which would normally be followed by running [dspace]/bin/dspace update-discovery-index, but you can use the -b parameter instead to reindex everything), here's how you can do it:

...


It should also be possible to use it in other versions of DSpace (starting from 1.6-1.8), but these use different versions of Solr, so modify the procedure accordingly (and expect other caveats):

DSpace 4.0Solr 4.4.0 (expected)
DSpace 3.0Solr 3.5.0
DSpace 1.8Solr 3.3.0
DSpace 1.7Solr 1.4.1
DSpace 1.6Solr 1.3.0

...