Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 файл
- const es = require('elasticsearch');
- const esClient = new es.Client({
- host: 'localhost:9200',
- log: 'trace'
- });
- const search = function search(index, body) {
- return esClient.search({index: index, body: body});
- };
- module.exports = search;
- 2 файл
- let body = {
- query: {
- match_all:
- {output}
- }
- };
- search('SAP', body)
- .then(results => {
- console.log(`found ${results.hits.total} items in ${results.took}ms`);
- console.log(`returned article titles:`);
- results.hits.hits.forEach((hit, index) => console.log(`\t${body.from + ++index} - ${hit._source.title}`));
- })
- .catch(console.error);
Advertisement
Add Comment
Please, Sign In to add comment