I am using Firebase function to push data to ElasticSearch to be indexed. But sometimes the data set is not indexed completely. Which fields can be indexed seem to be a random behavior, sometimes all fields are indexed, sometimes only a few, sometimes only one.
The firebase function I used to push data to Elastic search as below:
exports.indexHashtagsToElastic = functions.database.ref('/valid_hashtags/{hashtag_id}')
.onWrite(event =>{
let hashtagData = event.data.val();
let hashtag_id = event.params.hashtag_id;
console.log('Indexing the hashtags: ', hashtagData);
let elasticSearchConfig = functions.config().elasticsearch;
let elasticSearchUrl = elasticSearchConfig.url + 'hashtags/hashtag/' + hashtag_id;
let elasticSearchMethod = hashtagData ? 'POST' : 'DELETE';
let elasticSearchRequest = {
method: elasticSearchMethod,
url: elasticSearchUrl,
auth:{
username: elasticSearchConfig.username,
password: elasticSearchConfig.password
},
body: hashtagData,
json: true
};
return request(elasticSearchRequest).then(response => {
console.log("ElasticSearch response", response);
});
});
according to this log console.log('Indexing the hashtags: ', hashtagData); sometimes the dataset is not coming through in full. However the dataset created on database is complete and correct.
Any idea what went wrong here? Thanks!