is it possible to set a query to one or more datasources elastic search from the code of my custom panel type plugin?
If you are asking if you can issue queries to other active datasources from a panel, yes. It’s possible. Both from config in the query editor, or from your code directly.
Look at this api for querying a datasource from code: Data source HTTP API | Grafana Labs
This api only works with backend datasources though.
Am I understanding your use case correctly?