views:

62

answers:

1

I am making a little search algorithm at the moment, and I am wondering if MySQL fulltext searches weight keywords in order of appearance?

For example:

Search Term: php macaroni pizza custard

In a fulltext search, is PHP more "relevant" than custard? Or are they both equal?

A: 

The mySQL manual, if I read it correctly, says there is no distinction:

the rows returned are automatically sorted with the highest relevance first. Relevance values are nonnegative floating-point numbers. Zero relevance means no similarity. Relevance is computed based on the number of words in the row, the number of unique words in that row, the total number of words in the collection, and the number of documents (rows) that contain a particular word.

-

Every correct word in the collection and in the query is weighted according to its significance in the collection or query. Consequently, a word that is present in many documents has a lower weight (and may even have a zero weight), because it has lower semantic value in this particular collection. Conversely, if the word is rare, it receives a higher weight. The weights of the words are combined to compute the relevance of the row.

Pekka