-
Notifications
You must be signed in to change notification settings - Fork 0
/
elasticmore.js
61 lines (44 loc) · 986 Bytes
/
elasticmore.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const express = require('express')
const app = express()
const { Client } = require('@elastic/elasticsearch')
var resultfour =[]
const client = new Client({
node: 'https://elastic:Tn3nLz3YM5zPogCdmKHvWLLb@0187ecb4b77b4040a2fbb9ba408f7748.europe-west1.gcp.cloud.es.io:9243/',
})
client.search({
index: 'likedproducts',
body: {
query: {
bool:{
must: [
{
match_phrase:
{
"age.keyword": "30-35"
}
},
{
match_phrase:
{
"profession.keyword": "Medical"
}
}
]
}
},
}
}, (err, result) => {
console.log(result)
result.body.hits.hits.map(function(hit){
resultfour.push(hit)
})
}
)
var port = 5555
app.get('/results', function (req, res) {
res.send(resultfour)
})
var server = app.listen(port,function(){
console.log('listening to port 5555')
})
//export default resultfour