I don’t know if anyone has ever used nodejs combined with elasticsearch for development. I wanted to try it today and executed a scoll query, but a very strange error occurred. Please help.
This is my method
esdao.searchScollFor130 = function() {
esClient.search({
index: esconf.index130,
type: esconf.ttype,
scroll: '30s',
search_type: 'scan',
body: {query: {match_all: {}}}
}, function getMoreUntilDone(err, ress) {
console.log(ress);
if (92202 !== allresult.length) {
esClient.scroll({
scrollId: ress._scroll_id,
scroll: '30s'
}, getMoreUntilDone);
} else {
console.log('every "test" title', allTitles);
}
});
console.log(allresult);
}
But the background keeps throwing errors during execution
Another way to write it, replace 92202 with ress.hits.total and want to get the total number, but:
I am very depressed, I will directly return the result Copy it and assign it to a variable, but you can get the total value.
I have found the cause of the problem myself. Let me tell you the solution to avoid detours if you encounter the same problem. Because my server version is the older version 1.2, so I only need to add the version number when creating the client. Enough.
This is a question I raised on github. I was inspired by another person who asked a question. You can also refer to my solution process.