Patrick Lumenus
Patrick Lumenus

Reputation: 1722

ElasticSearch Typescript Support

I’m really new to ElasticSearch (picked it up a week ago). I’m trying to integrate it into one of my NodeJS applications. I’m using the guide here to implement it using Typescript.

From this page, it is saying I should define my own object interfaces to be used so that operations do not have a return type of any.

I want to ask how exactly I’m supposed to go about doing this? Do I need to define an interface for request body, response, and source for each document type I use in my implementation?

Like, do I need separate interfaces for doing match, multi_match, etc... queries, Responses, and Sources? Or is there a way to define a generic interface to work with all?

Thanks.

Upvotes: 7

Views: 5089

Answers (1)

Aaron Stuyvenberg
Aaron Stuyvenberg

Reputation: 3787

I've had success using the DefinitelyTyped ElasticSearch library.

I'd suggest leveraging those types, and then adding your own definitions for whatever you store (which will be returned to you from ElasticSearch in the _source object.

Upvotes: 2

Related Questions