Delivery Framework 4

Solr-Taglib

Solr-Taglib

Configuration

Maven dependancy

<dependency>
    <groupId>com.subshell.sophora</groupId>
    <artifactId>com.subshell.sophora.delivery.solr</artifactId>
    <version>VERSION</version>
</dependency>

Connection to the Solr-Server

To configure the connection to a Solr-Server, you can set the property sophora.delivery.solr.url, the default value for this property is http://localhost:1196/solr.

sophora.delivery.solr.url=http://localhost:1196/solr

Setting the username and password for solr server you should use this properties:

# Default: solr
sophora.delivery.solr.user=
 
# Default: solr
sophora.delivery.solr.password=

Template development

A little code snippet, to show the usage of the Solr-Taglib:

<%@ page pageEncoding="utf-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://www.subshell.com/sophora/solr/jsp" prefix="sophora-solr" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<sophora-solr:search var="result" pageNumber="0" pageSize="1" corename="MY_CORENAME" query="*:*" />
 
NEXT: ${result.hasNext}<br />
PREVIOUS: ${result.hasPrevious}<br />
NUM: ${result.numFound}<br />
START: ${result.start}<br />
SIZE: ${result.size}<br />
PAGESIZE: ${result.pageSize}<br />
PAGENUMBER: ${result.pageNumber}<br />
 
<hr />
<c:forEach var="entry" items="${result.entries}">
    ${entry.id}<hr />
</c:forEach>

Closing the Solr Client

We recommend to manually close the Solr Client on shutdown to gracefully dispose the underlying Solr Client and its threads.

SolrClient.getSolrServer("default").close();

Last modified on 10/16/20

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon