简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM