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

ScrollRequest not work? #352

Open
wfxr opened this issue May 12, 2019 · 3 comments
Open

ScrollRequest not work? #352

wfxr opened this issue May 12, 2019 · 3 comments
Milestone

Comments

@wfxr
Copy link

wfxr commented May 12, 2019

Here is a very simple scroll request, but I can't make it work. Did I get something wrong?

let req = ScrollRequest::new(json!({
        "query": {
            "match_all": {}
        }
    }));
let res = client.request(req)
    .send()?
    .into_response::<SearchResponse<Value>>()?;

The error message is :

Error: Api(IllegalArgument { reason: "Unknown parameter [query] in request body or parameter is of the wrong type[START_OBJECT] " })

If I keep request body empty:

let req = ScrollRequest::new(json!({}));

Another error showed:

Error: Api(ActionRequestValidation { reason: "Validation Failed: 1: scrollId is missing;" })
@KodrAus
Copy link
Member

KodrAus commented Jul 2, 2019

Hi @wfxr 👋

We should add high-level support for scrolling to this library. The scroll API is actually a little confusing. You need to issue a SearchRequest first with a scroll query parameter, then pass the _scroll_id to a ScrollRequest to continue:

let client = SyncClient::builder().build()?;

// Just make sure our index exists
client.index("my-index").create().send()?;

// Issue a search request
let res = client.search::<Value>()
    .index("my-index")
    .body(json!({
        "size": 100,
        "query": {
            "match_all": {}
        }
    }))
    // Add the `scroll` parameter
    .params_fluent(|p| p
        .url_param("scroll", "1m"))
    .send()?;

println!("{:?}", res);

Ok(())

We unfortunately don't currently expose the scroll_id field from our SearchResponse. I'll submit a PR to fix this up!

@slaterb1
Copy link

slaterb1 commented Jul 2, 2019

@KodrAus I literally just ran the query you posted above (independently for my own test index) and was surprised that the _scroll_id was not exposed on the SearchResponse. I've worked with the scroll api in ES quite a bit and the code you posted is exactly what I was looking for! I was just checking to see if there were any Issues related to this before diving deeper into the source to suggest/implement that change.

I only just started following this repo, but what is the typical tag/release timeline for this project? Would this small patch get tagged and released on it's own (soon) or will it get batched in with some other changes?

@KodrAus
Copy link
Member

KodrAus commented Jul 2, 2019

@slaterb1 Welcome!

So my bandwidth for supporting the project is a bit limited lately, but am actually working on a PR to add some nicer scrolling support at the moment that exposes the paged search responses either as an Iterator for synchronous calls or as a Stream for asynchronous ones, so it should land pretty soon! We've got a lot of changes currently on master to push out, so I'll be doing that as soon as scroll support lands and I give the docs a polish.

@KodrAus KodrAus added this to the 0.21.x milestone Jul 7, 2019
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

3 participants