We just upgraded from Elasticsearch/Nest 5.1.1 to 7.6.2 and are seeing a difference in how C# enums are being indexed. Previously, the JsonConverter attribute would store the enum in the index as a text string that we would query against. Now it is storing it as a number and queries are failing to return anything when searching by the enum. Below is how the enum property is set with attributes and the enum definition itself
[JsonConverter(typeof(StringEnumConverter))]
[Text]
public Gender Gender { get; set; }
[Serializable]
public enum Gender
{
Unknown = 'U',
Male = 'M',
Female = 'F'
}
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connectionSettings =
new ConnectionSettings(pool, sourceSerializer: JsonNetSerializer.Default);
var client = new ElasticClient(connectionSettings);
This should continue to work with JsonConverterAttribute as before.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.