Code: Select all
public class Content
{
[SimpleField(IsFilterable = true, IsKey = true)]
public required string Id { get; set; }
[SimpleField(IsFilterable = true, IsSortable = true, IsFacetable = true)]
public required string ContentType { get; set; }
[SearchableField(IsSortable = true, AnalyzerName = LexicalAnalyzerName.Values.StandardLucene)]
public required string Name { get; set; }
[SearchableField(IsSortable = true, AnalyzerName = LexicalAnalyzerName.Values.StandardLucene)]
public string? Description { get; set; }
[SimpleField(IsFilterable = true, IsFacetable = true)]
public ICollection Subscriptions { get; set; } = [];
}
Der zweite Indexer ist Nicht zu arbeiten, wie ich es möchte. Unsere Abonnementdaten befinden sich in einer separaten Datenbank und Links über ContentID . Die Abfrage, die ich im Indexer verwende, lautet: < /p>
Code: Select all
SELECT SC.ContentId AS ContentId
, S.SubscriptionName AS SubscriptionName
, SC.ModifyDate AS ModifyDate
FROM dbo.SubscriptionContent SC
INNER JOIN dbo.Subscription S ON S.SubscriptionId = SC.SubscriptionId
< /code>
Meine FieldMappings in diesem Index sind: < /p>
[new FieldMapping("ContentId") { TargetFieldName = nameof(Content.Id) }]
Code: Select all
var shaperInputs = new List
{
new InputFieldMappingEntry("inputs")
{
Source = "/document/SubscriptionName"
},
new InputFieldMappingEntry("groupBy")
{
Source = "/document/ContentId"
}
};
var shaperOutputs = new List
{
new OutputFieldMappingEntry("output")
{
TargetName = "groupedSubscriptionNames"
}
};
var skillset = new SearchIndexerSkillset("content-index-subscription-skillset", new List
{
new ShaperSkill(shaperInputs, shaperOutputs)
{
Name = "groupSubscriptionNames",
Description = "Group SubscriptionNames by ContentId",
Context = "/document"
}
});
< /code>
Dann füge ich AusgabefieldMappings von: < /p>
hinzu[new FieldMapping("/document/groupedSubscriptionOptionNames") { TargetFieldName = nameof(Content.Subscriptions) }]