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 Stringstatic final intstatic final Stringprotected final OpenSearchDocumentBuilderDocument Builderprotected final DocumentParserDocument Parserprotected StringThe name of the field for full idsprotected final org.opensearch.client.opensearch.OpenSearchClientThe OpenSearch clientprotected intThe number of results to return for each scroll requestprotected StringThe timeout for each the scroll request -
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchServiceImpl(OpenSearchDocumentBuilder documentBuilder, DocumentParser documentParser, org.opensearch.client.opensearch.OpenSearchClient openSearchClient) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidPerforms a delete for the given documentprotected voiddoDelete(org.opensearch.client.opensearch.OpenSearchClient client, String indexName, String siteName, String docId) Performs the delete operation using the given OpenSearch clientprotected voiddoIndex(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 voidPerforms the refresh operation using the given OpenSearch clientprotected StringHashes the full path to use as a unique id for OpenSearchvoidindex(String indexName, String siteName, String docId, String xml, Map<String, Object> additionalFields) Performs an index for the given xml filevoidvoidindexBinary(String indexName, String siteName, String path, org.craftercms.core.service.Content content, Map<String, Object> additionalFields) Performs an index for the given binary filevoidindexBinary(String indexName, String siteName, String path, org.springframework.core.io.Resource resource, Map<String, Object> additionalFields) voidPerforms 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 fieldvoidsetLocalIdFieldName(String localIdFieldName) voidsetScrollSize(int scrollSize) voidsetScrollTimeout(String scrollTimeout) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
searchFieldin 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:
searchIdin interfaceOpenSearchService
-
index
- Specified by:
indexin 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:
indexin 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:
indexBinaryin 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:
indexBinaryin interfaceOpenSearchService- Throws:
OpenSearchException
-
delete
Performs a delete for the given document- Specified by:
deletein 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:
refreshin 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:
closein interfaceAutoCloseable- Throws:
Exception
-