|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.dspace.discovery.SolrServiceImpl
@Service public class SolrServiceImpl
SolrIndexer contains the methods that index Items and their metadata, collections, communities, etc. It is meant to either be invoked from the command line (see dspace/bin/index-all) or via the indexContent() methods within DSpace.
The Administrator can choose to run SolrIndexer in a cron that repeats regularly, a failed attempt to index from the UI will be "caught" up on in that cron. The SolrServiceImple is registered as a Service in the ServiceManager via A spring configuration file located under classpath://spring/spring-dspace-applicationContext.xml Its configuration is Autowired by the ApplicationContext
| Field Summary | |
|---|---|
static String |
AUTHORITY_SEPARATOR
|
static String |
FILTER_SEPARATOR
|
protected static String |
LAST_INDEXED_FIELD
|
static String |
STORE_SEPARATOR
|
static String |
VARIANTS_STORE_SEPARATOR
|
| Constructor Summary | |
|---|---|
SolrServiceImpl()
|
|
| Method Summary | |
|---|---|
protected void |
addContainerMetadataField(org.apache.solr.common.SolrInputDocument doc,
List<String> highlightedMetadataFields,
String metadataField,
String value)
Add the metadata value of the community/collection to the solr document IF needed highlighting is added ! |
protected void |
buildDocument(Context context,
Collection collection)
Build a solr document for a DSpace Collection. |
protected void |
buildDocument(Context context,
Community community)
Build a solr document for a DSpace Community. |
protected void |
buildDocument(Context context,
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 |
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(Context c)
create full index - wiping old index |
protected void |
emailException(Exception exception)
|
protected static DSpaceObject |
findDSpaceObject(Context context,
org.apache.solr.common.SolrDocument doc)
|
protected List<String> |
getCollectionLocations(Collection target)
|
protected List<String> |
getItemLocations(Item myitem)
|
List<Item> |
getRelatedItems(Context context,
Item item,
DiscoveryMoreLikeThisConfiguration mltConfig)
|
protected org.apache.solr.client.solrj.impl.CommonsHttpSolrServer |
getSolr()
|
void |
indexContent(Context context,
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(Context context,
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(Context context,
DSpaceObject dso,
boolean force,
boolean commit)
|
static String |
locationToName(Context context,
String field,
String value)
|
void |
optimize()
Maintenance to keep a SOLR index efficient. |
void |
reIndexContent(Context context,
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(Context context,
DiscoverQuery discoveryQuery,
boolean includeWithdrawn)
|
protected DiscoverResult |
retrieveResult(Context context,
DiscoverQuery query,
org.apache.solr.client.solrj.response.QueryResponse solrQueryResponse)
|
DiscoverResult |
search(Context context,
DiscoverQuery query)
Convenient method to call @see #search(Context, DSpaceObject, DiscoverQuery) with a null DSpace Object as scope (i.e. |
DiscoverResult |
search(Context context,
DiscoverQuery discoveryQuery,
boolean includeWithdrawn)
|
DiscoverResult |
search(Context context,
DSpaceObject dso,
DiscoverQuery query)
Convenient method to call @see #search(Context, DSpaceObject, DiscoverQuery, boolean) with includeWithdrawn=false |
DiscoverResult |
search(Context context,
DSpaceObject dso,
DiscoverQuery discoveryQuery,
boolean includeWithdrawn)
|
List<DSpaceObject> |
search(Context context,
String query,
int offset,
int max,
String... filterquery)
|
List<DSpaceObject> |
search(Context context,
String query,
String orderfield,
boolean ascending,
int offset,
int max,
String... filterquery)
|
InputStream |
searchAsInputStream(DiscoverQuery query)
Simple means to return the search result as an InputStream |
InputStream |
searchJSON(Context context,
DiscoverQuery query,
DSpaceObject dso,
String jsonIdentifier)
|
InputStream |
searchJSON(Context context,
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 |
DiscoverFilterQuery |
toFilterQuery(Context context,
String field,
String operator,
String value)
Transforms the given string field and value into a filter query |
String |
toSortFieldIndex(String metadataField,
String type)
Transforms the metadata field of the given sort configuration into the indexed field which we can then use in our solr queries |
protected String |
transformAuthorityValue(Context context,
String field,
String value)
|
protected String |
transformDisplayedValue(Context context,
String field,
String value)
|
protected String |
transformFacetField(DiscoverFacetField facetFieldConfig,
String field,
boolean removePostfix)
|
protected String |
transformSortValue(Context context,
String field,
String value)
|
void |
unIndexContent(Context context,
DSpaceObject dso)
unIndex removes an Item, Collection, or Community |
void |
unIndexContent(Context context,
DSpaceObject dso,
boolean commit)
unIndex removes an Item, Collection, or Community |
void |
unIndexContent(Context context,
String handle)
Unindex a Document in the Lucene index. |
void |
unIndexContent(Context context,
String handle,
boolean commit)
Unindex a Document in the Lucene Index. |
void |
updateIndex(Context context)
Iterates over all Items, Collections and Communities. |
void |
updateIndex(Context context,
boolean force)
Iterates over all Items, Collections and Communities. |
protected void |
writeDocument(org.apache.solr.common.SolrInputDocument doc)
Write the document to the index under the appropriate handle. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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
| Constructor Detail |
|---|
public SolrServiceImpl()
| Method Detail |
|---|
protected org.apache.solr.client.solrj.impl.CommonsHttpSolrServer getSolr()
throws MalformedURLException,
org.apache.solr.client.solrj.SolrServerException
MalformedURLException
org.apache.solr.client.solrj.SolrServerException
public void indexContent(Context context,
DSpaceObject dso)
throws SQLException
indexContent in interface IndexingServicecontext - Users Contextdso - DSpace Object (Item, Collection or Community
SQLException
IOException
public void indexContent(Context context,
DSpaceObject dso,
boolean force)
throws SQLException
indexContent in interface IndexingServicecontext - Users Contextdso - DSpace Object (Item, Collection or Communityforce - Force update even if not stale.
SQLException
IOException
public void unIndexContent(Context context,
DSpaceObject dso)
throws SQLException,
IOException
unIndexContent in interface IndexingServicecontext - dso - DSpace Object, can be Community, Item, or Collection
SQLException
IOException
public void unIndexContent(Context context,
DSpaceObject dso,
boolean commit)
throws SQLException,
IOException
unIndexContent in interface IndexingServicecontext - dso - DSpace Object, can be Community, Item, or Collectioncommit - if true force an immediate commit on SOLR
SQLException
IOException
public void unIndexContent(Context context,
String handle)
throws IOException,
SQLException
unIndexContent in interface IndexingServicecontext - the dspace contexthandle - the handle of the object to be deleted
IOException
SQLException
public void unIndexContent(Context context,
String handle,
boolean commit)
throws SQLException,
IOException
unIndexContent in interface IndexingServicecontext - the dspace contexthandle - the handle of the object to be deleted
SQLException
IOException
public void reIndexContent(Context context,
DSpaceObject dso)
throws SQLException,
IOException
reIndexContent in interface IndexingServicecontext - context objectdso - object to re-index
SQLException
IOException
public void createIndex(Context c)
throws SQLException,
IOException
createIndex in interface IndexingServicec - context to use
SQLException
IOExceptionpublic void updateIndex(Context context)
updateIndex in interface IndexingServicecontext - the dspace context
public void updateIndex(Context context,
boolean force)
updateIndex in interface IndexingServicecontext - the dspace contextforce - whether or not to force the reindexing
public void cleanIndex(boolean force)
throws IOException,
SQLException,
SearchServiceException
cleanIndex in interface IndexingServiceforce - whether or not to force a clean index
IOException - IO exception
SQLException - sql exception
SearchServiceException - occurs when something went wrong with querying the solr serverpublic void optimize()
optimize in interface IndexingServiceprotected void emailException(Exception exception)
protected boolean requiresIndexing(String handle,
Date lastModified)
throws SQLException,
IOException,
SearchServiceException
handle - the handle of the dsolastModified - the last modified date of the DSpace object
SQLException - sql exception
IOException - io exception
SearchServiceException - if something went wrong with querying the solr server
protected List<String> getItemLocations(Item myitem)
throws SQLException
myitem - the item for which our locations are to be retrieved
SQLException - sql exception
protected List<String> getCollectionLocations(Collection target)
throws SQLException
SQLException
protected void writeDocument(org.apache.solr.common.SolrInputDocument doc)
throws IOException
doc - the solr document to be written to the server
IOException - IO exception
protected void buildDocument(Context context,
Community community)
throws SQLException,
IOException
community - Community to be indexed
SQLException
IOException
protected void buildDocument(Context context,
Collection collection)
throws SQLException,
IOException
collection - Collection to be indexed
SQLException - sql exception
IOException - IO exception
protected void addContainerMetadataField(org.apache.solr.common.SolrInputDocument doc,
List<String> highlightedMetadataFields,
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(Context context,
Item item)
throws SQLException,
IOException
context - Users Contextitem - The DSpace Item to be indexed
SQLException
IOException
protected 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 date
public static String locationToName(Context context,
String field,
String value)
throws SQLException
SQLException
public DiscoverResult search(Context context,
DiscoverQuery query)
throws SearchServiceException
SearchService
search in interface SearchServicecontext - DSpace Context objectquery - the discovery query object
SearchServiceException
public DiscoverResult search(Context context,
DSpaceObject dso,
DiscoverQuery query)
throws SearchServiceException
SearchService
search in interface SearchServicecontext - DSpace Context objectdso - a DSpace Object to use as scope of the search (only results
within this object)query - the discovery query object
SearchServiceException
public DiscoverResult search(Context context,
DSpaceObject dso,
DiscoverQuery discoveryQuery,
boolean includeWithdrawn)
throws SearchServiceException
search in interface SearchServicecontext - DSpace Context objectdso - a DSpace Object to use as scope of the search (only results
within this object)discoveryQuery - the discovery query objectincludeWithdrawn - use true to include in the results also withdrawn
items that match the query
SearchServiceException
public DiscoverResult search(Context context,
DiscoverQuery discoveryQuery,
boolean includeWithdrawn)
throws SearchServiceException
search in interface SearchServicecontext - DSpace Context objectincludeWithdrawn - use true to include in the results also withdrawn
items that match the query
SearchServiceException
protected org.apache.solr.client.solrj.SolrQuery resolveToSolrQuery(Context context,
DiscoverQuery discoveryQuery,
boolean includeWithdrawn)
public InputStream searchJSON(Context context,
DiscoverQuery query,
DSpaceObject dso,
String jsonIdentifier)
throws SearchServiceException
searchJSON in interface SearchServiceSearchServiceException
public InputStream searchJSON(Context context,
DiscoverQuery discoveryQuery,
String jsonIdentifier)
throws SearchServiceException
searchJSON in interface SearchServiceSearchServiceException
protected DiscoverResult retrieveResult(Context context,
DiscoverQuery query,
org.apache.solr.client.solrj.response.QueryResponse solrQueryResponse)
throws SQLException
SQLException
protected static DSpaceObject findDSpaceObject(Context context,
org.apache.solr.common.SolrDocument doc)
throws SQLException
SQLException
public InputStream searchAsInputStream(DiscoverQuery query)
throws SearchServiceException,
IOException
SearchServiceException
IOException
public List<DSpaceObject> search(Context context,
String query,
int offset,
int max,
String... filterquery)
public List<DSpaceObject> search(Context context,
String query,
String orderfield,
boolean ascending,
int offset,
int max,
String... filterquery)
search in interface SearchService
public DiscoverFilterQuery toFilterQuery(Context context,
String field,
String operator,
String value)
throws SQLException
SearchService
toFilterQuery in interface SearchServicecontext - the DSpace contextfield - the field of the filter queryvalue - the filter query value
SQLException - ...
public List<Item> getRelatedItems(Context context,
Item item,
DiscoveryMoreLikeThisConfiguration mltConfig)
getRelatedItems in interface SearchService
public String toSortFieldIndex(String metadataField,
String type)
SearchService
toSortFieldIndex in interface SearchServicemetadataField - the metadata field
protected String transformFacetField(DiscoverFacetField facetFieldConfig,
String field,
boolean removePostfix)
protected String transformDisplayedValue(Context context,
String field,
String value)
throws SQLException
SQLException
protected String transformAuthorityValue(Context context,
String field,
String value)
throws SQLException
SQLException
protected String transformSortValue(Context context,
String field,
String value)
throws SQLException
SQLException
public void indexContent(Context context,
DSpaceObject dso,
boolean force,
boolean commit)
throws SearchServiceException,
SQLException
indexContent in interface IndexingServiceSearchServiceException
SQLException
public void commit()
throws SearchServiceException
commit in interface IndexingServiceSearchServiceException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||