Reputation: 12538
I am trying to optimize my search engine. Right now, I am running a strcmp between the search words the user entered and keywords stored in the database. I am trying to come up with a way so that the more matches the users search words has with the keywords the sooner it will show up in the search results.
For example, if the user search for "red apple painting" and I have two entries for that item with the following keywords 1. "old apple painting green" 2. "apple painting red new york" I would like the second entry to come up first in the search result because all of the users search words were found in the keywords stored in the db.
Any help on how I can achieve this?
Upvotes: 4
Views: 203
Reputation: 1
Find applicable keywords with accurate seek site visitors capability. Create and optimize pages for engines like google and customers alike. Make sure your internet site is offered to each bots and human beings. Build applicable links from different notable web sites.
Upvotes: 0
Reputation: 1481
you need to create an index of words. The index would contain word id, doc id, number of hits, position of hits. Then the searcher will be able to give results like you want. There are free indexing tools available in market. But if you want to develop your own then follow the original paper bt google founders- http://infolab.stanford.edu/~backrub/google.html
Upvotes: 1
Reputation: 839114
Take a look at full text search.
You may also want to consider an external text search engine such as Lucene or Sphinx.
Upvotes: 5