Skip to content

Instantly share code, notes, and snippets.

@dnek
Created December 6, 2019 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnek/439bf98463fb23689c6df94ff111ca9e to your computer and use it in GitHub Desktop.
Save dnek/439bf98463fb23689c6df94ff111ca9e to your computer and use it in GitHub Desktop.
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