As part of SCHackathon 2018, I created a custom Event (a generic Event, not a Page Event, although I will change it to a Page Event and see if that helps see notes below).

I followed the docs here: https://doc.sitecore.net/developers/xp/xconnect//xconnect-model/events/create-event.html

I was able to attach the event to a Contact's Interactions. (Practically identical code to this post: Single contact showing in Sitecore Experience Profile)

This is confirmed by getting the specific user/contactReference:

// Get all available contact facets in current model
var contactFacets = client.Model.Facets.Where(c => c.Target == EntityType.Contact).Select(x => x.Name);

// Get all available interaction facets in current model
var interactionFacets = client.Model.Facets.Where(c => c.Target == EntityType.Interaction).Select(x => x.Name);

var contactReference = new IdentifiedContactReference(source, identifier);

var contact = client.GetAsync(contactReference, new ContactExpandOptions(contactFacets.ToArray())
{
   Interactions = new RelatedInteractionsExpandOptions(interactionFacets.ToArray())
   {
      // Get all interactions
      EndDateTime = DateTime.MaxValue,
      StartDateTime = DateTime.MinValue
   }
}).Result;

Now, where I am having issues. I am trying to Search all Contacts that have this Event. So, I followed the Search docs here: https://doc.sitecore.net/developers/xp/xconnect//xconnect-client-api/search/index.html and here: https://doc.sitecore.net/developers/xp/getting-started/

I found the simplest search returns 0 records!

var count = client.Contacts.ToEnumerable().Count();
Console.WriteLine("Count: " + count);

Therefore, doing any additional filtering is pointless.

But, what I am really trying to achieve is this:

var queryable = client.Contacts
          .Where(c => c.Interactions.Any(x => x.Events.OfType<CustomEvent>().Any()))

While preparing this, I believe it is due to the Event not being a PageEvent and therefore not being a "web" interaction it is causing the contact to not get aggregated. I will updated as I learn more. But any help/insight is greatly appreciated.

Any ideas?

In general, you can look at the examples in the documentation for searching contacts by an interaction facet:

https://doc.sitecore.net/developers/xp/xconnect//xconnect-client-api/search/contacts/index.html#search-by-interaction-facets

I'm sure this is what you based your queries on, but including it for completeness.

I notice in your code that you are trying to use things like ToEnumerable() on client.Contacts instead of GetBatchEnumerator() which is used in the documentation. The options for getting enumerators are listed here:

https://doc.sitecore.net/developers/xp/xconnect//xconnect-client-api/search/contacts/index.html#results-and-pagination

The first step in debugging the issue would be to try a search like this to see if there is any data at all to come back (from https://doc.sitecore.net/developers/xp/xconnect//xconnect-client-api/search/contacts/index.html#count-contacts):

int count = await client.Contacts.Where(c => c.Identifiers.Any(t => t.IdentifierType == Sitecore.XConnect.ContactIdentifierType.Known)).Count();

If you get no results, then there are no known contacts in your index and you should take a look to see if you have indexing issues or if you can see the contact in Solr.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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