I am using .NET SDK to create an index in Azure AI Search Service. I have multiple float fields in the model to index :
[SimpleField(IsFilterable = true, IsSortable = true, IsFacetable = true)]
public float? MonitoringFee { get; set; }
And I'm getting this error:
{"error":{"code":"InvalidRequestParameter","message":"The request is invalid. Details: definition : The field 'MonitoringFee' cannot specify a field type 'Edm.Single' because it is not supported.","details":[{"code":"InvalidField","message":"The field 'MonitoringFee' cannot specify a field type 'Edm.Single' because it is not supported. Parameters: definition"}]}}
The problem seems to be that the index does not support Edm.Single (float). So, I needed to convert the float fields to double.
I have tried using Custom FloatToDouble JsonSerializer in FieldBuilder and SearchIndexClient. I've also tried the following annotation on the field as well:
[JsonConverter(typeof(FloatToDoubleConverter))]
Both of the above tries were fruitless.
Note: I cannot change my model datatypes.
Then try to handle the conversion before indexing the data. Before sending the data to Azure AI Search for indexing, transform the float fields to double in your application code.
Here are some sample data for testing:
With this ModelTransformer class, you can easily transform all float fields to double fields in any model class: