I am using Sitecore 10 and trying to implement keyword search with xConnect contact. I want to search for contacts that have email or phone number that contains the inputted keyword. Below is my approach.
var expandOptions = new ContactExpandOptions(EmailAddressList.DefaultFacetKey, ListSubscriptions.DefaultFacetKey, PersonalInformation.DefaultFacetKey, PhoneNumberList.DefaultFacetKey);
IAsyncQueryable<Sitecore.XConnect.Contact> queryable;
if (!string.IsNullOrWhiteSpace(searchTerm))
{
queryable = client.Contacts.WithExpandOptions(expandOptions).Where(c => c.GetFacet<PhoneNumberList>(CollectionModel.FacetKeys.PhoneNumberList).PreferredPhoneNumber.Number.Contains(searchTerm) || c.GetFacet<EmailAddressList>(CollectionModel.FacetKeys.EmailAddressList).PreferredEmail.SmtpAddress.Contains(searchTerm))
.Skip((page - 1) * pageSize)
.Take(pageSize);
}
The problem is when this function is executed, it throws the exception: YourLinqIsTooStrongException
Turn out the xConnect search does not implement all of IAsyncQueryable methods and Contains() method is not supported as mentioned in this official document: https://doc.sitecore.com/xp/en/developers/92/sitecore-experience-platform/supported-methods-and-operators-for-xconnect-search.html
I've enabled indexing of PII sensitive data.
Has anybody encountered this error before and do you know how to resolve it?