Querying Elasticsearch Arrays with NEST and gRPC protos

My goal is to return a result of a search query to the user. This is done by querying a list of objects in Elasticsearch with a custom search parameter in a dotnet 6 webapi project using gRPC proto files and NEST.

My problem is that after the deserialization is done in the background, all properties except the list types have data in them. If I use the EnableDebugMode() and paste the same query in Postman I get the correct results with all properties containing data. I've ran some tests with standard .NET models conaining List elements and I couldn't reproduce the problem. It has to be something with the deserialization of the repeated type from gRPC protos. Is this a known problem or anyone know a workaround?

For the dotnet 6 webapi with NEST

private ISearchResponse<Country> GetFilteredResults(ElasticClient client, QueryDto query)
{
    return client.Search<Country>(s => s
        .From(0)
        .Size(10)
        .Query(q =>
                q.Nested(n => n
                    .Path(p => p.Customers)
                    .Query(q => q
                        .Bool(b => b
                            .Must(m => m
                                .MultiMatch(mm => mm
                                    .Fields(fs => fs
                                        .Field(f => f.Customers[0].Name)
                                        .Field(f => f.Customers[0].ShortName))
                                    .Type(TextQueryType.PhrasePrefix)
                                    .Query(query.SearchTerm))))))
        )
    );
}

the grpc proto file:

message Country {
    int32 countryId = 1;
    string name = 2;
    string description = 3;
    repeated Customer customers = 4;
}

message Customer {
    int32 customerId = 1;
    string name = 2;
    string shortName = 3;
}

For Elasticsearch:

{
    "test":{
       "aliases":{
       },
       "mappings":{
          "country":{
             "properties":{
                "countryId":{
                   "type":"long"
                },
                "customers":{
                   "type":"nested",
                   "properties":{
                      "customerId":{
                         "type":"long"
                      },
                      "name":{
                         "type":"text",
                         "fields":{
                            "keyword":{
                               "type":"keyword",
                               "ignore_above":256
                            }
                         }
                      },
                      "shortName":{
                         "type":"text",
                         "fields":{
                            "keyword":{
                               "type":"keyword",
                               "ignore_above":256
                            }
                         }
                      }
                   }
                },
                "name":{
                   "type":"text",
                   "analyzer":"analyzer-name"
                },
                "description":{
                   "type":"text",
                   "analyzer":"analyzer-name"
                }
             }
          }
       },
       "settings":{
          "index":{
             "number_of_shards":"1",
             "provided_name":"test",
             "creation_date":"1646646283283",
             "analysis":{
                "analyzer":{
                   "analyzer-name":{
                      "filter":"lowercase",
                      "type":"custom",
                      "tokenizer":"keyword"
                   }
                }
             },
             "number_of_replicas":"1",
             "uuid":"xyz",
             "version":{
                "created":"6020499"
             }
          }
       }
    }
 }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.