I'm trying to write some xConnect search functionality that will search through all identifiers of all contacts.
SOLR is running and I have added a set of sample contacts using the xConnect API.
This code executes as expected and finds a contact based on a twitter source:
using (var client = new XConnectClient(config))
{
var reference = new IdentifiedContactReference("twitter", "Twitter1");
Task<Contact> contactTask = client.GetAsync<Contact>(reference, new ContactExpandOptions() { });
Contact contact = await contactTask;
}
However code below doesn't return any contacts (and I would expect it to based on the above):
using (var client = new XConnectClient(config))
{
var queryable = client.Contacts.Where(x => x.Identifiers.Any(y => y.Identifier == "Twitter1")).GetBatchEnumerator(10);
var enumerator = await queryable;
while (await enumerator.MoveNext())
{
if (enumerator.Current != null)
{
foreach (var contact in enumerator.Current)
{
// process each contact
}
}
}
}
This code is an attempt to match the string "Twitter1" to any identifier source, not just a twitter source. If anyone knows what I might be doing wrong or another way of approaching this I'd be very grateful for some advice.