Versions Compared

Key

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

...

DSpace uses Solr as a part of Discovery as index to speed up access to content metadata and data about access to DSpace (for statistics). It also provides faceting and search results filtering. If Discovery is enabled, the DSpace search field accepts Solr search syntax.
Discovery is an optional part of DSpace since 1.7 (with big improvements and configuration format changes in 1.8). When enabled, Discovery replaces DSpace Search and Browse and provides Solr-based statistics.

Info
titleDo I need to read this page?

To gain the benefits of faceting and filtering in XMLUI, all you need to do is enable Discovery. The rest of these page describes some advanced uses of Solr - if you want to query Solr directly for theme customization or read DSpace metadata from outside DSpace.

Connecting to Solr

Wiki Markup
By default, the DSpace Solr server is configured to listen only on localhost port 8080 (unless you specified another port in Tomcat configuration and the {{\[dspace\]/config/modules/discovery.cfg}} config file). That means that you cannot connect from another machine to the dspace server port 8080 and request a Solr URL - you'll get a HTTP 403 error. This configuration was done for security considerations - Solr index contains some data that is not accessible via public DSpace interfaces and some of the data might be sensitive.

While you could make Solr publicly accessible by changing this default configuration (if you want to do so, search for LocalHostRestrictionFilter), this is not recommended. Instead, use one of following simple means to bypass this restriction temporarily. All of them will make Solr accessible only to the machine you're connecting from for as long as the connection is open.

...

The two Solr instances in DSpace Discovery are called "search" and "statistics". search contains data about communities, collections, items and bitstreams. statistics contains data about searches, accessing users, IPs etc. The two instances are accessible at following URLs (relative to the dspace server):

...

Using the knowledge of particular fields from Solr Admin and Solr syntax (SolrQuerySyntax, CommonQueryParameters) you can make your own search requests.
You can also look at the Tomcat log file to see queries generated by XMLUI in real time

Code Block
tail -f /var/log/tomcat6/catalina.out

(depending on your OS, Tomcat installation method and logging settings, the path may be different)

Solr responses

Wiki Markup
By default, Solr responses are returned in XML format. However, Solr can provide several other output formats including JSON and CSV. Discovery uses the javabin format. The Solr request parameter is wt (e.g. &wt=json). For more information, see [Response Writers|http://lucidworks.lucidimagination.com/display/solr/Response+Writers], [QueryResponseWriters|http://wiki.apache.org/solr/QueryResponseWriters].


An interesting option is to specify an XSLT stylesheet that can transform the XML response (server-side) to any format you choose, typically HTML. Append &wt=xslt&tr=example.xsl to the Solr request URL. The .xsl files must be provided in the {{\[dspace\]/solr/search/conf/xslt/
directory. Append &wt=xslt&tr=example.xsl to the Solr request URL.
For more information, see XsltResponseWriter
}} directory. 
For more information, see [XsltResponseWriter|http://wiki.apache.org/solr/XsltResponseWriter].

Examples

Date of last deposited item

To get all items (search.resourcetype:2) sorted by date accessioned (dc.date.accessioned_dt) in order from newest to oldest (desc; %20 is just an url-encoded space character):

Code Block
http://localhost:8080/solr/search/select?q=search.resourcetype:2&sort=dc.date.accessioned_dt%20desc

...

Other pages on this wiki describing Solr and Discovery.

...