public class ElasticsearchServiceImpl extends Object implements ElasticsearchService
ElasticsearchService| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_DOC
According to Elasticsearch documentation this will be removed and this is the recommended value
|
static String |
DEFAULT_LOCAL_ID_NAME |
static int |
DEFAULT_SCROLL_SIZE |
static String |
DEFAULT_SCROLL_TIMEOUT |
protected ElasticsearchDocumentBuilder |
documentBuilder
Document Builder
|
protected DocumentParser |
documentParser
Document Parser
|
protected org.elasticsearch.client.RestHighLevelClient |
elasticsearchClient
The Elasticsearch client
|
protected String |
localIdFieldName
The name of the field for full ids
|
protected int |
scrollSize
The number of results to return for each scroll request
|
protected String |
scrollTimeout
The timeout for each the scroll request
|
| Constructor and Description |
|---|
ElasticsearchServiceImpl(ElasticsearchDocumentBuilder documentBuilder,
DocumentParser documentParser,
org.elasticsearch.client.RestHighLevelClient elasticsearchClient) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
delete(String indexName,
String siteName,
String docId)
Performs a delete for the given document
|
protected void |
doDelete(org.elasticsearch.client.RestHighLevelClient client,
String indexName,
String siteName,
String docId)
Performs the delete operation using the given Elasticsearch client
|
protected void |
doIndex(org.elasticsearch.client.RestHighLevelClient client,
String indexName,
String siteName,
String docId,
Map<String,Object> doc)
Performs the index operation using the given Elasticsearch client
|
protected void |
doRefresh(org.elasticsearch.client.RestHighLevelClient client,
String indexName)
Performs the refresh operation using the given Elasticsearch client
|
protected String |
getId(String path)
Hashes the full path to use as a unique id for Elasticsearch
|
void |
index(String indexName,
String siteName,
String docId,
Map<String,Object> doc) |
void |
index(String indexName,
String siteName,
String docId,
String xml,
Map<String,Object> additionalFields)
Performs an index for the given xml file
|
void |
indexBinary(String indexName,
String siteName,
String path,
Map<String,Object> additionalFields,
org.craftercms.core.service.Content content)
Performs an index for the given binary file
|
void |
indexBinary(String indexName,
String siteName,
String path,
Map<String,Object> additionalFields,
org.springframework.core.io.Resource resource) |
void |
refresh(String indexName)
Performs a refresh for a given index
|
List<String> |
searchField(String indexName,
String field,
org.elasticsearch.index.query.QueryBuilder queryBuilder)
Performs a search for a specific field
|
Map<String,Object> |
searchId(String indexName,
String docId) |
void |
setLocalIdFieldName(String localIdFieldName) |
void |
setScrollSize(int scrollSize) |
void |
setScrollTimeout(String scrollTimeout) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitindexpublic static final String DEFAULT_DOC
public static final String DEFAULT_LOCAL_ID_NAME
public static final int DEFAULT_SCROLL_SIZE
public static final String DEFAULT_SCROLL_TIMEOUT
protected ElasticsearchDocumentBuilder documentBuilder
protected DocumentParser documentParser
protected org.elasticsearch.client.RestHighLevelClient elasticsearchClient
protected String localIdFieldName
protected int scrollSize
protected String scrollTimeout
public ElasticsearchServiceImpl(ElasticsearchDocumentBuilder documentBuilder, DocumentParser documentParser, org.elasticsearch.client.RestHighLevelClient elasticsearchClient)
public void setLocalIdFieldName(String localIdFieldName)
public void setScrollSize(int scrollSize)
public void setScrollTimeout(String scrollTimeout)
public List<String> searchField(String indexName, String field, org.elasticsearch.index.query.QueryBuilder queryBuilder) throws ElasticsearchException
searchField in interface ElasticsearchServiceindexName - the name of the indexfield - the name of the fieldqueryBuilder - the filters to applyElasticsearchException - if there is any error during the operationpublic Map<String,Object> searchId(String indexName, String docId)
searchId in interface ElasticsearchServicepublic void index(String indexName, String siteName, String docId, Map<String,Object> doc)
index in interface ElasticsearchServiceprotected void doIndex(org.elasticsearch.client.RestHighLevelClient client,
String indexName,
String siteName,
String docId,
Map<String,Object> doc)
public void index(String indexName, String siteName, String docId, String xml, Map<String,Object> additionalFields) throws ElasticsearchException
index in interface ElasticsearchServiceindexName - the name of the indexsiteName - the name of the sitedocId - the id of the documentxml - the content of the documentadditionalFields - additional fields to indexElasticsearchException - if there is any error during the operationpublic void indexBinary(String indexName, String siteName, String path, Map<String,Object> additionalFields, org.craftercms.core.service.Content content) throws ElasticsearchException
indexBinary in interface ElasticsearchServiceindexName - the name of the indexsiteName - the name of the sitepath - the path of the documentadditionalFields - the additional fields to indexcontent - the content of the documentElasticsearchException - if there is any error during the operationpublic void indexBinary(String indexName, String siteName, String path, Map<String,Object> additionalFields, org.springframework.core.io.Resource resource) throws ElasticsearchException
indexBinary in interface ElasticsearchServiceElasticsearchExceptionpublic void delete(String indexName, String siteName, String docId) throws ElasticsearchException
delete in interface ElasticsearchServiceindexName - the name of the indexsiteName - the id of the sitedocId - the id of the documentElasticsearchException - if there is any error during the operationprotected void doDelete(org.elasticsearch.client.RestHighLevelClient client,
String indexName,
String siteName,
String docId)
public void refresh(String indexName) throws ElasticsearchException
refresh in interface ElasticsearchServiceindexName - the name of the indexElasticsearchException - if there is any error during the operationprotected void doRefresh(org.elasticsearch.client.RestHighLevelClient client,
String indexName)
throws ElasticsearchException
ElasticsearchExceptionprotected String getId(String path)
path - the path of the filepublic void close()
throws Exception
close in interface AutoCloseableExceptionCopyright © 2023 CrafterCMS. All rights reserved.