How to fix "The data field ___ in the document with key ___ has an invalid value type of Edm.Double. The expected type was Edm.Int32

Tyler Suard 155 Reputation points
2024-12-02T17:47:43.4366667+00:00

Hello. I have set up a data source and an indexer. Everything was working fine until this morning, now I am getting the above error message. My data source is cosmosdb, and it takes a string and converts it into a number using StringToNumber. Apparently StringToNumber converts it into a Double, but my index can only take an Int32 in that field. How do I make StringToNumber return an int32?

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,350 questions
{count} votes

Accepted answer
  1. Laxman Reddy Revuri 5,405 Reputation points Microsoft External Staff Moderator
    2024-12-05T07:59:21.1566667+00:00

    Hi @Tyler Suard
    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer

    Ask: How to fix "The data field ___ in the document with key ___ has an invalid value type of Edm.Double. The expected type was Edm.Int32

    Solution:I solved this issue. The problem is, that particular field was coming in as a string from CosmosDB, and it was "0.0". When I used "StringToNumber(field))" in my data source, it was interpreting 0.0 as a double-precision float. I just changed the data source to use ROUND(StringToNumber(field)) instead. That rounded the number up to 0 instead of 0.0, which was interpreted as a 32bit integer rather than a double.

    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members. 

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.