5

I'm trying to show groups of users in xconnect who match a specific pattern card for a custom report. To do this I have tried using the ProfileScores facet and ContactBehaviorProfile facet. While using these I get an error saying their linq statement is not supported. Is doing something like this possible out of the box or would it require some kind of custom index?

Sample code I've tried:

    public async Task<object> GetUserFromPatternCardAsync(ID matchingPatternId, ID profile)
    {
        using (var client = SitecoreXConnectClientConfiguration.GetClient())
        {
            var queryable = client.Contacts
                //.Where(c => c.GetFacet<ProfileScores>(ProfileScores.DefaultFacetKey)
                //.Scores[profile.Guid].MatchedPatternId.Value == matchingPatternId.Guid)
                .Where(c => c.GetFacet<ContactBehaviorProfile>(ContactBehaviorProfile.DefaultFacetKey)
                .Scores[profile.Guid].MatchedPatternId.Value == matchingPatternId.Guid)
                .WithExpandOptions(new RelatedInteractionsExpandOptions(WebVisit.DefaultFacetKey)
                {
                    StartDateTime = DateTime.MinValue,
                    Limit = int.MaxValue
                });

            return await queryable.FirstOrDefault();
        }
    }
3

The problem is xConnect Search does not support the indexer in this part of the query:

.Scores[patternCard.Guid].MatchedPatternId.Value == matchingPatternId.Guid)`

However it does support the Any method against the dictionary, so something like this:

.Scores.Any(s => s.Key == patternCard.Guid && s.Value.MatchedPatternId == matchingPatternId.Guid)
| improve this answer | |
  • It's probably worth noting that while using ProfileScores I get the error Field could not be found in the model or the field is not enabled for indexing/searching. Path ProfileScores.Scores but using ContactBehaviorProfile works. Thanks for the help! – Teeknow Jan 17 '19 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.