Highlight matched words MySQL FULLTEXT index
MySQL FULLTEXT index trouble. There are:
1) Table with words like:
ID__WORDS
1___jfjdeur,rjjghfje,rioogr
2___fkjtifdfe,lerkr
3___kfrkriti
4___frlerkti,tykitriero,frorodfl,rfjkrjr
...
N___fjfjtiu,frkrker,fkdkri
2) MySQL FULLTEXT index on WORDS column.
3) Query like:
SELECT *
FROM table WHERE
match(word) against ('gjfjdeur,rioogr,tykitriero')
As the result returns:
ID___WORDS
1____gjfjdeur,rjjghfje,rioogr (because contains gjfjdeur and rioogr)
4____frlerkti,tykitriero,frorodfl,rfjkrjr (because contains tykitriero).
Is it imposible to rewrite query to create additional column which will be contain found/matched word? Something like:
ID___WORDS______________________FOUND
1____gjfjdeur,rjjghfje,rioogr____________gjfjdeur,rioogr
4____frlerkti,tykitriero,frorodfl,rfjkrjr______tykitriero
Maybe something like:
SELECT *,some_function_to_select_matched_range(word)
FROM table WHERE
match(word) against ('gjfjdeur,rioogr,tykitriero')")
'In against' in real consists of hundreds words and preg_match_all
in php isn't good solution to select matched words from each found with FULLTEXT index row.
上一篇: 全文搜索无法正常工作