Skip to content

HasParent is serializing to "type" instead of "parent_type" : parsing_exception Reason: "[has_parent] query does not support [type] #2991

@ghost

Description

NEST/Elasticsearch.Net version: 6.0.0-beta1

Elasticsearch version: 6.1.1

Problem:
When building a search descriptor including a HasParent descriptor, the final search query does not parse properly.

Steps to reproduce:

  1. Create parent/child documents with a base class and a JoinField.
  2. Index parent and child
  3. Create a SearchDescriptor including HasParent descriptor.
  4. Run search, failes with invalid result, see Debug Information.
  5. Take the generated query from the debug information, replace "type": "sampleparent" with "parent_type" : "sampleparent". Run the query in a native REST client. The query is valid and gives the expected result.

Sample snippet:

var searchDescriptor = new SearchDescriptor<SampleChild>()
.Query(q => q.HasParent<SampleParent>(p => p.Query(qx => qx.Term(t => t.Id, sampleParent.Id))))
    .Index("sample").Type("samplebase");
var searchResult = client.Search<SampleChild>(searchDescriptor);

See sample source:
HasParentProgramm.txt

Provide DebugInformation (if relevant):

Invalid NEST response built from a unsuccessful low level call on POST: /sample/samplebase/_search?typed_keys=true
# Audit trail of this API call:
 - [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.1491518
# OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetResponse()
   at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData) in T:\TeamCity\buildAgent\work\38a00213fd0f22c3\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 167
# Request:
{"query":{"has_parent":{"type":"sampleparent","query":{"term":{"id":{"value":"703ca000d47e4da7839fce7e3174fd18"}}}}}}
# Response:
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[has_parent] query does not support [type]","line":1,"col":32}],"type":"parsing_exception","reason":"[has_parent] query does not support [type]","line":1,"col":32},"status":400}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions