Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createIndex(product) {
- client.create({
- index: 'test-products',
- type: 'product',
- id: product._id.toHexString(),
- body: {
- SKU: product.SKU,
- Name: product.Name,
- Cost: product.Cost,
- supplierId: product.supplierId.toHexString()
- }
- }, function (error, response) {
- console.log('ERROR',error);
- console.log('RESPONSE',response);
- });
- }
- Product.find({},{},function(err,results){
- for (var i = 0; i < results.length; i++) {
- createIndex(results[i]);
- };
- });
- ////////////////////////////////////////////////////////////
- client.search({
- index: 'test-products',
- type: 'product',
- body: {
- "query": {
- "filtered": {
- "query": { "match": { "_all": 'W-814' }},
- "filter": {
- "bool": {
- "must": { "term": { "supplierId": '53a8a7299d3d147c39bd6ac9' }},
- }
- }
- }
- }
- }
- }).then(function (body) {
- res.send(body);
- }, function (error) {
- res.send(error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement