javascript - elasticsearch.js&nodejs scoll method problem
phpcn_u1582
phpcn_u1582 2017-05-24 11:38:21
0
1
809

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.

phpcn_u1582
phpcn_u1582

reply all(1)
给我你的怀抱

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.

var esClient = new elasticsearch.Client({
  host: esconf.host130,
  apiVersion: "0.90",
  log: 'error'
  });

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template