Elasticsearch Developer toolThis 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". Features
DemoCheckout the demo project https://github.com/Crasnam/vscode-elasticdeveloper/tree/master/demo/eslorem for examples. DescriptionEnvironmentThis 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.
PingThis action will check that the environment is reachable. Set as targetThis action will set the selected environment as target and preceding queries will use this environment. ExploreWith 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 templateIndex template can be created in files with extension esind. The deployed index template will use the filename as name.
DeployThis action will deploy the index template to the target environment. RetractThis action will delete the index template from the target environment, this will not delete any existing indices created from the index template. CompareCompare action will compare the deployed index template with the index template file that exists in the workspace. Create fileCreate file action will create a file from the deployed index template. This file can then be saved in the workspace. QueryQueries can be created in a file with the extension esquery and a file can contain more than one query.
Run QueryThis code lens action will run the active query. Run all queriesThis action will run all queries in a selected esquery file. Run BulkThe 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 APIAutocomplete for Elasticsearch REST endpoints bodyThe 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 documentationWhen a query has a valid endpoint a new code lens will be added and clicking on this will open the endpoint documentation.
Named queryA 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.
ConfigureBy 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 queriesWhen using a configuration object this object will get a "Run all queries". OutputBy 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.
HTMLBeside 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.
Example./query.esquery
./query.html
Saving response as both HTML and JSONIt is possible to apply HTML transformation and save the JSON file by specifying multiple file extensions.
Use a web browserIf 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"
|