Skip to content

Instantly share code, notes, and snippets.

@dnek

dnek/index.js

Created Dec 6, 2019
Embed
What would you like to do?
Firebase Cloud Functions x ElasticSearch
const functions = require('firebase-functions')
const { Client } = require('@elastic/elasticsearch')
const config = {
cloud: {
id: 'xxx'
},
auth: {
username: 'xxx',
password: 'xxx'
}
}
const client = new Client(config)
exports.mySearchFunc = functions.region('asia-northeast1').https.onCall(async (data, context) => {
const result = await client.search({
index: 'xxx',
body: {
query: {
match_all: {}
}
}
}).catch(console.log)
return result.body.hits.hits
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.