public class SolrRestClientSearchService extends Object implements SearchService<SolrQuery>
SearchService
for Search REST API v2.Modifier and Type | Field and Description |
---|---|
protected Charset |
charset |
static Charset |
DEFAULT_CHARSET |
protected org.springframework.web.client.RestTemplate |
restTemplate |
protected String |
serverUrl |
Constructor and Description |
---|
SolrRestClientSearchService() |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Commits any pending changes made to the search engine's default index.
|
void |
commit(String indexId)
Commits any pending changes made to the search engine's default index.
|
protected String |
createBaseUrl(String serviceUrl) |
protected String |
createBaseUrl(String serviceUrl,
String indexId) |
SolrQuery |
createQuery() |
SolrQuery |
createQuery(Map<String,String[]> params) |
void |
delete(String site,
String id)
Deletes the search engine's index data of an XML document.
|
void |
delete(String indexId,
String site,
String id)
Deletes the search engine's index data of an XML document.
|
Map<String,Object> |
search(SolrQuery query)
Does a full-text search and returns a Map model.
|
Map<String,Object> |
search(String indexId,
SolrQuery query)
Does a full-text search and returns a Map model.
|
void |
setCharset(String charset) |
void |
setRestTemplate(org.springframework.web.client.RestTemplate restTemplate) |
void |
setServerUrl(String serverUrl) |
void |
update(String site,
String id,
String xml,
boolean ignoreRootInFieldNames)
Updates the search engine's index data of an XML document.
|
void |
update(String indexId,
String site,
String id,
String xml,
boolean ignoreRootInFieldNames)
Updates the search engine's index data of an XML document.
|
void |
updateContent(String site,
String id,
org.craftercms.core.service.Content content)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String site,
String id,
org.craftercms.core.service.Content content,
Map<String,List<String>> additionalFields)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String site,
String id,
File file)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String site,
String id,
File file,
Map<String,List<String>> additionalFields)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String indexId,
String site,
String id,
org.craftercms.core.service.Content content)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String indexId,
String site,
String id,
org.craftercms.core.service.Content content,
Map<String,List<String>> additionalFields)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String indexId,
String site,
String id,
File file)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
void |
updateContent(String indexId,
String site,
String id,
File file,
Map<String,List<String>> additionalFields)
Updates the search engine's index data of a binary or structured document (PDF, Word, Office).
|
protected void |
updateContent(String indexId,
String site,
String id,
org.springframework.core.io.Resource resource,
Map<String,List<String>> additionalFields) |
public static final Charset DEFAULT_CHARSET
protected String serverUrl
protected org.springframework.web.client.RestTemplate restTemplate
protected Charset charset
public void setServerUrl(String serverUrl)
public void setRestTemplate(org.springframework.web.client.RestTemplate restTemplate)
public void setCharset(String charset)
public SolrQuery createQuery()
createQuery
in interface QueryFactory<SolrQuery>
public SolrQuery createQuery(Map<String,String[]> params)
createQuery
in interface QueryFactory<SolrQuery>
public Map<String,Object> search(SolrQuery query) throws SearchException
SearchService
search
in interface SearchService<SolrQuery>
query
- the query objectSearchException
- if any error occurs that makes the search failpublic Map<String,Object> search(String indexId, SolrQuery query) throws SearchException
SearchService
search
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.query
- the query objectSearchException
- if any error occurs that makes the search failpublic void update(String site, String id, String xml, boolean ignoreRootInFieldNames) throws SearchException
SearchService
update
in interface SearchService<SolrQuery>
site
- the Crafter site name the content belongs toid
- the id of the XML document, within the sitexml
- the XML document to update in the indexignoreRootInFieldNames
- ignore the root element of the input XML in field namesSearchException
public void update(String indexId, String site, String id, String xml, boolean ignoreRootInFieldNames) throws SearchException
SearchService
update
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.site
- the Crafter site name the content belongs toid
- the id of the XML document, within the sitexml
- the XML document to update in the indexignoreRootInFieldNames
- ignore the root element of the input XML in field namesSearchException
public void delete(String site, String id) throws SearchException
SearchService
delete
in interface SearchService<SolrQuery>
site
- the Crafter site name the content belongs toid
- the id of the content, within the siteSearchException
public void delete(String indexId, String site, String id) throws SearchException
SearchService
delete
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.site
- the Crafter site name the content belongs toid
- the id of the content, within the siteSearchException
public void commit() throws SearchException
SearchService
commit
in interface SearchService<SolrQuery>
SearchException
public void commit(String indexId) throws SearchException
SearchService
commit
in interface SearchService<SolrQuery>
SearchException
public void updateContent(String site, String id, File file) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
site
- the Crafter site name the content belongs toid
- the id of the file, within the sitefile
- the file content to update in the indexSearchException
public void updateContent(String indexId, String site, String id, File file) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.site
- the Crafter site name the content belongs toid
- the id of the file, within the sitefile
- the file content to update in the indexSearchException
public void updateContent(String site, String id, File file, Map<String,List<String>> additionalFields) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
site
- the Crafter site name the content belongs toid
- the id of the file, within the sitefile
- the file content to update in the indexadditionalFields
- additional metadata fields to be indexed (shouldn't have the name site, id or
document)SearchException
public void updateContent(String indexId, String site, String id, File file, Map<String,List<String>> additionalFields) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.site
- the Crafter site name the content belongs toid
- the id of the XML document, within the sitefile
- the file content to update in the indexadditionalFields
- additional metadata fields to be indexed (shouldn't have the name site, id or
document)SearchException
public void updateContent(String site, String id, org.craftercms.core.service.Content content) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
site
- the Crafter site name the content belongs toid
- the id of the file, within the sitecontent
- the file content to update in the indexSearchException
public void updateContent(String indexId, String site, String id, org.craftercms.core.service.Content content) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.site
- the Crafter site name the content belongs toid
- the id of the file, within the sitecontent
- the file content to update in the indexSearchException
public void updateContent(String site, String id, org.craftercms.core.service.Content content, Map<String,List<String>> additionalFields) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
site
- the Crafter site name the content belongs toid
- the id of the file, within the sitecontent
- the file content to update in the indexadditionalFields
- additional metadata fields to be indexed (shouldn't have the name site, id or
document)SearchException
public void updateContent(String indexId, String site, String id, org.craftercms.core.service.Content content, Map<String,List<String>> additionalFields) throws SearchException
SearchService
updateContent
in interface SearchService<SolrQuery>
indexId
- the index ID (core in Solr terminology). Use null for default index.site
- the Crafter site name the content belongs toid
- the id of the XML document, within the sitecontent
- the file content to update in the indexadditionalFields
- additional metadata fields to be indexed (shouldn't have the name site, id or
document)SearchException
protected void updateContent(String indexId, String site, String id, org.springframework.core.io.Resource resource, Map<String,List<String>> additionalFields) throws SearchException
SearchException
Copyright © 2019 CrafterCMS. All rights reserved.