Search code examples
azuresearchindexingazure-cognitive-search

Azure Congnitive Seach index int64 does not accept string value


I'm using a Python Azure App Function to copy data from a SQLServer database to a Azure Cognitive Search index. The problem I'm seeing is that there are some nvarchar fields that contain numeric data that I'm trying to put into an Edm.int64 field in the index. The documentation states that this should work:

https://learn.microsoft.com/en-us/rest/api/searchservice/data-type-map-for-indexers-in-azure-search#bkmk_sql_search

However, I get an error – “Cannot convert a value to target type 'Edm.Int64' because of conflict between input format string/number and parameter 'IEEE754Compatible' false/true”.

It works when copy string with numbers into an Edm.int32 index field....

Has anyone else encountered/solved this issue? Thanks!


Solution

  • You're getting the error since you're trying to convert from a varchar to a Edm.int32 index field and that is not supported.

    As per https://learn.microsoft.com/rest/api/searchservice/data-type-map-for-indexers-in-azure-search#bkmk_sql_search you can only convert int, smallint, tinyint types into Edm.int32.

    In the conversion table you'll find that char, nchar, varchar, nvarchar can only be converted to Edm.String or Collection(Edm.String).

    You can make your index field an Edm.String type and then in your client app code translate the string to an int accordingly once the content has been indexed to manipulate the response type.

    I hope this helps.