7

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.

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Ah. That’s actually better. Lol. Thanks.
Anyone know if this is still the best solution in 2022
hey! I should update this answer. Definitely Typed is still pretty good, but Elastic has released their own typescript library which is also very good: elastic.co/guide/en/elasticsearch/client/javascript-api/current/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.