public class ElasticSearchDataSetProvider extends Object implements DataSetProvider, DataSetDefRegistryListener
Data provider for an ElasticSearch server.
It's basically implemented as a REST client for querying an ElasticSearch server instance.
If a given type field is not explicitly mapped as a concrete dashbuilder datatype using the columns parameter, the implicit data type bindings are:
| ElasticSearch type | Dashbuilder type |
|---|---|
| string | TEXT ( if index value is analyzed ) or LABEL ( if index value is not_analyzed ) |
| float | NUMBER |
| double | NUMBER |
| byte | NUMBER |
| short | NUMBER |
| integer | NUMBER |
| long | NUMBER |
| token_count | LABEL |
| date | DATE |
| boolean | LABEL |
| binary | LABEL |
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,ElasticSearchClient> |
_clientsMap
Singleton clients for each data set definition..
|
protected Map<String,DataSetMetadata> |
_metadataMap
Backend cache map.
|
protected ElasticSearchClientFactory |
clientFactory |
protected IntervalBuilderDynamicDate |
intervalBuilderDynamicDate |
protected IntervalBuilderLocator |
intervalBuilderLocator |
protected org.slf4j.Logger |
log |
protected ElasticSearchQueryBuilderFactory |
queryBuilderFactory |
static int |
RESPONSE_CODE_OK |
protected StaticDataSetProvider |
staticDataSetProvider |
protected ElasticSearchValueTypeMapper |
typeMapper |
| Constructor and Description |
|---|
ElasticSearchDataSetProvider() |
ElasticSearchDataSetProvider(StaticDataSetProvider staticDataSetProvider,
IntervalBuilderLocator intervalBuilderLocator,
IntervalBuilderDynamicDate intervalBuilderDynamicDate) |
public static final int RESPONSE_CODE_OK
protected org.slf4j.Logger log
protected StaticDataSetProvider staticDataSetProvider
protected IntervalBuilderLocator intervalBuilderLocator
protected IntervalBuilderDynamicDate intervalBuilderDynamicDate
protected ElasticSearchClientFactory clientFactory
protected ElasticSearchValueTypeMapper typeMapper
protected ElasticSearchQueryBuilderFactory queryBuilderFactory
protected final Map<String,DataSetMetadata> _metadataMap
protected final Map<String,ElasticSearchClient> _clientsMap
public ElasticSearchDataSetProvider()
public ElasticSearchDataSetProvider(StaticDataSetProvider staticDataSetProvider, IntervalBuilderLocator intervalBuilderLocator, IntervalBuilderDynamicDate intervalBuilderDynamicDate)
public static ElasticSearchDataSetProvider get()
public void destroy()
public DataSetProviderType getType()
getType in interface DataSetProviderpublic DataSet lookupDataSet(DataSetDef def, DataSetLookup lookup) throws Exception
lookupDataSet in interface DataSetProviderExceptionprotected DataSet _lookupDataSet(ElasticSearchDataSetDef elDef, DataSetLookup lookup) throws Exception
Exceptionprotected ColumnFilter _getIntervalSelectionFilter(DataSetGroup intervalSel)
protected List<DataColumn> getAllColumns(DataSetMetadata metadata)
protected DataColumn getColumnById(DataSetMetadata metadata, String columnId)
protected boolean existColumn(DataSetMetadata metadata, String columnId)
protected void fillDataSetValues(ElasticSearchDataSetDef elDef, DataSet dataSet, SearchHitResponse[] hits) throws Exception
dataSet - The dataset instance to fill. Note that dataset columns must be added before calling this method.hits - The search result hits.Exceptionpublic boolean isDataSetOutdated(DataSetDef def)
isDataSetOutdated in interface DataSetProviderpublic DataSetMetadata getDataSetMetadata(DataSetDef def) throws Exception
getDataSetMetadata in interface DataSetProviderExceptionprotected Map<String,DataColumn> parseColumnsFromIndexMappings(IndexMappingResponse[] indexMappings, ElasticSearchDataSetDef def)
indexMappings - The mappings response from EL server.def - The data set definition.protected DataColumn parseColumnFromIndexMappings(ElasticSearchDataSetDef def, String indexName, String typeName, String fieldName, String format, FieldMappingResponse.FieldType fieldType, FieldMappingResponse.IndexType indexType)
protected String getColumnId(String index, String type, String field) throws IllegalArgumentException
IllegalArgumentExceptionprotected ColumnType getDataType(FieldMappingResponse.FieldType fieldType, FieldMappingResponse.IndexType indexType) throws IllegalArgumentException
Return the dashbuilder data type for a given ElasticSearch field type.
fieldType - The ElasticSearch field type..indexType - The index type for the field.IllegalArgumentException - If ElasticSearch core data type is not supported.protected long getRowCount(ElasticSearchDataSetDef elasticSearchDataSetDef) throws Exception
Exceptionpublic void onDataSetDefStale(DataSetDef def)
onDataSetDefStale in interface DataSetDefRegistryListenerpublic void onDataSetDefModified(DataSetDef oldDef, DataSetDef newDef)
onDataSetDefModified in interface DataSetDefRegistryListenerpublic void onDataSetDefRemoved(DataSetDef oldDef)
onDataSetDefRemoved in interface DataSetDefRegistryListenerpublic void onDataSetDefRegistered(DataSetDef newDef)
onDataSetDefRegistered in interface DataSetDefRegistryListenerprotected void remove(String uuid)
Copyright © 2017–2019 JBoss by Red Hat. All rights reserved.