Closed
Description
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
.
Metadata
Metadata
Assignees
Labels
No labels