public class ElasticSearchDataContext extends AbstractElasticSearchDataContext
SimpleTableDef class.dynamicTableDefinitions, indexName, staticTableDefinitions, TIMEOUT_SCROLLINFORMATION_SCHEMA_NAME, SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS| Constructor and Description |
|---|
ElasticSearchDataContext(org.elasticsearch.client.Client client,
String indexName)
Constructs a
ElasticSearchDataContext and automatically detects
the schema structure/view on all indexes (see
detectTable(ClusterState, String, String)). |
ElasticSearchDataContext(org.elasticsearch.client.Client client,
String indexName,
SimpleTableDef... tableDefinitions)
Constructs a
ElasticSearchDataContext. |
| Modifier and Type | Method and Description |
|---|---|
protected SimpleTableDef[] |
detectSchema()
Performs an analysis of the available indexes in an ElasticSearch
cluster instance and detects the elasticsearch types structure
based on the metadata provided by the ElasticSearch java client.
|
static SimpleTableDef |
detectTable(org.elasticsearch.cluster.ClusterState cs,
String indexName,
String documentType)
Performs an analysis of an available index type in an ElasticSearch
Client client and tries to detect the index structure based on
the metadata provided by the java client. |
protected Number |
executeCountQuery(Table table,
List<FilterItem> whereItems,
boolean functionApproximationAllowed)
Executes a simple count query, if possible.
|
protected Row |
executePrimaryKeyLookupQuery(Table table,
List<SelectItem> selectItems,
Column primaryKeyColumn,
Object keyValue)
Executes a query which obtains a row by primary key (as defined by
Column.isPrimaryKey()). |
UpdateSummary |
executeUpdate(UpdateScript update)
Submits an
UpdateScript for execution on the DataContext. |
org.elasticsearch.client.Client |
getElasticSearchClient()
Gets the
Client that this DataContext is wrapping. |
protected DataSet |
materializeMainSchemaTable(Table table,
List<Column> columns,
int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class.
|
protected DataSet |
materializeMainSchemaTable(Table table,
List<SelectItem> selectItems,
List<FilterItem> whereItems,
int firstRow,
int maxRows)
Execute a simple one-table query against a table in the main schema of the subclasses of this class.
|
protected void |
onSchemaCacheRefreshed()
Method invoked when schemas have been refreshed using
AbstractDataContext.refreshSchemas(). |
getIndexName, getMainSchema, getMainSchemaName, limitMaxRowsIsSet, sortTablesaddConverter, executeQuery, getDefaultSchemaName, getSchemaByNameInternal, getSchemaNamesInternal, isMainSchemaTable, isScalarFunctionMaterialized, materializeFromItem, materializeMainSchemaTable, materializeMainSchemaTableSelect, materializeTablecompileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, parseQuery, query, refreshSchemasclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompileQuery, executeQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemaspublic ElasticSearchDataContext(org.elasticsearch.client.Client client,
String indexName,
SimpleTableDef... tableDefinitions)
ElasticSearchDataContext. This constructor accepts a
custom array of SimpleTableDefs which allows the user to define
his own view on the indexes in the engine.client - the ElasticSearch clientindexName - the name of the ElasticSearch index to representtableDefinitions - an array of SimpleTableDefs, which define the table
and column model of the ElasticSearch index.public ElasticSearchDataContext(org.elasticsearch.client.Client client,
String indexName)
ElasticSearchDataContext and automatically detects
the schema structure/view on all indexes (see
detectTable(ClusterState, String, String)).client - the ElasticSearch clientindexName - the name of the ElasticSearch index to representprotected SimpleTableDef[] detectSchema()
AbstractElasticSearchDataContextdetectSchema in class AbstractElasticSearchDataContextpublic static SimpleTableDef detectTable(org.elasticsearch.cluster.ClusterState cs, String indexName, String documentType) throws Exception
Client client and tries to detect the index structure based on
the metadata provided by the java client.cs - the ElasticSearch clusterindexName - the name of the indexdocumentType - the name of the index typeExceptionprotected DataSet materializeMainSchemaTable(Table table, List<SelectItem> selectItems, List<FilterItem> whereItems, int firstRow, int maxRows)
QueryPostprocessDataContextQueryPostprocessDataContext.materializeMainSchemaTable(Table, List, int, int) and apply WHERE item
filtering afterwards.materializeMainSchemaTable in class QueryPostprocessDataContextprotected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows)
QueryPostprocessDataContextmaterializeMainSchemaTable in class QueryPostprocessDataContexttable - the table to querycolumns - the columns of the table to querymaxRows - the maximum amount of rows needed or -1 if all rows are wanted.protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn, Object keyValue)
QueryPostprocessDataContextColumn.isPrimaryKey()). This method is
provided to allow subclasses to optimize lookup queries since they are quite common and often a datastore can
retrieve the row using some specialized means which is much more performant than scanning all records manually.executePrimaryKeyLookupQuery in class QueryPostprocessDataContexttable - the table on which the lookup is requested.selectItems - the items to select from the lookup query.primaryKeyColumn - the column that is the primary keykeyValue - the primary key value that is specified in the lookup query.protected Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed)
QueryPostprocessDataContextexecuteCountQuery in class QueryPostprocessDataContexttable - the table on which the count is requested.whereItems - a (sometimes empty) list of WHERE items.functionApproximationAllowed - whether approximation is allowed or not.public UpdateSummary executeUpdate(UpdateScript update)
UpdateableDataContextUpdateScript for execution on the DataContext.
Since implementations of the DataContext vary quite a lot, there
is no golden rule as to how an update script will be executed. But the
implementors should strive towards handling an UpdateScript as a
single transactional change to the data store.update - the update script to executeprotected void onSchemaCacheRefreshed()
AbstractDataContextAbstractDataContext.refreshSchemas(). Can be overridden to add
callback functionality in subclasses.onSchemaCacheRefreshed in class AbstractDataContextpublic org.elasticsearch.client.Client getElasticSearchClient()
Client that this DataContext is wrapping.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.