HttpResponseError in Azure Ai search – Stack Overflow

I am new to cloud and trying create a vector embedding for Azure AI search. Here are the snippet of my code :

# Define the index fields
client = SearchIndexClient(endpoint, credential)
fields = [
  SimpleField(name="id", type=SearchFieldDataType.String, key=True, sortable=True, 
                   filterable=True, facetable=True),
  SimpleField(name="originalbalancedue", type=SearchFieldDataType.Double, 
                   sortable=True, filterable=True, facetable=True),
  SimpleField(name="adjustedbalancedue", type=SearchFieldDataType.Double, 
                   sortable=True, filterable=True, facetable=True),
  SimpleField(name="feeamount", type=SearchFieldDataType.Double, sortable=True, 
                   filterable=True, facetable=True),
  SearchableField(name="result", type=SearchFieldDataType.Double, sortable=True, 
                   filterable=True)
]

index = SearchIndex(name=index_name, fields=fields, vector_search=vector_search)
result = client.create_or_update_index(index)
print(f'{result.name} created')

And the search index was created successfully.

Now trying to insert text and embeddings into vector store as:

with open('worthiness_with_result_small.json', 'r') as f:
    content = f.read().strip()
    if content:
        documents = json.loads(content)
        print(f"loaded {len(documents)} documents")
    else:
        print("The file is empty.")
search_client = SearchClient(endpoint=endpoint, index_name=index_name, 
credential=credential)
result = search_client.upload_documents(documents)
print(f"Uploaded {len(documents)} documents") 

where my data in worthiness_with_result_small.json file looks like :

[{“id”:”425001″,”originalbalancedue”:1684269.59,”adjustedbalancedue”:1683369.59,”feeamount”:6659.1199999999998900,”result“:5759.1199999999998900}]

I am getting error:

HttpResponseError: () The request is invalid. Details: Cannot convert the literal '5759.12' to the expected type 'Edm.String'.
Code: 
Message: The request is invalid. Details: Cannot convert the literal '5759.12' to the expected type 'Edm.String'.

Any idea on what I am doing wrong here?

Read more here: Source link