public class ElasticSearchDataContext extends QueryPostprocessDataContext implements DataContext
SimpleTableDef
class.Modifier and Type | Field and Description |
---|---|
static String |
FIELD_ID |
static org.elasticsearch.common.unit.TimeValue |
TIMEOUT_SCROLL |
INFORMATION_SCHEMA_NAME
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
#detectSchema(Client) ). |
ElasticSearchDataContext(org.elasticsearch.client.Client client,
String indexName,
SimpleTableDef... tableDefs)
Constructs a
ElasticSearchDataContext . |
Modifier and Type | Method and Description |
---|---|
static SimpleTableDef[] |
detectSchema(org.elasticsearch.client.Client client,
String indexName)
Performs an analysis of the available indexes in an ElasticSearch cluster
Client 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() ). |
protected Schema |
getMainSchema() |
protected String |
getMainSchemaName() |
protected DataSet |
materializeMainSchemaTable(Table table,
Column[] columns,
int maxRows)
Executes a simple one-table query against a table in the main schema of
the subclasses of this class.
|
addConverter, executeQuery, getDefaultSchemaName, getMainSchemaInternal, getSchemaByNameInternal, getSchemaNamesInternal, isMainSchemaTable, materializeFromItem, materializeMainSchemaTable, materializeMainSchemaTable, materializeTable
compileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, parseQuery, query, refreshSchemas
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compileQuery, executeQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
public static final String FIELD_ID
public static final org.elasticsearch.common.unit.TimeValue TIMEOUT_SCROLL
public ElasticSearchDataContext(org.elasticsearch.client.Client client, String indexName, SimpleTableDef... tableDefs)
ElasticSearchDataContext
. This constructor accepts a
custom array of SimpleTableDef
s 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 representtableDefs
- an array of SimpleTableDef
s, 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
#detectSchema(Client)
).client
- the ElasticSearch clientindexName
- the name of the ElasticSearch index to representpublic static SimpleTableDef[] detectSchema(org.elasticsearch.client.Client client, String indexName)
Client
instance and detects the elasticsearch types structure
based on the metadata provided by the ElasticSearch java client.client
- the client to inspectindexName2
- detectTable(ClusterState, String, String)
public 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 typeException
protected Schema getMainSchema() throws MetaModelException
getMainSchema
in class QueryPostprocessDataContext
MetaModelException
protected String getMainSchemaName() throws MetaModelException
getMainSchemaName
in class QueryPostprocessDataContext
MetaModelException
protected DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows)
QueryPostprocessDataContext
materializeMainSchemaTable
in class QueryPostprocessDataContext
table
- 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)
QueryPostprocessDataContext
Column.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 QueryPostprocessDataContext
table
- 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)
QueryPostprocessDataContext
executeCountQuery
in class QueryPostprocessDataContext
table
- the table on which the count is requested.whereItems
- a (sometimes empty) list of WHERE items.functionApproximationAllowed
- whether approximation is allowed or not.Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.