1

I want to know if I can get for example a percentage of accuracy in my query result; for example something like this:

query:

"I love stackoverflow"

Results: (result, accuracy)

"we love stackoverflow",   80%
"I hate stackoverflow" ,   70%
"They hate stackoverflow", 40%

If there is nothing like this in MySQL full-text search, can you recommend me a text search library that can easily be deployed in an existing project in MYSQL DB and PHP?

Nicolas Durán
  • 292
  • 8
  • 19
  • 1
    http://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language.html look for "relevance" – Marc B Dec 19 '14 at 15:24
  • so question similar -> http://stackoverflow.com/questions/25646260/displaying-accuracy-of-mysql-select-queries – Marco Mura Dec 19 '14 at 15:25
  • @MarcB I understand that MySQL order results by "relevance" but you know how to display that relevance for each row in the query result? – Nicolas Durán Dec 19 '14 at 15:35

1 Answers1

1

FULLTEXT has this.

The value of

MATCH (col1,col2) AGAINST ('matching terms')

(when used in a SELECT or ORDER BY statement) produces the relevance score. It's not a percentage score, but it is a metric showing how close the match is to the terms.

For example,

 select zip, 
       primary_city, 
       match(primary_city, acceptable_cities) against ('york') AS relevance
  from zip
  where match(primary_city, acceptable_cities) against ('york') 
 order by 3 desc

produces the relevance of a match to a postcode table.

O. Jones
  • 103,626
  • 17
  • 118
  • 172