Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const es = require('elasticsearch');
- const search = (search_keyword,data) => {
- const esClient = new es.Client({
- host: 'localhost:9200',
- log: 'trace'
- });
- esClient.indices.create({
- index: 'test',
- body: data,
- });
- esClient.search({
- index: 'test',
- body: {
- query: {
- multi_match : {
- query: search_keyword,
- fields: [ "id", "name", "snippet" ],
- operator:"or"
- }
- }
- }
- })
- };
- module.exports=search;
Advertisement
Add Comment
Please, Sign In to add comment