elastic / elasticsearch-js

Official Elasticsearch client library for Node.js
https://ela.st/js-client
Apache License 2.0
5.24k stars 727 forks source link

Using generics with SearchRequest #1805

Open twisha opened 1 year ago

twisha commented 1 year ago

How can I use generics with SearchRequest? I'd like to enforce compile-time check for my queries. Field type is string. Instead I'd prefer it to be key of T with SearchRequest<T>. Please help!

SearchApi definition from version 8.x of @elastic/elasticsearch npm package. export default function SearchApi<TDocument = unknown, TAggregations = Record<T.AggregateName, T.AggregationsAggregate>>(this: That, params?: T.SearchRequest | TB.SearchRequest, options?: TransportRequestOptions): Promise<T.SearchResponse<TDocument, TAggregations>>;

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

twisha commented 10 months ago

This enhancement request for SearchRequest is still valid

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

JoshMock commented 6 months ago

Reopening because this is still something we want to work on. I was on leave for 2 months so the stalebot got this one before I could keep it alive.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.