.NET client suggest query issue

Hi,
I had an issue using new .NET client v8. I used to use v7 client (NEST) but recently decided to migrate to v8 client. let me explain my issue in details.

I have an index with this mappings:

{
  "mappings": {
    "properties": {
      "body": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "content_type": {
        "type": "keyword"
      },
      "creation_date": {
        "type": "date"
      },
      "depth": {
        "type": "float"
      },
      "domain": {
        "type": "keyword"
      },
      "h1": {
        "type": "text",
        "fields": {
          "as_you_type": {
            "type": "search_as_you_type",
            "doc_values": false,
            "max_shingle_size": 3
          },
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "h2": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "h3": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "h4": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "h5": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "h6": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "http_status": {
        "type": "float"
      },
      "id": {
        "type": "keyword"
      },
      "last_update": {
        "type": "date"
      },
      "meta_description": {
        "type": "text",
        "analyzer": "custom_analyzer"
      },
      "meta_keywords": {
        "type": "text",
        "analyzer": "custom_analyzer"
      },
      "page_type": {
        "type": "keyword"
      },
      "referrer_page": {
        "type": "keyword"
      },
      "title": {
        "type": "text",
        "fields": {
          "shingle": {
            "type": "text",
            "analyzer": "shingle"
          }
        },
        "analyzer": "custom_analyzer"
      },
      "unique_id": {
        "type": "keyword"
      },
      "url": {
        "type": "keyword"
      }
    }
  }
}

and related Entity in C# just like this:

    public class SearchWebpageDetailsDto
    {
        [JsonPropertyName("id")]
        public string Id { get; set; } = string.Empty;

        [JsonPropertyName("unique_id")]
        public Guid UniqueId { get; set; }

        [JsonPropertyName("domain")]
        public string Domain { get; set; } = string.Empty;
        [JsonPropertyName("url")]
        public string Url { get; set; } = string.Empty;
        [JsonPropertyName("title")]
        public string Title { get; set; }
        [JsonPropertyName("body")]
        public string Body { get; set; }


        [JsonPropertyName("meta_keywords")]
        public List<string> MetaKeywords { get; set; } = [];
        [JsonPropertyName("meta_description")]
        public List<string> MetaDescription { get; set; } = [];


        [JsonPropertyName("h1")]
        public List<string> H1 { get; set; } = [];
        [JsonPropertyName("h2")]
        public List<string> H2 { get; set; } = [];
        [JsonPropertyName("h3")]
        public List<string> H3 { get; set; } = [];
        [JsonPropertyName("h4")]
        public List<string> H4 { get; set; } = [];
        [JsonPropertyName("h5")]
        public List<string> H5 { get; set; } = [];
        [JsonPropertyName("h6")]
        public List<string> H6 { get; set; } = [];


        [JsonPropertyName("last_update")]
        public required DateTime LastUpdate { get; set; }
        [JsonPropertyName("creation_date")]
        public required DateTime CreationDate { get; set; }


        [JsonPropertyName("referrer_page")]
        public string Referrer { get; set; }
        [JsonPropertyName("http_status")]
        public int HttpStatus { get; set; }
        [JsonPropertyName("depth")]
        public long Depth { get; set; }

        [JsonPropertyName("content_type")]
        public string ContentType { get; set; }

        [JsonPropertyName("page_type")]
        public int PageType { get; set; }
    }

I tried to use a suggest query just like this using v8 client:

var suggestResponse = await _client.SearchAsync<SearchWebpageDetailsDto>(s => s
    .Suggest(su => su
        .Suggesters(sus => sus
            .Add("simple_phrase", sug => sug
                .Phrase(ph => ph
                    .Text(searchPhrase) // searchPhrase is method input param
                    .Field(f => f.Title.Suffix("shingle"))
                    .Size(5)
                    .Confidence(1)
                    .DirectGenerator(dg => dg
                        .Field(f => f.Title.Suffix("shingle"))
                        .PrefixLength(0)
                    )
                    .MaxErrors(2)
                    .Collate(co => co
                        .Query(q => q
                            .Source("{\"match\": {\"title\": {\"query\": \"{{suggestion}}\", \"fuzziness\": \"1\", \"operator\": \"and\"}}}")
                        )
                        .Prune(false)
                    )
                )
            )
        )
    )
);

But I get an Exception with this message:

Message: Request failed to execute. Call: Status code 400 from: POST /_search?pretty=true&error_trace=true&typed_keys=true. ServerError: Type: parsing_exception Reason: "suggester[phrase] doesn't support field [text]"

I had the same suggest query in v7 NEST with no exceptions or errors and it was just working properly.
My NEST query was this:

var suggestResponse = await _client.SearchAsync<SearchWebpageDetailsDto>(s => s
    .Suggest(su => su
        .Phrase("simple_phrase", ph => ph
            .Text(searchPhrase)
            .Field(f => f.Title.Suffix("shingle"))
            .Size(5)
            .Confidence(1)
            .DirectGenerator(dg => dg
                .Field(f => f.Title.Suffix("shingle"))
                .PrefixLength(0)
            )
            .MaxErrors(2)
            .Collate(co => co
                .Query(q => q
                    .Source("{\"match\": {\"title\": {\"query\": \"{{suggestion}}\", \"fuzziness\": \"1\", \"operator\": \"and\"}}}")
                )
                .Prune(false)
            )
        )
    )
);

Should mention that I was using NEST property attributes on SearchWebpageDetailsDto properties for example

[Text(name = "title")]
public string Title { get; set; }

... other properties

But in the new client didn't found same attributes so had to delete them.

How can I solve this problem?
Thanks in Advance.

Hi @jahedi ,

this is weird. Your query looks fine to me.

I noticed that you don't specify an index in your search request. Did you configure a the correct index as default index? I could imagine that your search request runs on a wrong index that does not have the correct mappings.

Could you please attach the JSON payload of the request?

This can e.g. be logged by using the following code snippet:

var settings = new ElasticsearchClientSettings(new Uri("..."))
    // ...
    .DisableDirectStreaming()
    .EnableDebugMode(cd =>
    {
        Console.WriteLine(cd.DebugInformation);
    });

Yes, I have defined the index named in the ElasticsearchClientSettings and as default index.
Also I tried to write the index named explicitly but didn't work too.

This is the debug information:

Unsuccessful (400) low level call on POST: /_search?pretty=true&error_trace=true&typed_keys=true
 Exception: Request failed to execute. Call: Status code 400 from: POST /_search?pretty=true&error_trace=true&typed_keys=true. ServerError: Type: parsing_exception Reason: "suggester[phrase] doesn't support field [text]"

# Audit trail of this API call:
 - [1] BadResponse: Node: https://192.168.200.23:9200/ Took: 00:00:00.0393522
# OriginalException: Elastic.Transport.TransportException: Request failed to execute. Call: Status code 400 from: POST /_search?pretty=true&error_trace=true&typed_keys=true. ServerError: Type: parsing_exception Reason: "suggester[phrase] doesn't support field [text]"
# Request:
{
  "suggest": {
    "simple_phrase": {
      "phrase": {
        "collate": {
          "prune": false,
          "query": {
            "source": "{\u0022match\u0022: {\u0022title\u0022: {\u0022query\u0022: \u0022{{suggestion}}\u0022, \u0022fuzziness\u0022: \u00221\u0022, \u0022operator\u0022: \u0022and\u0022}}}"
          }
        },
        "confidence": 1,
        "direct_generator": [
          {
            "field": "title.shingle",
            "prefix_length": 0
          }
        ],
        "field": "title.shingle",
        "max_errors": 2,
        "size": 5,
        "text": "linux"
      }
    }
  }
}
# Response:
{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "suggester[phrase] doesn't support field [text]",
        "line" : 21,
        "col" : 17,
        "stack_trace" : "org.elasticsearch.common.ParsingException: suggester[phrase] doesn't support field [text]\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.fromXContent(PhraseSuggestionBuilder.java:504)\r\n\tat org.elasticsearch.xcontent@8.14.3/org.elasticsearch.xcontent.NamedXContentRegistry$Entry.lambda$new$0(NamedXContentRegistry.java:55)\r\n\tat org.elasticsearch.xcontent@8.14.3/org.elasticsearch.xcontent.NamedXContentRegistry.parseNamedObject(NamedXContentRegistry.java:148)\r\n\tat org.elasticsearch.xcontent@8.14.3/org.elasticsearch.xcontent.support.AbstractXContentParser.namedObject(AbstractXContentParser.java:414)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.suggest.SuggestionBuilder.fromXContent(SuggestionBuilder.java:264)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.suggest.SuggestBuilder.fromXContent(SuggestBuilder.java:152)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.builder.SearchSourceBuilder.parseXContent(SearchSourceBuilder.java:1452)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.builder.SearchSourceBuilder.parseXContent(SearchSourceBuilder.java:1259)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.action.search.RestSearchAction.parseSearchRequest(RestSearchAction.java:181)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.action.search.RestSearchAction.lambda$prepareRequest$1(RestSearchAction.java:120)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestRequest.withContentOrSourceParamParserOrNull(RestRequest.java:544)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.action.search.RestSearchAction.prepareRequest(RestSearchAction.java:119)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:81)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController$1.onResponse(RestController.java:452)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController$1.onResponse(RestController.java:446)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.rest.SecurityRestFilter.doHandleRequest(SecurityRestFilter.java:89)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.rest.SecurityRestFilter.lambda$intercept$0(SecurityRestFilter.java:81)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:171)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.lambda$authenticateAndAttachToContext$3(SecondaryAuthenticator.java:99)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:245)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.authenticate(SecondaryAuthenticator.java:109)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.authenticateAndAttachToContext(SecondaryAuthenticator.java:90)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.rest.SecurityRestFilter.intercept(SecurityRestFilter.java:75)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:446)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController.tryAllHandlers(RestController.java:606)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:329)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.http.AbstractHttpServerTransport.dispatchRequest(AbstractHttpServerTransport.java:487)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.http.AbstractHttpServerTransport.handleIncomingRequest(AbstractHttpServerTransport.java:583)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.http.AbstractHttpServerTransport.incomingRequest(AbstractHttpServerTransport.java:460)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpPipeliningHandler.handlePipelinedRequest(Netty4HttpPipeliningHandler.java:126)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpPipeliningHandler.channelRead(Netty4HttpPipeliningHandler.java:116)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\r\n\tat io.netty.codec@4.1.107.Final/io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\r\n\tat io.netty.codec@4.1.107.Final/io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpHeaderValidator.forwardData(Netty4HttpHeaderValidator.java:209)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpHeaderValidator.forwardFullRequest(Netty4HttpHeaderValidator.java:152)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpHeaderValidator$1.lambda$onResponse$0(Netty4HttpHeaderValidator.java:125)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\r\n\tat java.base/java.lang.Thread.run(Thread.java:1570)\r\n"
      }
    ],
    "type" : "parsing_exception",
    "reason" : "suggester[phrase] doesn't support field [text]",
    "line" : 21,
    "col" : 17,
    "stack_trace" : "org.elasticsearch.common.ParsingException: suggester[phrase] doesn't support field [text]\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder.fromXContent(PhraseSuggestionBuilder.java:504)\r\n\tat org.elasticsearch.xcontent@8.14.3/org.elasticsearch.xcontent.NamedXContentRegistry$Entry.lambda$new$0(NamedXContentRegistry.java:55)\r\n\tat org.elasticsearch.xcontent@8.14.3/org.elasticsearch.xcontent.NamedXContentRegistry.parseNamedObject(NamedXContentRegistry.java:148)\r\n\tat org.elasticsearch.xcontent@8.14.3/org.elasticsearch.xcontent.support.AbstractXContentParser.namedObject(AbstractXContentParser.java:414)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.suggest.SuggestionBuilder.fromXContent(SuggestionBuilder.java:264)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.suggest.SuggestBuilder.fromXContent(SuggestBuilder.java:152)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.builder.SearchSourceBuilder.parseXContent(SearchSourceBuilder.java:1452)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.search.builder.SearchSourceBuilder.parseXContent(SearchSourceBuilder.java:1259)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.action.search.RestSearchAction.parseSearchRequest(RestSearchAction.java:181)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.action.search.RestSearchAction.lambda$prepareRequest$1(RestSearchAction.java:120)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestRequest.withContentOrSourceParamParserOrNull(RestRequest.java:544)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.action.search.RestSearchAction.prepareRequest(RestSearchAction.java:119)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.BaseRestHandler.handleRequest(BaseRestHandler.java:81)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController$1.onResponse(RestController.java:452)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController$1.onResponse(RestController.java:446)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.rest.SecurityRestFilter.doHandleRequest(SecurityRestFilter.java:89)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.rest.SecurityRestFilter.lambda$intercept$0(SecurityRestFilter.java:81)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.action.ActionListener$2.onResponse(ActionListener.java:171)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.lambda$authenticateAndAttachToContext$3(SecondaryAuthenticator.java:99)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:245)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.authenticate(SecondaryAuthenticator.java:109)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.authc.support.SecondaryAuthenticator.authenticateAndAttachToContext(SecondaryAuthenticator.java:90)\r\n\tat org.elasticsearch.security@8.14.3/org.elasticsearch.xpack.security.rest.SecurityRestFilter.intercept(SecurityRestFilter.java:75)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:446)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController.tryAllHandlers(RestController.java:606)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.rest.RestController.dispatchRequest(RestController.java:329)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.http.AbstractHttpServerTransport.dispatchRequest(AbstractHttpServerTransport.java:487)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.http.AbstractHttpServerTransport.handleIncomingRequest(AbstractHttpServerTransport.java:583)\r\n\tat org.elasticsearch.server@8.14.3/org.elasticsearch.http.AbstractHttpServerTransport.incomingRequest(AbstractHttpServerTransport.java:460)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpPipeliningHandler.handlePipelinedRequest(Netty4HttpPipeliningHandler.java:126)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpPipeliningHandler.channelRead(Netty4HttpPipeliningHandler.java:116)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\r\n\tat io.netty.codec@4.1.107.Final/io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\r\n\tat io.netty.codec@4.1.107.Final/io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpHeaderValidator.forwardData(Netty4HttpHeaderValidator.java:209)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpHeaderValidator.forwardFullRequest(Netty4HttpHeaderValidator.java:152)\r\n\tat org.elasticsearch.transport.netty4@8.14.3/org.elasticsearch.http.netty4.Netty4HttpHeaderValidator$1.lambda$onResponse$0(Netty4HttpHeaderValidator.java:125)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)\r\n\tat io.netty.transport@4.1.107.Final/io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)\r\n\tat io.netty.common@4.1.107.Final/io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)\r\n\tat java.base/java.lang.Thread.run(Thread.java:1570)\r\n"
  },
  "status" : 400
}

