I finally seem to be at the stage where I understand how to build complex queries, bool, match_phrase_prefix, ids, etc.
However, it's still hard work to remember the exact syntax for each, so my approach is generally:
- build the query in Kibana using its autocomplete
- wrap the code in a helper function
- compose helper function outputs to build queries
However, with either raw POJOs or using the helpers there's not much support in my IDE.
I see that it is possible to get some kind of completion using TypeScript:
I have also installed the global types in WebStorm:
But completion seems to bottom out at the query stage:
Before I went looking for TS support, I had a play with building some type support + helpers, and it worked exactly as I hoped it could:
I could go forward from here and build out TS support for the small subset of features I use, but I figure this is what the Elastic TypeScript package should be doing, no?
I've attempted to import and set the definitions in
@elastic/elasticsearch/api in my
typeRoots but no luck:
"typeRoots": [ "node_modules/@elastic/elasticsearch", ]
My TS knowledge is pretty good (write and use generics, etc) but there are gaps (this possibly being one!).
Anyway... if you've read through all that, well done, and... what should I be doing to get both completion and type safety / warnings when building queries?