elasticsearch-js: Scroll api 5.3 throwing error

var allTitles = [];
var i =0;

var elasticsearch = require('elasticsearch');

var client = new elasticsearch.Client({
    host: 'localhost:9200',
 });
// first we do a search, and specify a scroll timeout
client.search({
  index: 'movies',
  scroll: '30s', 
  size:1,
  _source : 'title'
}, function getMoreUntilDone(error, response) {
  // collect the title from each response

  console.log('i',i++);


  console.log(JSON.stringify(response));

  response.hits.hits.forEach(function (hit) {
    allTitles.push(hit._source.title);
  });
  if (response.hits.total > allTitles.length) {
    // ask elasticsearch for the next set of hits from this search
    client.scroll({
       scrollId: response._scroll_id,
        scroll: '30s', 
    }, getMoreUntilDone);
  } else {
    console.log('every "test" title', allTitles);
  }
});

when I running the code throwing error

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Failed to parse request body"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Failed to parse request body",
    "caused_by": {
      "type": "json_parse_exception",
      "reason": "Unrecognized token 'DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAHKFnV6a2NabEh4VDZLQmdzUzY0Y2tpd0EAAAAAAAAByxZ1emtjWmxIeFQ2S0Jnc1M2NGNraXdBAAAAAAAAAcwWdXprY1psSHhUNktCZ3NTNjRja2l3QQAAAAAAAAHOFnV6a2NabEh4VDZLQmdzUzY0Y2tpd0EAAAAAAAABzRZ1emtjWmxIeFQ2S0Jnc1M2NGNraXdB': was expecting ('true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@67ba4d99; line: 1, column: 457]"
    }
  },
  "status": 400
}

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Upgrading to 13.0.0-rc1 should fix your issue

This is still valid issue, still not working with elastic 5.5 and elasticsearch.js v13.3.1

Why exactly was this closed? The issue I described above for clearScroll persists in 13.0.0.