开发者

Search function for blog posts; how can this be done elegantly?

What's the best way to rank blog posts based on a simple search string? The most obvious way to handle it (to me at least) is to look for things LIKE the search string in the titles of the entries and their tags, as well as count occurrences of the search string in each entry's body. However, this sounds a little bit bloated and the way to weight these different factors to produce ranked results (also accommodating for how recent posts are) will have a huge impact on the relevance of search results. Issues of computational cost aside, i开发者_开发百科t seems like it will be difficult to ensure relevant results will be returned to the user.

So: is there a more elegant way to handle searching a blog that I have missed?

Edit: the tables of post/entry data won't grow very large. in fact, they are likely to remain very small (~150 rows)


You could use MySQL's fulltext search for writing a search with relevancy (MyISAM only).

Besides that, you have other options like: sphinx or solr but they require more work to implement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