Relevant search results from a MySQL table
What's the best way of generating super relevant results from a MySQL table? I have a list of sites in a table with a title, description and tags. How can I set up a SELECT query/search function in PHP that will find user typed keywords in all three of those columns, and whilst remaining as quick as possible keep the following in mind:
Are there any specific changes I would need to make to my table?
The simplest method would be to use a full-text index on all of those columns.
However, fulltext indexes in mysql will not give you fine-grained control over the weighting of different columns. For that you need something like lucene or sphinx .
There is no simple answer. "and whilst remaining as quick as possible" is not a constraint. You have to: 1) set the real goal 2) try to achieve it yourself
It might happen that the simplest query does the work well and you don't have to do anything else.
The order is ALWAYS write working code, try it and if it doesn't run well optimise it. You are doing this the other way round and thus wasting your time.
The natural approach IMHO will be to let PHP move through the recordset, so you can apply the logic record by record.
You can expect you'll want to refine your logic in the future. Handling your needs through code will let you do so easily.
Can't say about your table structure, as you haven't provided much detail.
链接地址: http://www.djcxy.com/p/75274.html上一篇: 在mysql全文搜索中给一些字段更多的相关性和相关性排序
下一篇: 来自MySQL表的相关搜索结果