Class OpenSearchServiceImpl
java.lang.Object
org.craftercms.search.opensearch.impl.OpenSearchServiceImpl
- All Implemented Interfaces:
AutoCloseable
,OpenSearchService
- Direct Known Subclasses:
MultiOpenSearchServiceImpl
Default implementation of
OpenSearchService
- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final int
static final String
protected final OpenSearchDocumentBuilder
Document Builderprotected final DocumentParser
Document Parserprotected String
The name of the field for full idsprotected final org.opensearch.client.opensearch.OpenSearchClient
The OpenSearch clientprotected int
The number of results to return for each scroll requestprotected String
The timeout for each the scroll request -
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchServiceImpl
(OpenSearchDocumentBuilder documentBuilder, DocumentParser documentParser, org.opensearch.client.opensearch.OpenSearchClient openSearchClient) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Performs a delete for the given documentprotected void
doDelete
(org.opensearch.client.opensearch.OpenSearchClient client, String indexName, String siteName, String docId) Performs the delete operation using the given OpenSearch clientprotected void
doIndex
(org.opensearch.client.opensearch.OpenSearchClient client, String indexName, String siteName, String docId, Map<String, Object> doc) Performs the index operation using the given OpenSearch clientprotected void
Performs the refresh operation using the given OpenSearch clientprotected String
Hashes the full path to use as a unique id for OpenSearchvoid
index
(String indexName, String siteName, String docId, String xml, Map<String, Object> additionalFields) Performs an index for the given xml filevoid
void
indexBinary
(String indexName, String siteName, String path, org.craftercms.core.service.Content content, Map<String, Object> additionalFields) Performs an index for the given binary filevoid
indexBinary
(String indexName, String siteName, String path, org.springframework.core.io.Resource resource, Map<String, Object> additionalFields) void
Performs a refresh for a given indexsearchField
(String aliasName, String field, org.opensearch.client.opensearch._types.query_dsl.Query query) Performs a search for a specific fieldvoid
setLocalIdFieldName
(String localIdFieldName) void
setScrollSize
(int scrollSize) void
setScrollTimeout
(String scrollTimeout) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.craftercms.search.opensearch.OpenSearchService
index, indexBinary, indexBinary
-
Field Details
-
DEFAULT_LOCAL_ID_NAME
- See Also:
-
DEFAULT_SCROLL_SIZE
public static final int DEFAULT_SCROLL_SIZE- See Also:
-
DEFAULT_SCROLL_TIMEOUT
- See Also:
-
documentBuilder
Document Builder -
documentParser
Document Parser -
openSearchClient
protected final org.opensearch.client.opensearch.OpenSearchClient openSearchClientThe OpenSearch client -
localIdFieldName
The name of the field for full ids -
scrollSize
protected int scrollSizeThe number of results to return for each scroll request -
scrollTimeout
The timeout for each the scroll request
-
-
Constructor Details
-
OpenSearchServiceImpl
@ConstructorProperties({"documentBuilder","documentParser","OpenSearchClient"}) public OpenSearchServiceImpl(OpenSearchDocumentBuilder documentBuilder, DocumentParser documentParser, org.opensearch.client.opensearch.OpenSearchClient openSearchClient)
-
-
Method Details
-
setLocalIdFieldName
-
setScrollSize
public void setScrollSize(int scrollSize) -
setScrollTimeout
-
searchField
public List<String> searchField(String aliasName, String field, org.opensearch.client.opensearch._types.query_dsl.Query query) throws OpenSearchException Performs a search for a specific field- Specified by:
searchField
in interfaceOpenSearchService
- Parameters:
aliasName
- the name of the indexfield
- the name of the fieldquery
- the filters to apply- Returns:
- the list of values that match the search
- Throws:
OpenSearchException
- if there is any error during the operation
-
searchId
- Specified by:
searchId
in interfaceOpenSearchService
-
index
- Specified by:
index
in interfaceOpenSearchService
-
doIndex
protected void doIndex(org.opensearch.client.opensearch.OpenSearchClient client, String indexName, String siteName, String docId, Map<String, Object> doc) Performs the index operation using the given OpenSearch client -
index
public void index(String indexName, String siteName, String docId, String xml, Map<String, Object> additionalFields) throws OpenSearchExceptionPerforms an index for the given xml file- Specified by:
index
in interfaceOpenSearchService
- Parameters:
indexName
- the name of the indexsiteName
- the name of the sitedocId
- the id of the documentxml
- the content of the documentadditionalFields
- additional fields to index- Throws:
OpenSearchException
- if there is any error during the operation
-
indexBinary
public void indexBinary(String indexName, String siteName, String path, org.craftercms.core.service.Content content, Map<String, Object> additionalFields) throws OpenSearchExceptionPerforms an index for the given binary file- Specified by:
indexBinary
in interfaceOpenSearchService
- Parameters:
indexName
- the name of the indexsiteName
- the name of the sitepath
- the path of the documentcontent
- the content of the documentadditionalFields
- the additional fields to index- Throws:
OpenSearchException
- if there is any error during the operation
-
indexBinary
public void indexBinary(String indexName, String siteName, String path, org.springframework.core.io.Resource resource, Map<String, Object> additionalFields) throws OpenSearchException- Specified by:
indexBinary
in interfaceOpenSearchService
- Throws:
OpenSearchException
-
delete
Performs a delete for the given document- Specified by:
delete
in interfaceOpenSearchService
- Parameters:
indexName
- the name of the indexsiteName
- the id of the sitedocId
- the id of the document- Throws:
OpenSearchException
- if there is any error during the operation
-
doDelete
protected void doDelete(org.opensearch.client.opensearch.OpenSearchClient client, String indexName, String siteName, String docId) Performs the delete operation using the given OpenSearch client -
refresh
Performs a refresh for a given index- Specified by:
refresh
in interfaceOpenSearchService
- Parameters:
indexName
- the name of the index- Throws:
OpenSearchException
- if there is any error during the operation
-
doRefresh
protected void doRefresh(org.opensearch.client.opensearch.OpenSearchClient client, String indexName) throws OpenSearchException Performs the refresh operation using the given OpenSearch client- Throws:
OpenSearchException
-
getId
Hashes the full path to use as a unique id for OpenSearch- Parameters:
path
- the path of the file- Returns:
- MD5 hash for the path
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-