what algorithm will be best suited for the following situation:
Suppose the user enters in search box :- Dell Computers But in the database this term doesn't exist but what exist is :- Dell or just :-Computers so how/what alogrithm can work for the above scenario. Steps required:
1) Find to see if an exact match exists for "Dell Computers"
2) If not, then check for each word like "Dell" and "Computers"
Moreover i want to implement this in PHP. Any ideas how to do it?
This has been done extensively in the area of Full text searching. Look at Lucene, ElasticSearch, MySQL Full-Text Search, or PostgreSQL Full Text Search.
The basic idea is to create a trie of single keywords pointing to the resulting set of articles/documents, then look up each word separately and do a set intersection of the results to find articles matching both - and fall back on the individual result sets if there are no good intersections.
Add to that stemming of the lookup words, and you're on your way to reimplementing Lucene and friends.