Skip to content

Instantly share code, notes, and snippets.

@quoeamaster
Created July 3, 2018 07:13
Show Gist options
  • Save quoeamaster/61eb8581849f37e985007e771e133b9c to your computer and use it in GitHub Desktop.
Save quoeamaster/61eb8581849f37e985007e771e133b9c to your computer and use it in GitHub Desktop.
medium - node example 00
// import the 'elasticsearch' package / library
var elasticsearch = require('elasticsearch');
// connect to a node (localhost:9200
var client = new elasticsearch.Client({
host: 'localhost:9200'
});
// run a query
client.search({
index: 'product_index',
type: 'doc',
body: {
query: {
match: {
'product_desc': 'sports shoes with yellow shoe laces'
}
}
}
}, function(error) {
if (error) {
console.log("something wrong " + error);
} else {
console.log("query succeeded");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment