Elasticsearch-js: JSAPI scroll documentation is inconsistent

Created on 16 Nov 2016  路  7Comments  路  Source: elastic/elasticsearch-js

In the documenation for client.scroll at https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html#api-scroll the parameter scroll is listed as accepting either a Date or number. The example on the same page uses a stringscroll: '30s'. Either the parameter should be documented as also accepting a string or the example needs to be updated.

If the parameter can be a string like '30s' is that also true of other parameters in other functions that accept Date, Number?

bug documentation

All 7 comments

That's a good question.

The elasticsearch source indicates that the only valid values for the scroll parameter is a string representaion of a duration, formatted as a number followed by a time unit.

Best I can tell by looking at the history this has always been the case, but before 5.0 the units were not required.

This does indeed mean that the docs are incorrect.

So just to clarify so I can get the TypeScript declaration file right: parameters named timeout, masterTimeout, scroll, interval and ttl _must_ be strings like "30s" (and presumably timestamp is correct with Date, number). Yes?

Regarding the second question:

I suspect it is the case for many of the other parameters that are marked with Date, Number. These parameters are identified with "type": "time" in the rest api spec (which might be helpful in your quest to type the elasticsearch client).

The only exception I know of so far is the timestamp parameter of the create, index, and update APIs. This parameter is marked as type time in the rest spec, but actually expects a date value.. Going to have to look deeper into that one

Awesome. Thanks for the quick turnaround on this.

Sure thing, thank you for helping update the community type definitions!

This is also in the example code for client.scroll:

client.search({
  index: 'myindex',
  // Set to 30 seconds because we are calling right back
  scroll: '30s',
  search_type: 'scan',
  fields: ['title'],
  q: 'title:test'
}

It looks like search_type: 'scan' should now be searchType: 'query_then_fetch' and fields: ['title'] should be docvalueFields: ['title'].

This should be fixed with the updates that came along with 12.1

Was this page helpful?
0 / 5 - 0 ratings