@Service public class SolrServiceImpl extends Object implements org.dspace.discovery.SearchService, org.dspace.discovery.IndexingService
| Modifier and Type | Field and Description |
|---|---|
static String |
AUTHORITY_SEPARATOR |
static String |
FILTER_SEPARATOR |
protected static String |
LAST_INDEXED_FIELD |
static String |
STORE_SEPARATOR |
static String |
VARIANTS_STORE_SEPARATOR |
| Constructor and Description |
|---|
SolrServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addContainerMetadataField(org.apache.solr.common.SolrInputDocument doc,
List<String> highlightedMetadataFields,
List<String> toIgnoreMetadataFields,
String metadataField,
String value)
Add the metadata value of the community/collection to the solr document
IF needed highlighting is added !
|
protected void |
buildDocument(org.dspace.core.Context context,
org.dspace.content.Bitstream bitstream) |
protected void |
buildDocument(org.dspace.core.Context context,
org.dspace.content.Collection collection)
Build a solr document for a DSpace Collection.
|
protected void |
buildDocument(org.dspace.core.Context context,
org.dspace.content.Community community)
Build a solr document for a DSpace Community.
|
protected void |
buildDocument(org.dspace.core.Context context,
org.dspace.content.Item item)
Build a Lucene document for a DSpace Item and write the index
|
protected org.apache.solr.common.SolrInputDocument |
buildDocument(int type,
int id,
String handle,
List<String> locations)
Create Lucene document with all the shared fields initialized.
|
void |
buildSpellCheck() |
void |
cleanIndex(boolean force)
Iterates over all documents in the Lucene index and verifies they are in
database, if not, they are removed.
|
void |
commit() |
void |
createIndex(org.dspace.core.Context c)
create full index - wiping old index
|
protected void |
emailException(Exception exception) |
protected static org.dspace.content.DSpaceObject |
findDSpaceObject(org.dspace.core.Context context,
org.apache.solr.common.SolrDocument doc) |
protected List<String> |
getCollectionLocations(org.dspace.content.Collection target) |
protected List<String> |
getItemLocations(org.dspace.content.Item myitem) |
List<org.dspace.content.Item> |
getRelatedItems(org.dspace.core.Context context,
org.dspace.content.Item item,
org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration mltConfig) |
protected org.apache.solr.client.solrj.impl.HttpSolrServer |
getSolr() |
void |
indexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso)
If the handle for the "dso" already exists in the index, and the "dso"
has a lastModified timestamp that is newer than the document in the index
then it is updated, otherwise a new document is added.
|
void |
indexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
boolean force)
If the handle for the "dso" already exists in the index, and the "dso"
has a lastModified timestamp that is newer than the document in the index
then it is updated, otherwise a new document is added.
|
void |
indexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
boolean force,
boolean commit) |
static String |
locationToName(org.dspace.core.Context context,
String field,
String value) |
void |
optimize()
Maintenance to keep a SOLR index efficient.
|
void |
reIndexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso)
reIndexContent removes something from the index, then re-indexes it
|
protected boolean |
requiresIndexing(String handle,
Date lastModified)
Is stale checks the lastModified time stamp in the database and the index
to determine if the index is stale.
|
protected org.apache.solr.client.solrj.SolrQuery |
resolveToSolrQuery(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery discoveryQuery,
boolean includeUnDiscoverable) |
protected org.dspace.discovery.DiscoverResult |
retrieveResult(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery query,
org.apache.solr.client.solrj.response.QueryResponse solrQueryResponse) |
org.dspace.discovery.DiscoverResult |
search(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery query) |
org.dspace.discovery.DiscoverResult |
search(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery discoveryQuery,
boolean includeUnDiscoverable) |
org.dspace.discovery.DiscoverResult |
search(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
org.dspace.discovery.DiscoverQuery query) |
org.dspace.discovery.DiscoverResult |
search(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
org.dspace.discovery.DiscoverQuery discoveryQuery,
boolean includeUnDiscoverable) |
List<org.dspace.content.DSpaceObject> |
search(org.dspace.core.Context context,
String query,
int offset,
int max,
String... filterquery) |
List<org.dspace.content.DSpaceObject> |
search(org.dspace.core.Context context,
String query,
String orderfield,
boolean ascending,
int offset,
int max,
String... filterquery) |
InputStream |
searchAsInputStream(org.dspace.discovery.DiscoverQuery query)
Simple means to return the search result as an InputStream
|
InputStream |
searchJSON(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery query,
org.dspace.content.DSpaceObject dso,
String jsonIdentifier) |
InputStream |
searchJSON(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery discoveryQuery,
String jsonIdentifier) |
static Date |
toDate(String t)
Helper function to retrieve a date using a best guess of the potential
date encodings on a field
|
org.dspace.discovery.DiscoverFilterQuery |
toFilterQuery(org.dspace.core.Context context,
String field,
String operator,
String value) |
String |
toSortFieldIndex(String metadataField,
String type) |
protected String |
transformAuthorityValue(org.dspace.core.Context context,
String field,
String value) |
protected String |
transformDisplayedValue(org.dspace.core.Context context,
String field,
String value) |
protected String |
transformFacetField(org.dspace.discovery.DiscoverFacetField facetFieldConfig,
String field,
boolean removePostfix) |
protected String |
transformSortValue(org.dspace.core.Context context,
String field,
String value) |
void |
unIndexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso)
unIndex removes an Item, Collection, or Community
|
void |
unIndexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
boolean commit)
unIndex removes an Item, Collection, or Community
|
void |
unIndexContent(org.dspace.core.Context context,
String handle)
Unindex a Document in the Lucene index.
|
void |
unIndexContent(org.dspace.core.Context context,
String handle,
boolean commit)
Unindex a Document in the Lucene Index.
|
void |
updateIndex(org.dspace.core.Context context)
Iterates over all Items, Collections and Communities.
|
void |
updateIndex(org.dspace.core.Context context,
boolean force)
Iterates over all Items, Collections and Communities.
|
protected void |
writeDocument(org.apache.solr.common.SolrInputDocument doc,
List<org.dspace.discovery.BitstreamContentStream> streams)
Write the document to the index under the appropriate handle.
|
protected static final String LAST_INDEXED_FIELD
public static final String FILTER_SEPARATOR
public static final String AUTHORITY_SEPARATOR
public static final String STORE_SEPARATOR
public static final String VARIANTS_STORE_SEPARATOR
protected org.apache.solr.client.solrj.impl.HttpSolrServer getSolr()
public void indexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso)
throws SQLException
indexContent in interface org.dspace.discovery.IndexingServicecontext - Users Contextdso - DSpace Object (Item, Collection or CommunitySQLExceptionIOExceptionpublic void indexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
boolean force)
throws SQLException
indexContent in interface org.dspace.discovery.IndexingServicecontext - Users Contextdso - DSpace Object (Item, Collection or Communityforce - Force update even if not stale.SQLExceptionIOExceptionpublic void unIndexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso)
throws SQLException,
IOException
unIndexContent in interface org.dspace.discovery.IndexingServicecontext - dso - DSpace Object, can be Community, Item, or CollectionSQLExceptionIOExceptionpublic void unIndexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
boolean commit)
throws SQLException,
IOException
unIndexContent in interface org.dspace.discovery.IndexingServicecontext - dso - DSpace Object, can be Community, Item, or Collectioncommit - if true force an immediate commit on SOLRSQLExceptionIOExceptionpublic void unIndexContent(org.dspace.core.Context context,
String handle)
throws IOException,
SQLException
unIndexContent in interface org.dspace.discovery.IndexingServicecontext - the dspace contexthandle - the handle of the object to be deletedIOExceptionSQLExceptionpublic void unIndexContent(org.dspace.core.Context context,
String handle,
boolean commit)
throws SQLException,
IOException
unIndexContent in interface org.dspace.discovery.IndexingServicecontext - the dspace contexthandle - the handle of the object to be deletedSQLExceptionIOExceptionpublic void reIndexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso)
throws SQLException,
IOException
reIndexContent in interface org.dspace.discovery.IndexingServicecontext - context objectdso - object to re-indexSQLExceptionIOExceptionpublic void createIndex(org.dspace.core.Context c)
throws SQLException,
IOException
createIndex in interface org.dspace.discovery.IndexingServicec - context to useSQLExceptionIOExceptionpublic void updateIndex(org.dspace.core.Context context)
updateIndex in interface org.dspace.discovery.IndexingServicecontext - the dspace contextpublic void updateIndex(org.dspace.core.Context context,
boolean force)
updateIndex in interface org.dspace.discovery.IndexingServicecontext - the dspace contextforce - whether or not to force the reindexingpublic void cleanIndex(boolean force)
throws IOException,
SQLException,
org.dspace.discovery.SearchServiceException
cleanIndex in interface org.dspace.discovery.IndexingServiceforce - whether or not to force a clean indexIOException - IO exceptionSQLException - sql exceptionSearchServiceException - occurs when something went wrong with querying the solr serverpublic void optimize()
optimize in interface org.dspace.discovery.IndexingServicepublic void buildSpellCheck()
throws org.dspace.discovery.SearchServiceException
buildSpellCheck in interface org.dspace.discovery.IndexingServiceorg.dspace.discovery.SearchServiceExceptionprotected void emailException(Exception exception)
protected boolean requiresIndexing(String handle, Date lastModified) throws SQLException, IOException, org.dspace.discovery.SearchServiceException
handle - the handle of the dsolastModified - the last modified date of the DSpace objectSQLException - sql exceptionIOException - io exceptionSearchServiceException - if something went wrong with querying the solr serverprotected List<String> getItemLocations(org.dspace.content.Item myitem) throws SQLException
myitem - the item for which our locations are to be retrievedSQLException - sql exceptionprotected List<String> getCollectionLocations(org.dspace.content.Collection target) throws SQLException
SQLExceptionprotected void writeDocument(org.apache.solr.common.SolrInputDocument doc,
List<org.dspace.discovery.BitstreamContentStream> streams)
throws IOException
doc - the solr document to be written to the serverstreams - IOException - IO exceptionprotected void buildDocument(org.dspace.core.Context context,
org.dspace.content.Community community)
throws SQLException,
IOException
community - Community to be indexedSQLExceptionIOExceptionprotected void buildDocument(org.dspace.core.Context context,
org.dspace.content.Bitstream bitstream)
throws SQLException,
IOException
SQLExceptionIOExceptionprotected void buildDocument(org.dspace.core.Context context,
org.dspace.content.Collection collection)
throws SQLException,
IOException
collection - Collection to be indexedSQLException - sql exceptionIOException - IO exceptionprotected void addContainerMetadataField(org.apache.solr.common.SolrInputDocument doc,
List<String> highlightedMetadataFields,
List<String> toIgnoreMetadataFields,
String metadataField,
String value)
doc - the solr documenthighlightedMetadataFields - the list of metadata fields that CAN be highlightedmetadataField - the metadata field addedvalue - the value (can be NULL !)protected void buildDocument(org.dspace.core.Context context,
org.dspace.content.Item item)
throws SQLException,
IOException
context - Users Contextitem - The DSpace Item to be indexedSQLExceptionIOExceptionprotected org.apache.solr.common.SolrInputDocument buildDocument(int type,
int id,
String handle,
List<String> locations)
type - Type of DSpace Objectid - handle - locations - @returnpublic static Date toDate(String t)
t - the string to be transformed to a datepublic static String locationToName(org.dspace.core.Context context, String field, String value) throws SQLException
SQLExceptionpublic org.dspace.discovery.DiscoverResult search(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery query)
throws org.dspace.discovery.SearchServiceException
search in interface org.dspace.discovery.SearchServiceorg.dspace.discovery.SearchServiceExceptionpublic org.dspace.discovery.DiscoverResult search(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
org.dspace.discovery.DiscoverQuery query)
throws org.dspace.discovery.SearchServiceException
search in interface org.dspace.discovery.SearchServiceorg.dspace.discovery.SearchServiceExceptionpublic org.dspace.discovery.DiscoverResult search(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
org.dspace.discovery.DiscoverQuery discoveryQuery,
boolean includeUnDiscoverable)
throws org.dspace.discovery.SearchServiceException
search in interface org.dspace.discovery.SearchServiceorg.dspace.discovery.SearchServiceExceptionpublic org.dspace.discovery.DiscoverResult search(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery discoveryQuery,
boolean includeUnDiscoverable)
throws org.dspace.discovery.SearchServiceException
search in interface org.dspace.discovery.SearchServiceorg.dspace.discovery.SearchServiceExceptionprotected org.apache.solr.client.solrj.SolrQuery resolveToSolrQuery(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery discoveryQuery,
boolean includeUnDiscoverable)
public InputStream searchJSON(org.dspace.core.Context context, org.dspace.discovery.DiscoverQuery query, org.dspace.content.DSpaceObject dso, String jsonIdentifier) throws org.dspace.discovery.SearchServiceException
searchJSON in interface org.dspace.discovery.SearchServiceorg.dspace.discovery.SearchServiceExceptionpublic InputStream searchJSON(org.dspace.core.Context context, org.dspace.discovery.DiscoverQuery discoveryQuery, String jsonIdentifier) throws org.dspace.discovery.SearchServiceException
searchJSON in interface org.dspace.discovery.SearchServiceorg.dspace.discovery.SearchServiceExceptionprotected org.dspace.discovery.DiscoverResult retrieveResult(org.dspace.core.Context context,
org.dspace.discovery.DiscoverQuery query,
org.apache.solr.client.solrj.response.QueryResponse solrQueryResponse)
throws SQLException
SQLExceptionprotected static org.dspace.content.DSpaceObject findDSpaceObject(org.dspace.core.Context context,
org.apache.solr.common.SolrDocument doc)
throws SQLException
SQLExceptionpublic InputStream searchAsInputStream(org.dspace.discovery.DiscoverQuery query) throws org.dspace.discovery.SearchServiceException, IOException
org.dspace.discovery.SearchServiceExceptionIOExceptionpublic List<org.dspace.content.DSpaceObject> search(org.dspace.core.Context context, String query, int offset, int max, String... filterquery)
public List<org.dspace.content.DSpaceObject> search(org.dspace.core.Context context, String query, String orderfield, boolean ascending, int offset, int max, String... filterquery)
search in interface org.dspace.discovery.SearchServicepublic org.dspace.discovery.DiscoverFilterQuery toFilterQuery(org.dspace.core.Context context,
String field,
String operator,
String value)
throws SQLException
toFilterQuery in interface org.dspace.discovery.SearchServiceSQLExceptionpublic List<org.dspace.content.Item> getRelatedItems(org.dspace.core.Context context, org.dspace.content.Item item, org.dspace.discovery.configuration.DiscoveryMoreLikeThisConfiguration mltConfig)
getRelatedItems in interface org.dspace.discovery.SearchServicepublic String toSortFieldIndex(String metadataField, String type)
toSortFieldIndex in interface org.dspace.discovery.SearchServiceprotected String transformFacetField(org.dspace.discovery.DiscoverFacetField facetFieldConfig, String field, boolean removePostfix)
protected String transformDisplayedValue(org.dspace.core.Context context, String field, String value) throws SQLException
SQLExceptionprotected String transformAuthorityValue(org.dspace.core.Context context, String field, String value) throws SQLException
SQLExceptionprotected String transformSortValue(org.dspace.core.Context context, String field, String value) throws SQLException
SQLExceptionpublic void indexContent(org.dspace.core.Context context,
org.dspace.content.DSpaceObject dso,
boolean force,
boolean commit)
throws org.dspace.discovery.SearchServiceException,
SQLException
indexContent in interface org.dspace.discovery.IndexingServiceorg.dspace.discovery.SearchServiceExceptionSQLExceptionpublic void commit()
throws org.dspace.discovery.SearchServiceException
commit in interface org.dspace.discovery.IndexingServiceorg.dspace.discovery.SearchServiceExceptionCopyright © 2014 DuraSpace. All rights reserved.