If I have a List<string>
and want to do a standard search through it, I can use a LINQ statement like this:
(from t in tasks
where searchTerms.All(term => t.ToUpper().Contains(term.ToUpper()))
select t).ToList();
But if I want to support standard search-engine-like syntax to handle phrases such as:
contract
contract customer
jim customer
"Jim Smith" customer
then I need to start rolling my own custom search method. In addition as Jon Skeet mentioned here, you have to be careful with comparing with ToUpper() with different culture settings, and if you are in a web environment, you have many issues with encoding and searching-for-encoded-characters issues, etc.
Is there not a .NET or LINQ solution which handles search-machine-like searches, e.g. instead of Contains() something like ConstainsSearchTerms()?