In Azure I've uploaded a large amount of blobs with html content and many meta data fields. We are then indexing this content with Azure Cognitive Search, using a blob indexer. The issue we are having is that we want to boost search scores on a "publishDate" that we set on the blob meta data fields. This is inherently different than blob update and create dates that are automatically set. I don't think we can set the type of a metadata field to be Edm.DateTimeOffset, so this is currently Edm.String. The indexer can't set a scoring profile that has freshness off a String. Is there a way to either:
1.) Set a metadata field on a blob to be Edm.DateTimeOffset 2.) Have a scoring profile on an index, that converts a string to Edm.DateTimeOffset and then boots freshness?
I've tried both setting publishDate in multiple date formats and played around with scoring profiles. I also look at if there was a way to spoof this by sticking publish dates into the existing meta data fields for blob create date/ update date but that is not allowed
Try this all steps
1.Create a new field in your index to store the "publishDate" as an Edm.DateTimeOffset type. Let's call this field "publishedDateTime". Set the searchable and retrievable properties of this field according to your requirements.
2.Modify your blob indexer to map the "publishDate" metadata field to the "publishedDateTime" field in the index. You can do this by configuring the fieldMappings property in the indexer definition.
{
"fieldMappings": [
{
"sourceFieldName": "metadata_publishDate",
"targetFieldName": "publishedDateTime"
}
],
// Other indexer configuration properties...
}
3.Create a scoring profile that boosts search scores based on the "publishedDateTime" field.
{
"scoringProfiles": [
{
"name": "boostByPublishedDateTime",
"text": {
"weights": {
"publishedDateTime": 1.5
}
}
}
],
// Other index configuration properties...
}
4.Associate the scoring profile with your index by setting the scoringProfiles property in the index definition.
{
"scoringProfiles": [
{
"name": "boostByPublishedDateTime",
"text": {
"weights": {
"publishedDateTime": 1.5
}
}
}
],
"defaultScoringProfile": "boostByPublishedDateTime",
// Other index configuration properties...
}
when you perform searches using Azure Cognitive Search, the "publishedDateTime" field will be taken into account for boosting search scores based on the configured scoring profile.