Skip to content

Script Development / Connector Object DFF.CONN / Elasticsearch

The Elasticsearch connector operation object mainly provides methods for operating Elasticsearch.

This connector connects via the HTTP protocol

DFF.CONN(...) parameters are as follows:

Parameter Type Required / Default Description
connector_id str Required Connector ID
timeout int/float 10 Default HTTP request timeout for the current operation object, in seconds

.query(...)

Send an HTTP request to Elasticsearch with the following parameters:

Parameter Type Required / Default Description
method str Required Request method, such as GET, POST; it can also be written as "GET /path"
path str None Request path; when omitted, it is split from method
query dict None URL query parameters
body dict None JSON request body
timeout int/float None Timeout for this request; when omitted, the operation object's default value is used
Example
1
2
3
result = db.query('GET', '/some_index/_search?q=some_field:something')
result = db.query('GET', '/some_index/_search', query={...})
result = db.query('GET', '/some_index/_search', body={...})

The connector automatically adds the format=json query parameter. When the response is JSON or XML, the parsed object is returned; otherwise, raw bytes are returned. When the HTTP status code is greater than or equal to 400, an exception is thrown.

For specific query syntax and formats, please refer to the official Elasticsearch documentation.