Skip to content

Nest 2.0.0 Indexing id-less object incorrectly selects PUT method, should be POST #1736

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
wewebber opened this issue Jan 19, 2016 · 0 comments
Milestone

Comments

@wewebber
Copy link

If I do (in F#):

type DocType = { Id : string ; Name : string }
let myDoc = { Id = null; Name = "foo" }
client.Index(IndexRequest(DocumentPath(myDoc)))

then the request that gets generated is

PUT /doctype/doctype/
{ body }

which causes an "Invalid Request" error from ElasticSearch (2.1.1). The request should be:

POST /doctype/doctype/
{ body }

The problematic code is at line 20 of https://github.com/elastic/elasticsearch-net/blob/82c938893b2ff4ddca03a8e977ad14a16da712ba/src/Nest/Document/Single/Index/IndexRequest.cs

    protected override HttpMethod HttpMethod => ((IIndexRequest<TDocument>)this).Id 
                 == null ? HttpMethod.POST : HttpMethod.PUT;

The Id property here is Nest.Id object wrapped around the document itself. Its GetString() method will return null, but the object itself is not null.

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