Skip to content

mtermvector query with lots of ids #648

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

Closed
ghost opened this issue May 7, 2014 · 3 comments
Closed

mtermvector query with lots of ids #648

ghost opened this issue May 7, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented May 7, 2014

Hi!

I tried the new Multi Term Vector query. But when I add a lot of (1000) ids to the Ids parameter. I get an error:

An unhandled exception of type 'Elasticsearch.Net.Exceptions.MaxRetryException' occurred in Elasticsearch.Net.dll

Additional information: Unable to perform request: 'POST ' on any of the nodes after retrying 0 times.

on the Transport.cs - line: 259

The request looks like:
var mtvResul = client.MultiTermVectors(mtv => mtv
.Fields(bd => bd.BlockText)
.Ids(ids.ToArray())
);
Where ids is a List with 1000 elements.
Am I doing somehing wrong?

Thanks!

@gmarz
Copy link
Contributor

gmarz commented May 8, 2014

Hey @gull86,

I was able to reproduce the same issue. The problem here is that when you use the Ids descriptor method, a query string is generated, and it's too large. You should use the Documents descriptor method instead so that the docs will be added as part of the request body. Something like this:

var mtvResul = client.MultiTermVectors(mtv => mtv
    .Fields(bd => bd.BlockText)
    .Documents(d => d.Id("1"), d => d.Id("2")));
);

In your case this isn't really ideal because you have an array of ids that you want to add to the request. If #649 is merged, you'll be able to do this instead:

var mtvResul = client.MultiTermVectors(mtv => mtv
    .Fields(bd => bd.BlockText)
    .Documents(ids.Select(id => new MultiTermVectorDocument { Id = id.ToString() }))
);

@Mpdreamz
Copy link
Member

Mpdreamz commented May 8, 2014

Hey @gull86 @gmarz

I've updated this slightly, based on @gmarz's PR, so that .Ids() are no longer passed over the querystring.

 .Ids(1,2,3,4,5,....)
 .Ids("1", "2", "3", ...)
 .Ids(new [] {1,2,3 ...)

Should now all work with arbitrary number of ids too.

@gmarz
Copy link
Contributor

gmarz commented May 8, 2014

@Mpdreamz Looks good, thanks!

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