public class ConcurrentUpdateSolrConnector extends java.lang.Object implements SolrConnector
Modifier and Type | Class and Description |
---|---|
private class |
ConcurrentUpdateSolrConnector.CommitHandler |
SolrConnector.LoadTimeURL
Modifier and Type | Field and Description |
---|---|
private static long |
AUTOCOMMIT |
private boolean |
commitProcessRunning |
private SolrConnector |
connector |
private java.util.LinkedHashMap<java.lang.String,SolrInputDocument> |
docBuffer |
private ARC<java.lang.String,SolrConnector.LoadTimeURL> |
metadataCache |
private ConcurrentUpdateSolrConnector.CommitHandler |
processHandler |
private int |
updateCapacity |
Constructor and Description |
---|
ConcurrentUpdateSolrConnector(SolrConnector connector,
int updateCapacity,
int idCacheCapacity,
int concurrency) |
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Collection<SolrInputDocument> solrdocs)
add a solr input document
|
void |
add(SolrInputDocument solrdoc)
add a solr input document
|
int |
bufferSize()
get the size of a write buffer (if any) of pending write requests
|
void |
clear()
delete everything in the solr index
|
void |
clearCaches()
clear all caches: inside solr and ouside solr within the implementations of this interface
|
void |
close()
close the server connection
|
void |
commit(boolean softCommit)
force a commit
|
private void |
commitDocBuffer() |
java.util.concurrent.BlockingQueue<SolrDocument> |
concurrentDocumentsByQueries(java.util.List<java.lang.String> querystrings,
java.lang.String sort,
int offset,
int maxcount,
long maxtime,
int buffersize,
int concurrency,
boolean prefetchIDs,
java.lang.String... fields)
Get results from solr queries as a stream of documents.
|
java.util.concurrent.BlockingQueue<SolrDocument> |
concurrentDocumentsByQuery(java.lang.String querystring,
java.lang.String sort,
int offset,
int maxcount,
long maxtime,
int buffersize,
int concurrency,
boolean prefetchIDs,
java.lang.String... fields)
Get results from a solr query as a stream of documents.
|
java.util.concurrent.BlockingQueue<java.lang.String> |
concurrentIDsByQueries(java.util.List<java.lang.String> querystrings,
java.lang.String sort,
int offset,
int maxcount,
long maxtime,
int buffersize,
int concurrency)
get a document id result stream from a set of solr queries.
|
java.util.concurrent.BlockingQueue<java.lang.String> |
concurrentIDsByQuery(java.lang.String querystring,
java.lang.String sort,
int offset,
int maxcount,
long maxtime,
int buffersize,
int concurrency)
get a document id result stream from a solr query.
|
void |
deleteById(java.lang.String id)
delete an entry from solr using the url hash as document id
|
void |
deleteByIds(java.util.Collection<java.lang.String> ids)
delete a set of entries from solr; entries are identified by their url hash
|
void |
deleteByQuery(java.lang.String querystring)
delete entries from solr according the given solr query string
|
void |
ensureAliveProcessHandler() |
boolean |
equals(java.lang.Object o) |
long |
getCountByQuery(java.lang.String querystring)
get the number of results when this query is done.
|
SolrDocument |
getDocumentById(java.lang.String id,
java.lang.String... fields)
get a document from solr by given key for the id-field
|
SolrDocumentList |
getDocumentListByParams(ModifiableSolrParams params)
get the solr document list from a query response
This differs from getResponseByParams in such a way that it does only create the fields of the response but
never search snippets and there are also no facets generated.
|
SolrDocumentList |
getDocumentListByQuery(java.lang.String querystring,
java.lang.String sort,
int offset,
int count,
java.lang.String... fields)
get a query result from solr
to get all results set the query String to "*:*"
|
java.util.LinkedHashMap<java.lang.String,ReversibleScoreMap<java.lang.String>> |
getFacets(java.lang.String query,
int maxresults,
java.lang.String... fields)
get facets of the index: a list of lists with values that are most common in a specific field
|
SolrConnector.LoadTimeURL |
getLoadTimeURL(java.lang.String id)
check if a given document, identified by url hash as document id exists
|
QueryResponse |
getResponseByParams(ModifiableSolrParams query)
get a "full" query response from solr.
|
int |
getSegmentCount()
ask the solr subsystem about it's segment number
|
long |
getSize()
get the size of the index
|
int |
hashCode() |
boolean |
isClosed()
test if the connector is already closed
|
java.util.Iterator<java.lang.String> |
iterator() |
void |
optimize(int maxSegments)
force an explicit merge of segments
|
void |
update(java.util.Collection<SolrInputDocument> solrdoc)
Update a solr document.
|
void |
update(SolrInputDocument solrdoc)
Update a solr document.
|
private void |
updateCache(java.lang.String id,
SolrConnector.LoadTimeURL md) |
private static final long AUTOCOMMIT
private SolrConnector connector
private ARC<java.lang.String,SolrConnector.LoadTimeURL> metadataCache
private final java.util.LinkedHashMap<java.lang.String,SolrInputDocument> docBuffer
private ConcurrentUpdateSolrConnector.CommitHandler processHandler
private final int updateCapacity
private boolean commitProcessRunning
public ConcurrentUpdateSolrConnector(SolrConnector connector, int updateCapacity, int idCacheCapacity, int concurrency)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
private void commitDocBuffer()
public int bufferSize()
SolrConnector
bufferSize
in interface SolrConnector
public void clearCaches()
SolrConnector
clearCaches
in interface SolrConnector
private void updateCache(java.lang.String id, SolrConnector.LoadTimeURL md)
public void ensureAliveProcessHandler()
public java.util.Iterator<java.lang.String> iterator()
iterator
in interface java.lang.Iterable<java.lang.String>
public long getSize()
SolrConnector
getSize
in interface SolrConnector
public void commit(boolean softCommit)
SolrConnector
commit
in interface SolrConnector
public void optimize(int maxSegments)
SolrConnector
optimize
in interface SolrConnector
maxSegments
- the maximum number of segments. Set to 1 for maximum optimizationpublic int getSegmentCount()
SolrConnector
getSegmentCount
in interface SolrConnector
public boolean isClosed()
SolrConnector
isClosed
in interface SolrConnector
public void close()
SolrConnector
close
in interface SolrConnector
public void clear() throws java.io.IOException
SolrConnector
clear
in interface SolrConnector
java.io.IOException
public void deleteById(java.lang.String id) throws java.io.IOException
SolrConnector
deleteById
in interface SolrConnector
id
- the url hash of the entryjava.io.IOException
public void deleteByIds(java.util.Collection<java.lang.String> ids) throws java.io.IOException
SolrConnector
deleteByIds
in interface SolrConnector
ids
- a list of url hashesjava.io.IOException
public void deleteByQuery(java.lang.String querystring) throws java.io.IOException
SolrConnector
deleteByQuery
in interface SolrConnector
java.io.IOException
public SolrConnector.LoadTimeURL getLoadTimeURL(java.lang.String id) throws java.io.IOException
SolrConnector
getLoadTimeURL
in interface SolrConnector
id
- the url hash and document idjava.io.IOException
public void add(SolrInputDocument solrdoc) throws java.io.IOException, SolrException
SolrConnector
add
in interface SolrConnector
java.io.IOException
SolrException
public void add(java.util.Collection<SolrInputDocument> solrdocs) throws java.io.IOException, SolrException
SolrConnector
add
in interface SolrConnector
java.io.IOException
SolrException
public SolrDocument getDocumentById(java.lang.String id, java.lang.String... fields) throws java.io.IOException
SolrConnector
getDocumentById
in interface SolrConnector
fields
- list of fieldsjava.io.IOException
public QueryResponse getResponseByParams(ModifiableSolrParams query) throws java.io.IOException, SolrException
SolrConnector
getResponseByParams
in interface SolrConnector
java.io.IOException
SolrException
public SolrDocumentList getDocumentListByParams(ModifiableSolrParams params) throws java.io.IOException, SolrException
SolrConnector
getDocumentListByParams
in interface SolrConnector
java.io.IOException
SolrException
public SolrDocumentList getDocumentListByQuery(java.lang.String querystring, java.lang.String sort, int offset, int count, java.lang.String... fields) throws java.io.IOException, SolrException
SolrConnector
getDocumentListByQuery
in interface SolrConnector
querystring
- the solr query stringsort
- the solr sort string, may be null to be not usedoffset
- the first result offsetcount
- number of wanted resultsfields
- list of fieldsjava.io.IOException
SolrException
public long getCountByQuery(java.lang.String querystring) throws java.io.IOException
SolrConnector
getCountByQuery
in interface SolrConnector
java.io.IOException
public java.util.LinkedHashMap<java.lang.String,ReversibleScoreMap<java.lang.String>> getFacets(java.lang.String query, int maxresults, java.lang.String... fields) throws java.io.IOException
SolrConnector
getFacets
in interface SolrConnector
query
- a query which is performed to get the facetsmaxresults
- the maximum size of the resulting mapsfields
- the field names which are selected as facetjava.io.IOException
public java.util.concurrent.BlockingQueue<SolrDocument> concurrentDocumentsByQuery(java.lang.String querystring, java.lang.String sort, int offset, int maxcount, long maxtime, int buffersize, int concurrency, boolean prefetchIDs, java.lang.String... fields)
SolrConnector
concurrentDocumentsByQuery
in interface SolrConnector
querystring
- the solr query stringsort
- the solr sort string, may be null to be not usedoffset
- first result offsetmaxcount
- the maximum number of resultsmaxtime
- the maximum time in millisecondsbuffersize
- the size of an ArrayBlockingQueue; if <= 0 then a LinkedBlockingQueue is usedconcurrency
- is the number of AbstractSolrConnector.POISON_DOCUMENT entries to add at the end of the feedprefetchIDs
- if true, then first all IDs are fetched and then all documents are queries by the ID. If false then documents are retrieved directlyfields
- list of fieldspublic java.util.concurrent.BlockingQueue<SolrDocument> concurrentDocumentsByQueries(java.util.List<java.lang.String> querystrings, java.lang.String sort, int offset, int maxcount, long maxtime, int buffersize, int concurrency, boolean prefetchIDs, java.lang.String... fields)
SolrConnector
concurrentDocumentsByQueries
in interface SolrConnector
querystrings
- the list of solr query stringssort
- the solr sort string, may be null to be not usedoffset
- first result offsetmaxcount
- the maximum number of resultsmaxtime
- the maximum time in millisecondsbuffersize
- the size of an ArrayBlockingQueue; if <= 0 then a LinkedBlockingQueue is usedconcurrency
- is the number of AbstractSolrConnector.POISON_DOCUMENT entries to add at the end of the feedprefetchIDs
- if true, then first all IDs are fetched and then all documents are queries by the ID. If false then documents are retrieved directlyfields
- list of fieldspublic java.util.concurrent.BlockingQueue<java.lang.String> concurrentIDsByQuery(java.lang.String querystring, java.lang.String sort, int offset, int maxcount, long maxtime, int buffersize, int concurrency)
SolrConnector
concurrentIDsByQuery
in interface SolrConnector
sort
- the solr sort string, may be null to be not usedbuffersize
- the size of an ArrayBlockingQueue; if <= 0 then a LinkedBlockingQueue is usedconcurrency
- is the number of AbstractSolrConnector.POISON_ID entries to add at the end of the feedpublic java.util.concurrent.BlockingQueue<java.lang.String> concurrentIDsByQueries(java.util.List<java.lang.String> querystrings, java.lang.String sort, int offset, int maxcount, long maxtime, int buffersize, int concurrency)
SolrConnector
concurrentIDsByQueries
in interface SolrConnector
sort
- the solr sort string, may be null to be not usedoffset
- common offset of all queriesmaxcount
- maximum count for each querybuffersize
- the size of an ArrayBlockingQueue; if <= 0 then a LinkedBlockingQueue is usedconcurrency
- is the number of AbstractSolrConnector.POISON_ID entries to add at the end of the feedpublic void update(SolrInputDocument solrdoc) throws java.io.IOException, SolrException
SolrConnector
update
in interface SolrConnector
java.io.IOException
SolrException
public void update(java.util.Collection<SolrInputDocument> solrdoc) throws java.io.IOException, SolrException
SolrConnector
update
in interface SolrConnector
java.io.IOException
SolrException