public class ElasticsearchRepository extends Object implements IBigDataRepositorySPI
Modifier and Type | Field and Description |
---|---|
protected org.elasticsearch.action.bulk.BulkProcessor |
bulkProcessor
The
BulkProcessor instance shared with IBatchIndexer generated by this repository. |
protected org.elasticsearch.client.Client |
client |
protected ElasticsearchRepository |
repository |
Constructor and Description |
---|
ElasticsearchRepository() |
Modifier and Type | Method and Description |
---|---|
void |
addDocument(Document document)
Adds a
content to the index. |
void |
addIndex(Locale locale)
Adds the indices relative to the given locale in Elasticsearch.
|
void |
addOrUpdateDocumentType(DocumentType documentType)
Adds or updates a document type into managed indices.
|
void |
deleteDocumentsByFieldValue(String fieldId,
Collection<?> values)
Deletes
contents that are matched by one of the given values in the field of given field
identifier. |
void |
deleteDocumentsByFieldValue(String fieldId,
Object... values)
Deletes
contents that are matched by one of the given values in the field of given field
identifier. |
void |
deleteDocumentsByQuery(SearchQuery searchQuery)
Deletes
contents that are matched by the given search query.The search query's sorts ,
initial hit and maximum hit count will be
ignored. |
void |
deleteDocumentType(String documentTypeId)
Deletes a given document type from managed indices.
|
void |
deleteIndex(Locale locale)
Deletes the indices related to the given locale.
|
void |
destroy()
Destroy this repository and performs any required resource freeing.
|
protected void |
executeAsync(org.elasticsearch.action.ActionRequest request)
Sends a request to Elasticsearch to be executed asynchronously.
|
protected <T extends org.elasticsearch.action.ActionResponse> |
executeSync(org.elasticsearch.action.ActionRequestBuilder<?,T,?> request)
Executes a request to Elasticsearch synchronously and returns the response.
|
protected <T extends org.elasticsearch.action.ActionResponse> |
executeSync(org.elasticsearch.action.ActionRequestBuilder<?,T,?> request,
boolean remapException)
Executes a request to Elasticsearch synchronously and returns the response.
|
List<String> |
getAutoCompleteSuggestions(SearchQuery searchQuery,
AutoCompleteSuggestionConfig autoCompleteSuggestion)
Returns a list of auto complete suggestions for the given auto complete suggestion configuration and the search
query.
|
org.elasticsearch.client.Client |
getDelegate()
Returns the underlying Elasticsearch client of this repository.
|
DocumentType |
getDocumentType(String documentTypeId)
Returns the document type of the given identifier.
|
DocumentTypeField |
getDocumentTypeField(String documentTypeFieldFullId)
Return the document type field of the field that has the given identifier.
|
protected org.elasticsearch.action.search.SearchRequestBuilder |
getQuery(SearchQuery searchQuery)
Returns a search request builder based on the given
SearchQuery . |
String |
getSearchAliasName()
Returns the alias used for searching in lumis portal indices.
|
void |
init(String repositoryId)
Initializes this repository using the given
node as configuration. |
protected void |
logRequest(Object request)
Logs at debug level a request that will be sent to Elasticsearch.
|
ISearchResults |
search(SearchQuery searchQuery)
Runs the given
search query and returns the search results . |
IBatchIndexer |
startBatch()
Returns an indexer to perform bulk actions.
The caller must assure IBatchIndexer.close() is called after the desired bulk operations were
performed. |
void |
validate(SearchQuery searchQuery)
Checks is the given
search query is syntactically correct. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addDocument, deleteDocumentsByFieldValue, deleteDocumentsByFieldValue
protected org.elasticsearch.client.Client client
protected org.elasticsearch.action.bulk.BulkProcessor bulkProcessor
BulkProcessor
instance shared with IBatchIndexer
generated by this repository.startBatch()
protected ElasticsearchRepository repository
public void init(String repositoryId)
IBigDataRepositorySPI
node
as configuration.init
in interface IBigDataRepositorySPI
repositoryId
- the repository identifier.public String getSearchAliasName()
public void addIndex(Locale locale)
locale
- the locale the indices to be created refers to.public void deleteIndex(Locale locale)
locale
- the locale.public void destroy()
IBigDataRepositorySPI
destroy
in interface IBigDataRepositorySPI
public void addOrUpdateDocumentType(DocumentType documentType)
IBigDataRepository
addOrUpdateDocumentType
in interface IBigDataRepository
documentType
- the document type to be added.DocumentTypes
public void deleteDocumentType(String documentTypeId) throws PortalObjectNotFoundException
IBigDataRepository
deleteDocumentType
in interface IBigDataRepository
documentTypeId
- the document type identifier to be deleted.PortalObjectNotFoundException
- if the document type with the given identifier couldn't be found.public DocumentType getDocumentType(String documentTypeId) throws PortalObjectNotFoundException
IBigDataRepository
getDocumentType
in interface IBigDataRepository
documentTypeId
- the document type identifier.PortalObjectNotFoundException
- if the desired type does not exist.public DocumentTypeField getDocumentTypeField(String documentTypeFieldFullId) throws PortalObjectNotFoundException
IBigDataRepository
getDocumentTypeField
in interface IBigDataRepository
documentTypeFieldFullId
- the (full) identifier of the document type field.PortalObjectNotFoundException
- if the desired field does not exist.public IBatchIndexer startBatch()
IBigDataRepository
IBatchIndexer.close()
is called after the desired bulk operations were
performed.
Example of usage:
Or using try-with-resources:
startBatch
in interface IBigDataRepository
public void deleteDocumentsByQuery(SearchQuery searchQuery)
IBigDataIndexer
contents
that are matched by the given search query.sorts
,
initial hit
and maximum hit count
will be
ignored.deleteDocumentsByQuery
in interface IBigDataIndexer
searchQuery
- the search query.public ISearchResults search(SearchQuery searchQuery)
IBigDataSearcher
search query
and returns the search results
.search
in interface IBigDataSearcher
searchQuery
- the query to run.public List<String> getAutoCompleteSuggestions(SearchQuery searchQuery, AutoCompleteSuggestionConfig autoCompleteSuggestion)
IBigDataSearcher
getAutoCompleteSuggestions
in interface IBigDataSearcher
searchQuery
- the search query the auto complete request will be based on.autoCompleteSuggestion
- the auto complete suggestion request.public void validate(SearchQuery searchQuery) throws PortalException
IBigDataSearcher
search query
is syntactically correct.validate
in interface IBigDataSearcher
searchQuery
- the search query
to be validatedPortalException
- if there is a syntax error in query.public org.elasticsearch.client.Client getDelegate()
getDelegate
in interface IBigDataRepository
public void addDocument(Document document)
IBigDataIndexer
content
to the index.addDocument
in interface IBigDataIndexer
document
- the content
to be added.public void deleteDocumentsByFieldValue(String fieldId, Object... values)
IBigDataIndexer
contents
that are matched by one of the given values in the field of given field
identifier.deleteDocumentsByFieldValue
in interface IBigDataIndexer
fieldId
- the field identifier.values
- the values.public void deleteDocumentsByFieldValue(String fieldId, Collection<?> values)
IBigDataIndexer
contents
that are matched by one of the given values in the field of given field
identifier.deleteDocumentsByFieldValue
in interface IBigDataIndexer
fieldId
- the field identifier.values
- the values.protected org.elasticsearch.action.search.SearchRequestBuilder getQuery(SearchQuery searchQuery)
SearchQuery
.searchQuery
- the search query.SearchQuery
.protected <T extends org.elasticsearch.action.ActionResponse> T executeSync(org.elasticsearch.action.ActionRequestBuilder<?,T,?> request)
protected <T extends org.elasticsearch.action.ActionResponse> T executeSync(org.elasticsearch.action.ActionRequestBuilder<?,T,?> request, boolean remapException)
protected void executeAsync(org.elasticsearch.action.ActionRequest request)
protected void logRequest(Object request)
request
- the request object.Lumisportal 10.1.2.170428 - Copyright © 2006–2017 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.