# TCP states:
  Established: 32
  TimeWait: 9
  CloseWait: 13

# ThreadPool statistics:
  Worker: 
    Busy: 1
    Free: 32766
    Min: 8
    Max: 32767
  IOCP: 
    Busy: 0
    Free: 1000
    Min: 1
    Max: 1000

Hi @jahedi,

could you please try to manually specify the index again? It does not seem like the default index was used in the request.

If it still not works, it is probably a server-side issue/misconfiguration.

I added the index named manually and the result was the same. the only difference with the above information was that the request was POST /myindex/_search and not POST /_search but the result was the same.

I don't think the issue is on the server side because I used the NEST package before on this same server with the very same query and it was working right.

Also mention that I tried to get the results using the low level Transport option and I got the correct results just like this:

var searchRawQuery = new
{
    suggest = new
    {
        text = searchText,
        did_you_mean = new
        {
            phrase = new
            {
                field = "title.shingle",
                size = 5,
                confidence = 1,
                direct_generator = new[]
                {
                    new
                    {
                        field = "title.shingle",
                        prefix_length = 0
                    }
                },
                max_errors = 4,
                collate = new
                {
                    query = new
                    {
                        source = new
                        {
                            match = new
                            {
                                title = new
                                {
                                    query = "{{suggestion}}",
                                    @operator = "and"
                                }
                            },
                        },
                    },

                    prune = false
                }
            }
        }
    }
};

var searchJsonQuery = PostData.Serializable(searchRawQuery);
var defaultIndexName = _client.ElasticsearchClientSettings.DefaultIndex;

    var searchResponseString = await _client.Transport.RequestAsync<StringResponse>
        (HttpMethod.GET, $"/{defaultIndexName}/_search", searchJsonQuery).ConfigureAwait(false);

As you can see I got the result as StringResponse. I tried to get the results as my document entity named SearchWebpageDetailsDto but got the error again!
just like this:

// caused error
var searchResponseString = await _client.Transport.RequestAsync<SearchResponse< SearchWebpageDetailsDto>>
        (HttpMethod.GET, $"/{defaultIndexName}/_search", searchJsonQuery).ConfigureAwait(false);

Hi @jahedi,

Also mention that I tried to get the results using the low level Transport option and I got the correct results just like this

Could you please round-trip (de-)serialize the low-level request and compare the JSON payload to the one that you captured earlier?

The error you are getting is definitely a ServerError which means that something must go wrong when build- or serializing the request using the DSL.