Created
July 3, 2018 07:13
-
-
Save quoeamaster/61eb8581849f37e985007e771e133b9c to your computer and use it in GitHub Desktop.
medium - node example 00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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