Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrolling with typedclient API #785

Closed
frkntplglu opened this issue Jan 16, 2024 · 2 comments
Closed

Scrolling with typedclient API #785

frkntplglu opened this issue Jan 16, 2024 · 2 comments

Comments

@frkntplglu
Copy link

Hi, I was trying to use Scroll feature with typedclient API and I got an error many times which is cannot parse scroll id. Then, I started to look into source code of package and I realized that Scroll(duration time.Duration) method updates r.req.Scroll value

 func (r *Scroll) Scroll(duration types.Duration) *Scroll {
	r.req.Scroll = duration

	return r
}

However, ScrollId(scrollid string) method just updates r.scrollid value

func (r *Scroll) ScrollId(scrollid string) *Scroll {
	r.paramSet |= scrollidMask
	r.scrollid = scrollid
	return r
}

That's why the scroll id that I sent cannot be added to the request and gives an error. When I added r.req.ScrollId = scrollid to ScrollId method it works correctly. I am not sure if it is a bug or not.

Last version of ScrollId method :

func (r *Scroll) ScrollId(scrollid string) *Scroll {
	r.paramSet |= scrollidMask
	r.scrollid = scrollid
	r.req.ScrollId = scrollid
	return r
}

I used it like this :
es.Scroll().Scroll(15 * time.Minute).ScrollId(scrollId).Do(context.Background())

If I'm wrong please let me know, if it is a bug how could we figure this out?

@Anaethelion
Copy link
Contributor

Hi @frkntplglu

Multiple things in this:

  • ScrollID in its current form is going into r.scrollid which is used into the path parameter, it should work.
  • If you wish to use only the body I would advise to use the .Request method for now, like so:
es.Scroll().
	Request(&scroll.Request{
		Scroll:   fmt.Sprintf("%.fs", (15 * time.Minute).Seconds()),
		ScrollId: "scrollId",
	}).
	Do(context.Background())
  • Scroll has been deprecated for some time now, I'd recommend you use search_after with a Point in Time.
  • I'm keeping this issue open, the ScrollId in the specification is optional, which means the method should point to the body. I'm going to investigate this.

@Anaethelion
Copy link
Contributor

Fixed in 8.12.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants