I am using Azure search service to search for the documents in my Azure CosmosDB Account.
Using the portal, I have created an Azure search service and given my existing CosmosDB as data source.
Following is the sample document stored in CosmosDB
{
"id": "Engine",
"Sub-Components Price": [
//Price list
],
"Sub-Components": [
"List of sub components here"
],
"Brand": "Brand Name here",
}
When the CosmosDB containing above document is given as data source to the Azure search, id field is internally converted to some string (Automatic Indexing may be).
I am able to set other fields like Sub-Components, Brand as search parameter (using C#) and search only those specific fields. I want to apply the same to id field also. But id field encrypted/encoded to some other string as follows:
{
"id": "UkVRX1ZFSF9DVVNUX0",
"Sub-Components Price": [
//Price list
],
"Sub-Components": [
"List of sub components here"
],
"Brand": "Brand Name here",
}
How to retrieve my original id and set it as search parameter?
Thanks in advance !!
UkVRX1ZFSF9DVVNUX0
is a base64 encoded string and when you decode it you get REQ_VEH_CUST_
.
Why the values are converting to base64 encoded string?
Please check the indexer details. Since there're limitations on the value in the key
field (https://learn.microsoft.com/en-us/rest/api/searchservice/naming-rules - See Document Key
), there's probably a setting in indexer (look under field mapping section and then check if base64Encode
mapping function is applied on the id
field mapping) which is converting and storing the value as base64 encoded string.
If you're confident that the value of id
in source (i.e. key
field in index) will not violate the rule for key field value, you can remove this base64encode mapping function, save the indexer, reset the indexer and run it again. This time the data will be saved as it is in the source.