Class ElasticSearchNativeClient
- java.lang.Object
-
- org.dashbuilder.dataprovider.backend.elasticsearch.rest.impl.ElasticSearchNativeClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable,ElasticSearchClient<ElasticSearchNativeClient>
public class ElasticSearchNativeClient extends Object implements ElasticSearchClient<ElasticSearchNativeClient>
The Dashbuilder's client implementation for the ElasticSearch data provider. It uses the native Java admin client from ElasticSearch.- Since:
- 0.5.0
-
-
Field Summary
Fields Modifier and Type Field Description protected StringclusterNameprotected static StringEL_CLIENT_TIMEOUTprotected static StringEL_CLUTER_NAMEprotected String[]indexprotected StringserverURLprotected longtimeoutprotected String[]type-
Fields inherited from interface org.dashbuilder.dataprovider.backend.elasticsearch.rest.ElasticSearchClient
HEADER_RESPONSE_CODE, RESPONSE_CODE_NOT_FOUND, RESPONSE_CODE_OK
-
-
Constructor Summary
Constructors Constructor Description ElasticSearchNativeClient(ElasticSearchClientFactory clientFactory, ElasticSearchValueTypeMapper valueTypeMapper, org.dashbuilder.dataset.IntervalBuilderDynamicDate intervalBuilderDynamicDate, ElasticSearchUtils utils)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()ElasticSearchNativeClientclusterName(String clusterName)Builds the client for a given cluster.CountResponsecount(String[] index, String... type)Count documents for a given index/es and type/esMappingsResponsegetMappings(String... index)Obtain the mappings for a given index/es.ElasticSearchNativeClientindex(String... indexes)Builds the client for a given index/es.SearchResponsesearch(org.dashbuilder.dataset.def.ElasticSearchDataSetDef definition, org.dashbuilder.dataset.DataSetMetadata metadata, SearchRequest request)Obtain documents for a given index/es and type/esElasticSearchNativeClientserverURL(String serverURL)Builds the client for a given serer URL.ElasticSearchNativeClientsetTimeout(int timeout)Sets the timeout value for the HTTP rest client requests.ElasticSearchNativeClienttype(String... types)Builds the client for a given types/es.
-
-
-
Field Detail
-
EL_CLUTER_NAME
protected static final String EL_CLUTER_NAME
- See Also:
- Constant Field Values
-
EL_CLIENT_TIMEOUT
protected static final String EL_CLIENT_TIMEOUT
- See Also:
- Constant Field Values
-
serverURL
protected String serverURL
-
clusterName
protected String clusterName
-
index
protected String[] index
-
type
protected String[] type
-
timeout
protected long timeout
-
-
Constructor Detail
-
ElasticSearchNativeClient
public ElasticSearchNativeClient(ElasticSearchClientFactory clientFactory, ElasticSearchValueTypeMapper valueTypeMapper, org.dashbuilder.dataset.IntervalBuilderDynamicDate intervalBuilderDynamicDate, ElasticSearchUtils utils)
-
-
Method Detail
-
serverURL
public ElasticSearchNativeClient serverURL(String serverURL)
Description copied from interface:ElasticSearchClientBuilds the client for a given serer URL.- Specified by:
serverURLin interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
serverURL- The ElasticSearch server URL.- Returns:
- The REST client for the given server URL.
-
index
public ElasticSearchNativeClient index(String... indexes)
Description copied from interface:ElasticSearchClientBuilds the client for a given index/es.- Specified by:
indexin interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
indexes- The ElasticSearch index/es.- Returns:
- The REST client for the given index/es.
-
type
public ElasticSearchNativeClient type(String... types)
Description copied from interface:ElasticSearchClientBuilds the client for a given types/es.- Specified by:
typein interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
types- The ElasticSearch types/es.- Returns:
- The REST client for the given types/es.
-
clusterName
public ElasticSearchNativeClient clusterName(String clusterName)
Description copied from interface:ElasticSearchClientBuilds the client for a given cluster.- Specified by:
clusterNamein interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
clusterName- The ElasticSearch cluster name.- Returns:
- The REST client for the given cluster.
-
setTimeout
public ElasticSearchNativeClient setTimeout(int timeout)
Description copied from interface:ElasticSearchClientSets the timeout value for the HTTP rest client requests.- Specified by:
setTimeoutin interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
timeout- The timeout value in miliseconds.
-
getMappings
public MappingsResponse getMappings(String... index) throws ElasticSearchClientGenericException
Description copied from interface:ElasticSearchClientObtain the mappings for a given index/es.- Specified by:
getMappingsin interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
index- The index/es to obtain the mappings.- Returns:
- The mappings for the given index/es
- Throws:
ElasticSearchClientGenericException
-
count
public CountResponse count(String[] index, String... type) throws ElasticSearchClientGenericException
Description copied from interface:ElasticSearchClientCount documents for a given index/es and type/es- Specified by:
countin interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
index- The index/es for the document type to count. If value isnullreturns the count number of all documents if all indexes.type- The type/s of the documents to count. If value isnullreturns the count number of all documents in all indexes or in the index specified byindex.- Returns:
- The number of documents for a given index/es and type/es
- Throws:
ElasticSearchClientGenericException
-
search
public SearchResponse search(org.dashbuilder.dataset.def.ElasticSearchDataSetDef definition, org.dashbuilder.dataset.DataSetMetadata metadata, SearchRequest request) throws ElasticSearchClientGenericException
Description copied from interface:ElasticSearchClientObtain documents for a given index/es and type/es
If the index/es value set in the
requestisnullreturns all documents of all indexes.If the type/s value set in the
requestisnullreturns all documents in all indexes or in the index specified byindex.- Specified by:
searchin interfaceElasticSearchClient<ElasticSearchNativeClient>- Parameters:
definition- The dataset definition.metadata- The metadata.request- The search request.- Returns:
- The number of documents for a given index/es and type/es
- Throws:
ElasticSearchClientGenericException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-