Closed
Description
🚀 Feature Proposal
A more newbie friendly example on the readme.md page
Motivation
As a new user, I found it hard to get the example working. When searching for a library to use the code not working first time is annoying and might make me try another library or just not bother and use HTTP.
The reason it didn't work is because it tries to do a POST request in a search query, returning a 400 response code. I suggest changing this to a GET request, and putting an example document in the index to begin with.
Example
Here is an example:
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
// promise API
async function main() {
await client.index({
index: 'example-index',
body: { counter: 1 }
})
const result = await client.search({
index: 'example-index',
q: 'counter:1'
});
console.log(result.body.hits.hits[0]);
};
main();
Metadata
Metadata
Assignees
Labels
No labels