How to give more weight for title than other fields in Mysql Full Text Search Index
-
I am implementing mysql full text search, here I am facing one issue, results displaying but not working as I expect. When I perform search for 'Samsung Galaxy S6' it is coming at second position. I need title has more weight than other fields. If search string in title found, it will come first, and one more thing when I perform only with "S6" results are strange 0 results showing, how should I do this. Please help. My http://sqlfiddle.com/#!9/f0549/14
-
Answer:
I cannot provide an answer to the weighting of results if the search term was found in the title. I can provide the reason as to why searching for just "S6" returns 0 results, this is a MySQL limitation, where it's minimum word length is 4 characters by default, this can be changed in my.ini, look for the ft_min_word_len (and inversely ft_max_word_len). This is assuming you're using the MATCH() of course. Further reading: https://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language.html
jack brone at Stack Overflow Visit the source
Other answers
In order to apply a different weight for the fields text and title, you have to create an separate index on each column. Then you use both indices with a weight factor. select * from mytable where match(title) against 'word' or match(text) against 'word' order by 2 * match(title) against 'word' + match(text) against 'word' desc Choose an appropriate weighing factor (2 might be good).
Lorenz Meyer
Related Q & A:
- How To Get Full Text From RSS?Best solution by Stack Overflow
- How to set/change another post author by custom fields or something else?Best solution by WordPress
- How to skip columns empty in CSV file when importing into MySQL table using LOAD DATA INFILE?Best solution by Stack Overflow
- How to store table with a large number of fields?Best solution by Stack Overflow
- How to Display an Image in PDF, which is retrieved from MySql Database :JSP and iText?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.