ElasticDB
ElasticDB is a base class used to connect an Elasticsearch database and manages queries.
- class DIRAC.Core.Base.ElasticDB.ElasticDB(dbname, fullName, indexPrefix='', parentLogger=None)
Bases:
DIRAC.Core.Base.DIRACDB.DIRACDB
,DIRAC.Core.Utilities.ElasticSearchDB.ElasticSearchDB
Class for interfacing DIRAC ES DB definitions to ES clusters
- RESULT_SIZE = 10000
- __init__(dbname, fullName, indexPrefix='', parentLogger=None)
c’tor
- Parameters
- bulk_index(indexPrefix, data=None, mapping=None, period='day', withTimeStamp=True)
- Parameters
- Returns
S_OK/S_ERROR
- clusterName = ''
- createIndex(indexPrefix, mapping=None, period='day')
- deleteByQuery(indexName, query)
Delete data by query (careful!)
- deleteDoc(index: str, id: str)
Deletes a document in an index.
- Parameters
index – name of the index
id – document ID
- existingIndex(indexName)
Checks the existance of an index, by its name
- Parameters
indexName (str) – the name of the index
- Returns
S_OK/S_ERROR if the request is successful
- existsDoc(index: str, id: str) bool
Returns information about whether a document exists in an index.
- Parameters
index – name of the index
id – document ID
- static generateFullIndexName(indexName, period)
Given an index prefix we create the actual index name.
- getCSOption(optionName, defaultValue=None)
- getDoc(index: str, id: str) dict
Retrieves a document in an index.
- Parameters
index – name of the index
id – document ID
- getDocTypes(indexName)
Returns mappings, by index.
- Parameters
indexName (str) – is the name of the index…
- Returns
S_OK or S_ERROR
- getIndexPrefix()
It returns the DIRAC setup.
- getIndexes(indexName=None)
It returns the available indexes…
- getUniqueValue(indexName, key, orderBy=False)
- index(indexName, body=None, docID=None, op_type='index')
- pingDB()
Try to connect to the database
- Returns
S_OK(TRUE/FALSE)
- query(index, query)
Executes a query and returns its result (uses ES DSL language).
- update(index, query=None, updateByQuery=True, id=None)
Executes an update of a document, and returns S_OK/S_ERROR