Stack Management elasticsearch-js client migration #73973
Labels
chore
Team:Kibana Management
Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Summary
Per #83910, the new elasticsearch-js client is available in Kibana and we need to migrate our apps over to it prior to 7.14.
Learn more about the new elasticsearch-js client at https://github.com/elastic/elasticsearch-js.
See the ES JS client API reference.
Punch list
Apps
Alison
Yulia
JL
CJ
es_ui_shared
, I don't think this needs migration other than the deleting the legacyisEsError
function once all of our plugins have been migrated and we no longer use itHow to migrate
📚 Be prepared! Review the migration guide.
Basic steps
import { LegacyAPICaller } from 'src/core/server'
withimport { ElasticsearchClient } from 'kibana/server'
.LegacyAPICaller
(commonly namedcallAsCurrentUser
) withElasticsearchClient
(commonly namedclient
).transport.request
with direct calls to the APIs defined on the new client (see API docs).context.core.elasticsearch.legacy.client.callAsCurrentUser
with references tocontext.core.elasticsearch.client.asCurrentUser
.Handling errors
When handling errors, replaces usage of
lib.isEsError(e)
with a comparison ofe.name === 'ResponseError'
and replace usage of:with:
Per #84801, test the app and verify that full ES errors are surfaced in the UI via
SectionError
, if applicable.API integration tests
getService('legacyEs')
togetService('es')
.es
service now returns a promise that resolves to an object containing thebody
. So any helper functions that consume this API likeconst getIndex = (index) => es.indices.get({ index });
will need to be migrated to handle the resolved promise and pull out the body: ``const getIndex = (index) => es.indices.get({ index }).then(({ body }) => body);`.Functional tests
We also need to migrate functional tests over from using the
legacyEs
service to thees
service. This means replacing instances ofgetService('legacyEs')
withgetService('es')
, and ensuring that the required APIs are available.Once you're done
The text was updated successfully, but these errors were encountered: