elastic / elasticsearch-js

Official Elasticsearch client library for Node.js
https://ela.st/js-client
Apache License 2.0
29 stars 731 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 1 year 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 1 year ago

This enhancement request for SearchRequest is still valid

github-actions[bot] commented 9 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 9 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 4 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.

github-actions[bot] commented 1 month 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.