Description
🚀 Feature Proposal
Implement the same type of TypeScript generics for search responses as can be seen in the elastic javascript client, where it's possible to define the results type of the response.
Motivation
At the moment, the type definition of the results part of a search response is defined as results: Array<{}>;
. Comparing with the elasticsearch js client, which we sadly doesn't seem to be able to use since we use the enterprise app search. The way they have solved this looks like a better approach in my opinion.
They seem to be using the Elasticsearch specification repo for this, at least according to their docs.
For context, we are utilizing the node js client in our project.
Example
interface Document {
character: string
quote: string
}
const result= await client.search<Document>({
index: 'game-of-thrones',
query: {
match: { quote: 'winter' }
}
})
The above would return the same response type as is currently implemented, but also with the results array typed with the Document interface.