Skip to content

SearchTemplateDescriptor Explain method #5040

@wyeager

Description

@wyeager

NEST/Elasticsearch.Net version:
7.9.0

Elasticsearch version:
7.9.2

Description of the problem including expected versus actual behavior:
SearchTemplateDescriptor Explain method places ?explain=true in URL when instead the endpoint seems to need "explain": true key value pair in request body

Steps to reproduce:

var searchResponse = await elasticClient
    .SearchTemplateAsync<MyObject>(searchTemplateDesc =>
        searchTemplateDesc
            .Index(myIndex)
            .Source(mySearchTemplate)
            .Params(myParams)
            .Explain());

Each element of searchResponse.Hits will have null for the value of its Explanation field.

Expected behavior
I would expect the Explanation field of each element of searchResponse.Hits to have a value when I call Explain() on the SearchTemplateDescriptor.

Additional Info:
I can send this raw request to:
http://localhost:9200/myIndex/_search/template

{
  "source" : {
      "query": { "match" : { "FirstName" : "{{FirstName}}" } }
  },
  "explain": true,
  "params" : {
    "FirstName": "John"
  }
}

and _explanation has a value.

However, setting ?explain=true in the URL and omitting "explain": true from the request body, like this:
http://localhost:9200/myIndex/_search/template?explain=true

{
  "source" : {
      "query": { "match" : { "FirstName" : "{{FirstName}}" } }
  },
  "params" : {
    "FirstName": "John"
  }
}

does not return an explanation.

I'm pretty sure the cause of the bug is that the SearchTemplateDescriptor Explain method is structuring the request the second way when it should be structuring it the first way.

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