Package org.opensextant.util
Class SolrProxy
java.lang.Object
org.opensextant.util.SolrUtil
org.opensextant.util.SolrProxy
As Xponents is a multi-core instance of Solr, a single default solr home and
default solr core does not make sense. Each wrapper around Solr (via
SolrProxy) needs to name the solr home and an explicit core name.
- Author:
- ubaldino
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Collection<org.apache.solr.common.SolrInputDocument> solrRecords) Add many solr records.void
add
(org.apache.solr.common.SolrInputDocument solrRecord) Add one solr record.void
close()
static String
deriveSolrHome
(String given) A single method to help find a suitable value for SOLR HOME If given is null, then system variables are checked.org.apache.solr.client.solrj.SolrClient
static org.apache.solr.client.solrj.SolrClient
initializeHTTP
(URL url) Get an HTTP server for Solr.boolean
Is Solr server instance allowed to write to index?void
Reopen an existing solr proxy.void
optimize()
Optimizes the Solr server.void
Save and reopen.void
InvokessaveIndex(false)
void
saveIndex
(boolean commit) Save and optionally records to server or index On failure, current accumulating request is cleared and nullified to avoid retransmitting bad data.static List<org.opensextant.data.Place>
searchGazetteer
(org.apache.solr.client.solrj.SolrClient index, org.apache.solr.common.params.SolrParams qparams) Search an OpenSextant solr gazetteer.static org.apache.solr.client.solrj.embedded.EmbeddedSolrServer
Creates an EmbeddedSolrServer given solr home & the core to use.void
setWritable
(boolean b) Methods inherited from class org.opensextant.util.SolrUtil
createPlace, getChar, getCoordinate, getCoordinate, getDate, getDouble, getFloat, getFloat, getInteger, getInteger, getLong, getString, getString, getStrings, populatePlace
-
Field Details
-
solrHome
-
coreName
-
logger
protected org.slf4j.Logger logger -
solrClient
protected org.apache.solr.client.solrj.SolrClient solrClient -
server_url
-
-
Constructor Details
-
SolrProxy
Initializes a Solr server from a URL -
SolrProxy
Initializes a Solr server from the SOLR_HOME environment variable.- Parameters:
core
- name of solr core- Throws:
org.opensextant.ConfigException
- cfg err
-
SolrProxy
Initializes a Solr server from the SOLR_HOME environment variable.- Parameters:
solr_home
- the solr_homecore
- name of solr core- Throws:
org.opensextant.ConfigException
- cfg err
-
-
Method Details
-
deriveSolrHome
A single method to help find a suitable value for SOLR HOME If given is null, then system variables are checked.- Parameters:
given
- solr home.- Throws:
org.opensextant.ConfigException
-
setWritable
public void setWritable(boolean b) -
isWritable
public boolean isWritable()Is Solr server instance allowed to write to index?- Returns:
- true if index is intended to be writable.
-
initializeHTTP
Get an HTTP server for Solr.- Parameters:
url
- server represented by URL- Returns:
- Instance of a Solr server
-
setupCore
public static org.apache.solr.client.solrj.embedded.EmbeddedSolrServer setupCore(String _solrHome, String _coreName) throws org.opensextant.ConfigException Creates an EmbeddedSolrServer given solr home & the core to use. These may be null and you get the default.- Parameters:
_solrHome
- solr home_coreName
- name of core- Returns:
- the embedded solr server
- Throws:
org.opensextant.ConfigException
- on err
-
searchGazetteer
public static List<org.opensextant.data.Place> searchGazetteer(org.apache.solr.client.solrj.SolrClient index, org.apache.solr.common.params.SolrParams qparams) throws org.apache.solr.client.solrj.SolrServerException, IOException Search an OpenSextant solr gazetteer.- Parameters:
index
- solr server handleqparams
- search parameters- Returns:
- list of places
- Throws:
org.apache.solr.client.solrj.SolrServerException
- on errIOException
-
add
Add one solr record.- Parameters:
solrRecord
- document/gazetteer or other entry to add to index- Throws:
Exception
- on err ???
-
add
Add many solr records.- Parameters:
solrRecords
- array of records to add- Throws:
Exception
- on err
-
openIndex
Reopen an existing solr proxy.- Throws:
org.opensextant.ConfigException
- the config exceptionIOException
- Signals that an I/O exception has occurred.
-
optimize
Optimizes the Solr server.- Throws:
IOException
- on errorg.apache.solr.client.solrj.SolrServerException
- the solr server exception
-
saveIndex
public void saveIndex()InvokessaveIndex(false)
-
saveIndex
public void saveIndex(boolean commit) Save and optionally records to server or index On failure, current accumulating request is cleared and nullified to avoid retransmitting bad data. In the event of a failure all records since last "saveIndex" would be lost and should be resubmitted.- Parameters:
commit
- true, if we should commit updates
-
saveAndReopen
Save and reopen.- Throws:
org.opensextant.ConfigException
- the config exceptionIOException
- on err
-
close
- Throws:
IOException
-
getInternalSolrClient
public org.apache.solr.client.solrj.SolrClient getInternalSolrClient()
-