You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem?
Create a 'Prepared Statement Like' API that will allow users to submit a DDL / DML query to a search template (similar to the existing DSL search template API )
What solution would you like?
This solution will allow creation of both DML / DDL SQL queries that would be parameterized templates with the ability to be called by users (similar to RDBMS's prepared statements support)
The next API will be used (similar to the existing DSL search query API)
This command defines a search template to generate a view by using a parameterized query. The {{client_ip}} in the query is replaced by the value 10.40.40.10.:
GET _search/template
{
"source": {
"query":
"CREATE MATERIALIZED VIEW alb_logs_raw
AS
SELECT
UNIX_MILLIS(time) AS timestamp,
request_verb AS requestVerb,
request_url AS requestUrl,
target_status_code AS statusCode,
received_bytes AS receivedBytes,
sent_bytes AS sentBytes
FROM alb_logs_temp
WHERE client_ip = {{client_ip}}"
}
}
},
"params": {
"client_ip": "10.40.40.10"
}
}
After the search template works the way you want it to, you can save the source of that template as a script, making it reusable for different input parameters.
When saving the search template as a script, you need to specify the lang parameter as mustache:
POST _scripts/create_view_alb_logs_template
{
"script": {
"lang": "mustache",
"source":
"CREATE MATERIALIZED VIEW alb_logs_raw
AS
SELECT
UNIX_MILLIS(time) AS timestamp,
request_verb AS requestVerb,
request_url AS requestUrl,
target_status_code AS statusCode,
received_bytes AS receivedBytes,
sent_bytes AS sentBytes
FROM alb_logs_temp
WHERE client_ip = {{client_ip}}"
}
}
},
"params": {
"client_ip": "10.40.40.10"
}
}
Now you can reuse the template by referring to its id parameter. You can reuse this source template for different input values.
Is your feature request related to a problem?
Create a 'Prepared Statement Like' API that will allow users to submit a DDL / DML query to a search template (similar to the existing DSL search template API )
What solution would you like?
This solution will allow creation of both DML / DDL SQL queries that would be parameterized templates with the ability to be called by users (similar to RDBMS's prepared statements support)
The next API will be used (similar to the existing DSL search query API)
This command defines a search template to generate a view by using a parameterized query. The {{client_ip}} in the query is replaced by the value 10.40.40.10.:
After the search template works the way you want it to, you can save the source of that template as a script, making it reusable for different input parameters.
When saving the search template as a script, you need to specify the lang parameter as mustache:
Now you can reuse the template by referring to its id parameter. You can reuse this source template for different input values.
What alternatives have you considered?
N/A
Do you have any additional context?
The text was updated successfully, but these errors were encountered: