Giter VIP home page Giter VIP logo

vscode-elastic's Introduction

Elasticsearch for VSCode

.github/workflows/runTests.yaml .github/workflows/publish.yaml

Welcome to Elasticsearch for VSCode! An extension for developing elasticsearch queries.

shot

Using

  • Open an existing file with a .es file extenion or open a new text file (ctrl+n) and change the language mode to Elasticsearch (es) by pressing ctrl+k,m and select es. Elasticsearch queries and funtionalities are enabled in the es language mode in Visual Studio Code editor.
  • For https endpoints, just add protocol type in url : https://host
  • For auth protected clusters, you can use http://user:pass@host:9200 as the endpoint url to have it auth.

Submit requests

Simple way:

GET /my-index/_search
{
    "size":7,
    "query": {
        "match" : {
            "message" : {
                "query" : "this is a test"
            }
        }
    }
}

Get payload from file [#4]:

PUT /my-index
!./opt/elasticsearch/mapping.json

Commands

  • Elasticsearch: Set Host to create connection profile and connect.

Keymaps

  • Alt + Enter / Ctrl + Enter to execute selected query.

Roadmap

  • Work with multi host
  • User Authentication
  • IntelliSense like kibana autocomplete

vscode-elastic's People

Contributors

barnuri avatar barnuri-cp avatar geekpete avatar heatwave avatar hsen-dev avatar jgowdyelastic avatar jharting avatar maxenceg2m avatar stfujnkk avatar vymarkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-elastic's Issues

Option not to show "Run Query" lines in documents

I really like using ctrl+enter to execute the query and find that the "Run Query" text that appears in front of each query is quite distracting (both when it pops into place and just by being there). It would be nice if you could add an option to disable that so it doesn't appear and we can just run them with ctrl+enter.

Or even better an option to disable it plus a keyboard shortcut that would let us toggle this, so if you're using the mouse a lot you can toggle it on and have them appear temporarily.

Get Payload from File

Hey, awesome work on this.

I was wondering how difficult it would be to allow the following:

PUT /my-index
!./opt/elasticsearch/mapping.json

Where !./path will load the contents of a file and use that as the body payload?

Updating VS Code to 1.37.0 breaks all features

  • Cannot execute any query
    image

  • Cannot set ES host
    image

  • Cannot "auto-indent"
    image

  • Syntax highlighting looks incorrect
    image

  • Operating System:

macOS 10.14.6
  • VS Code:
Version: 1.37.0
Commit: 036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8
Date: 2019-08-08T01:22:37.660Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0

Uninstall and re-install the plugin does not help.

Close results tab with shortcut

I can't close the results tab using the default shortcut of ctrl + w. If I press it on another tab it works but not on the results tab. I have showResultAsDocument set to false.

Nothing happens after install

I have installed the extension. Opened a file .es and language switched to Elasticsearch.
I setted the ES Host.
What's the trick to make the run query command appear and the game to start?

Get payload from file raise not_x_content_exception - Content type not set?

Hi,

When I want to get payload from file - as specified in README - I got an "not_x_content_exception".

Query:

PUT /itunes-suggest
!./mapping.json

Response:

{
    "error": {
        "root_cause": [
            {
                "type": "not_x_content_exception",
                "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
            }
        ],
        "type": "not_x_content_exception",
        "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
    },
    "status": 500
}

VSCode version: 1.59.1
Extension version: v0.13.3

GET queries wont run without a body

It appears that the Run Query is disabled when there is no body in for a request

This will work fine:
works

This will not:
doesnt work

And it is the same whether I use the hot-key or hit the Run Query button.

Current Version: 0.13.2
VS Code Version: 1.24.1 on Windows

Add support for a host list

Persist some type of data so that a new host can be added such that you can select from a list of hosts when switching hosts. I typically need to switch from development environment to beta or production environments and having to retype the host is slightly annoying.

Also plugin is great replacement for the old sense plugin ๐Ÿ‘

Support multiline scripts

The dev console in Kibana allows scripts to contain line breaks, even though it's invalid JSON. You open and close the script with a triple quote: """

This make scripts far easier to read and write. It would be very useful if this plugin supported this.

Mishandling of large numbers

Documents with big numeric values are presented incorrectly (rendered number is incorrect).

Please see very similar issue here: jqlang/jq#1959

Steps to reproduce:

  1. Create an index with a field of the unsigned_long type
PUT /my-test-index-000001
{
  "mappings": {
    "properties": {
      "big_number": { "type": "unsigned_long" }
    }
  }
}
  1. Index some data
POST /my-test-index-000001/_doc
{
    "big_number": 1234
}
POST /my-test-index-000001/_doc
{
    "big_number": 1016950844191088640
}
  1. Query for the data
GET /my-test-index-000001/_search
{
    "size": 10
}

Here is a query result:
Screenshot_20221122_120052

Incorrect because 1016950844191088640 != 1016950844191088600

  1. You can try to search for a particular values to see how it is really indexed
    4.1 Searching for rendered value โ†’ no results
GET /my-test-index-000001/_search
{
    "query": {
        "term": {
            "big_number": 1016950844191088600
        }
    },
    "size": 10
}

4.1 Searching for indexed value โ†’ document found

GET /my-test-index-000001/_search
{
    "query": {
        "term": {
            "big_number": 1016950844191088640
        }
    },
    "size": 10
}

elastic.execute not found

Hello i am running vscode-elastic extension in my version of visual studio and i am receiving the error 'command elastic.execute not found' when trying to 'run query'. I am running on a Macbook.

In addition how do you change the elasticsearch instance configuration one submitted?

Thanks if anyone can help.

Add _msearch support

I use this often in kabana, I understand it's not valid json (which may make it hard), but support would be nice, if possible.

GET _msearch
{"index" : "index0"}
{ "query": { "multi_match": { "query":"test0" } } }
{"index" : "index1"}
{ "query": { "multi_match": { "query":"test1" } } }

Thanks

great extension,but how to format .es file

when I press alt+ shift + f
there is no formatter for .es file

or how could I use jsonc extension formatter?
also,I try to add settings.json
"[es]": {
"editor.defaultFormatter": "vscode.json-language-features"
}
but,no luck.I don't have much time for try something more,so I'm here to ask,thanks,bro.

elasticsearch for vscode error: socket hang up

Issue Type: Bug

can not run es query when I upgread vscode to 1.46.1 error message is socket hang up

Extension version: 0.13.3
VS Code version: Code 1.46.1 (cd9ea6488829f560dc949a8b2fb789f3cdc05f5d, 2020-06-17T21:13:20.174Z)
OS version: Windows_NT x64 10.0.18363

Highlighting not always working correctly

The highlighting doesn't show properly all the time. And then it works if I change something, even deleting an empty line and putting it back "resets" the highlighting, but then it stops working again a few minutes later. I'm not sure what's triggering the highlighting to go back to being wrong. This happens in different files. Using latest version of vscode and this extension.

It shows wrong in various parts of the file, like the highlighting of JSON object keys and values. And sometimes the method like GET or POST is showing without highlighting.

pic

Support AWS Signer

Hi,
How can I pass/configure below parameter to access elasticsearch
Region
Service
Access Key Id
Secret Access Key

Without that I'm seeing below error:
{
"Message": "User: anonymous is not authorized to perform: es:ESHttpGet"
}

This is working fine in Kibana plugin in browser and postman with the AWS Signature.

Bulk API call can't be terminated with newline

Hi,

when trying to do an bulk operation as described in the elasticsearch reference like this:

POST _bulk
{ "index" : { "_index" : "test", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_id" : "2" } }
{ "create" : { "_index" : "test", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }

it results in an error message like this:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "The bulk request must be terminated by a newline [\\n]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "The bulk request must be terminated by a newline [\\n]"
    },
    "status": 400
}

How can i tell the elastic search plugin for VSCode to append a newline character?

best regards,
JohT
PS.: Really great plugin btw.

License

Thanks for the great extension. Please add a license

host set with different es file

hi, thx for your powerful plugin. but i am wondering how to set different es file with different host. because i have so many es clusters. it is tedious to change host every time.

Is there a way to ignore TLS cert issue as well as curl's k option?

I'd like to connect to AWS Elasticsearch service host via vscode-elastic extension.

The AWS Elasticsearch service host

  • is hosted in internal network (AWS VPC internal), which is isolated from local network.
  • establishes TLS(HTTPS)

So, I

When I use curl command to access the Elasticsearch host, I create ssh tunnel first then use -k option to ignore the cert issue like the following.

curl -k -XGET https://localhost:7000/_cat/health

It can give me a 200 response.

How to see this issue

Make ssh tunnel via

ssh -f -N -L 7000:subdomain.ap-northeast-1.es.amazonaws.com:443 bastion-server-domain

Set the domain host for vscode-elastic extension.

image

Exec Run Query

image

I'd like to know if there's a way to ignore the cert issue as well as curl's k option.

Run query shortcut key not working in temporary file

The shortcut key to does not work when using a temporary file (not saving it).

If I Ctrl + Enter just a blank line is inserted. If I remap the key, VSCode tells me The key combination (...) is not a command. If I'm now saving this file, both the default and the remapped key binding works as expected.

Version 0.13.2

Output format option

Could we get the option to return the output as the raw JSON from Elasticsearch rather than the tree?

Post bulk request

Could we post bulk request?
Like this
POST /cars/transactions/_bulk
{ "index": {}}
{ "price" : 10000, "color" : "red", "make" : "honda", "sold" : "2014-10-28" }
{ "index": {}}
{ "price" : 20000, "color" : "red", "make" : "honda", "sold" : "2014-11-05" }
{ "index": {}}
{ "price" : 30000, "color" : "green", "make" : "ford", "sold" : "2014-05-18" }
{ "index": {}}
{ "price" : 15000, "color" : "blue", "make" : "toyota", "sold" : "2014-07-02" }
{ "index": {}}
{ "price" : 12000, "color" : "green", "make" : "toyota", "sold" : "2014-08-19" }
{ "index": {}}
{ "price" : 20000, "color" : "red", "make" : "honda", "sold" : "2014-11-05" }
{ "index": {}}
{ "price" : 80000, "color" : "red", "make" : "bmw", "sold" : "2014-01-01" }
{ "index": {}}
{ "price" : 25000, "color" : "blue", "make" : "ford", "sold" : "2014-02-12" }

Support bulk operations

Hi,

Thanks for this very useful plugin.

I'd like to use it to run bulk requests. These requests take a payload in the format of ndjson (newline delimited json) which is not recognized by your parser.

I would like to be able to run these queries to ingest some data, like in the following tutorial:
https://opensearch.org/docs/search-plugins/knn/approximate-knn/

I would hope to put my payload inline in the .es file (currently the parser will take into account only the first line of the payload and ignore the rest) and/or from an external file (currently I get an "invalid json" error).
image

If reading from an external "ndjson" file is easier, I'm ok with it
image

Thanks in advance

extension seems not to work on Linux

I can neither set the host address with the command ES: Elastic: Set Host
command 'elastic.setHost' not found
nor can I, after manually configuring the host in a .esenv file, make a query run
command 'elastic.execute' not found

I am on Ubuntu 18.04.1 LTS
VSCode is 1.31.0
Elasticsearch for VSCode is 0.13.3

Reinstalling the extension did not resolve the issue.

getaddrinfo error

Dear,

My es version is 7.7.0 and open authorization. after check you docs said, i need to use http://user:pass@ip:9200 connection way. after i set host and run query, the tools reports getaddrinfo error.
would you please let me know, how to fix this issue.

Many thank.

Allow ctrl+enter to run command

To be consistent with kibana's dev tools console and many other programs, ctrl+enter should be able to run the command (instead of or in addition to alt+enter).

Https

This looks awesome. Is it possible to specify protocol? Trying to use it against elastic instance at cloud.elastic.co but only getting econnreset.

Cant change es host

Can't change the es host for file. How and where to execute this command?

Name:
elastic.setHost

Description:
Elastic: Set Host

Conditional Clauses causes invalid JSON

From the docs elastic search use conditional clauses for search templates.

Doing this with the extension installed causes "Invalid Json" and prevents the query able to be executed.

No hits bug

When i put : localhost:9200 in set host, it works perfectly. But when I put localhost:9200 strange things start to happen.

Expected Behaviour :

image

I get no hits when i add /:

image

HTTPS - Certificate Error

Hi,

First off thank you for your time developing this plugin.

When trying to connect to my private ES instance in AWS I am getting a certificate error

unable to verify the first certificate

I checked the root certificate is added to Windows OS and I am able to connect to it via browser just fine.

Is there a different certificate store I have to add this to?

Or is there a way I can troubleshoot this differently to find out the problem, the error doesn't provide much context.

image

Thank you!

Update of Elastic references

G'Day!
Our style guide does ask that users not change the colouring and it'd be great if you could please update the Elastic logo you are using, as seen here.

It'd also be awesome if you could change Elastic for Visual Studio Code to Elasticsearch for Visual Studio Code to make it clear it's for the Elasticsearch product :)

Thanks,
Mark (from Elastic)

Query string parameters not supported

I noticed that if I add querystring parameters to my query, the plugin does not recognize my block as a valid Elasticsearch query.

For example, this works fine:

GET /vision/tags/_search
{
  "size" : 0,
  "aggs" : {
    "distinct_tags" : {
      "terms": {
        "field": "tag",
        "size": 10
      }
    }
  }
}

...but this breaks:

GET /vision/tags/_search?filter_path=aggregations.distinct_tags.buckets
{
  "size" : 0,
  "aggs" : {
    "distinct_tags" : {
      "terms": {
        "field": "tag",
        "size": 10
      }
    }
  }
}

Thanks.

Hangs when Executing Query

This appears to have happened with the most recent update.

When I try to execute a query, the executing query message appears in the status bar, but it never returns results and no error message ever appears.

I've attempted to use different hosts. I have also tried prefixing the host with http://.

I'm using version 1.24.1 of VS Code with version 0.13.1 of the plugin.

Nothing appears when "elastic.showResultAsDocument" is false

When setting "elastic.showResultAsDocument": false, no results appear. But the command does get executed. Only if setting to the default of true do results appear.

I see there's been no activity in this repo or issues for a long time. Is this project still maintained?

fix secret and publish the extension

please fix the secert in the report and make github actions works, and publish the new version of the extenstion
secret name : VSCE_PAT
https://github.com/hsen-dev/vscode-elastic/runs/6241944196?check_suite_focus=true

info from my pr:

you can also make the github action that run test to be required
https://docs.codemagic.io/configuration/github-checks/

and dont forget to make a github secret to make the publish github action work
add secert named VSCE_PAT (https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token)
https://docs.github.com/en/actions/security-guides/encrypted-secrets

if you need any help you can contact with me :)

Parse error when non-json result (e.g. _cat/)

When the setting elastic.showResultAsDocument is set to true (default), running queries list _cat
(where result us not JSON format) will cause a parse error when parsing result. think it is here

Can be good to support this and also there is no message or other indication that the query didn't succeed.

Better error reporting

Great work on the tool it already works incredibly well :).

A suggestion for an improvement I would like would to have more explicit error communication.

For instance I am getting an "invalid Json" error, but I cannot tell, where the error is occuring.

Support SSL Encrypted Clusters

SSL protected clusters can be X-Pack or some other mechanism.

Not sure how this would be managed, configuration-wise, but it would allow testing against my actual data, instead of limiting me to unencrypted clusters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.