Elasticsearch Developer tool
This is a vscode extension that I have built to make it easier to work with Elasticsearch queries. This is also my first vscode extension so there is probably some "undocumented features".
Checkout the demo project https://github.com/Crasnam/vscode-elasticdeveloper/tree/master/demo/eslorem for examples.
This is an Elasticsearch server and should be created in a file with extension esenv, see below for an example. It is possible to have multiple environments in a workspace but these must be separate files.
This action will check that the environment is reachable.
Set as target
This action will set the selected environment as target and preceding queries will use this environment.
With the explorer view it possible to navigate environments and view existing index, mappings, aliases, scripts and index templates. It's also possible to retreive index settings and statistics.
Index template can be created in files with extension esind. The deployed index template will use the filename as name.
This action will deploy the index template to the target environment.
This action will delete the index template from the target environment, this will not delete any existing indices created from the index template.
Compare action will compare the deployed index template with the index template file that exists in the workspace.
Create file action will create a file from the deployed index template. This file can then be saved in the workspace.
Queries can be created in a file with the extension esquery and a file can contain more than one query.
This code lens action will run the active query.
Run all queries
This action will run all queries in a selected esquery file.
The extension has support for the Bulk API and will manage the conversion of multiple bodies to the NDJSON format, see the file populate_bulk.esquery in the demo project for an example.
Autocomplete for Elasticsearch REST API
Autocomplete for Elasticsearch REST endpoints body
The extension will when possible show intellisense when creating a body for a supported endpoint. This feature is not fully implemented on all endpoints and versions for Elasticsearch, I'm working on it.
Open REST API documentation
When a query has a valid endpoint a new code lens will be added and clicking on this will open the endpoint documentation.
A named query give you the possiblity to easier identify queries when using the "Run all queries" action and using HTML transformations. The name should be JSON firendly because the name will be added as a property on the response object.
By defining a configuration object in an esquery file it is possible to manage the input to all queries in the current file. This is useful when you want to test a search and also see how different analyzers analyze the same input.
Run all queries
When using a configuration object this object will get a "Run all queries".
By default elasticdeveloper extension will always create a temp file for the response. With the help of a configuration object it is possible to create a fixed output. The example below will save the response from Elasticsearch in the file query.json with the same path as the esquery file.
Beside saving the response in a JSON file the extension can also transform and save the response as a HTML file. This is done with Handlebars http://handlebarsjs.com/. This will give you a more visual and readable overview of the response, this depends on your "HTML/css/design skills" ;)
For this to work you need to create your own HTML template file that has the same name and path as the esquery file.
In the configuration object set the output to an file with HTML file extension. Use a different name on the output so it does not match the HTML template file so you dont overwrite your HTML template.
Saving response as both HTML and JSON
It is possible to apply HTML transformation and save the JSON file by specifying multiple file extensions.
Use a web browser
If you use this in combination with a web browser you can have much larger workspace. You will need a debbuger extension for an browser and then you can add a configuration in .vscode/launch.json that should launch your browser with the output file.
Example configuration for "Debugger for FireFox"