Domanda

I'm using a MySQL db with a full-text index of the two fields (name and aliases).

It is a videogames database

codice:

SELECT name,MATCH (name,aliases) AGAINST ('inFamous: Second Son') AS relevance
FROM games_search
ORDER BY relevance DESC;

With this query I get the following results

codice:

inFamous 2                     9.150630950927734
inFamous: Second Son           9.150630950927734
inFamous                       8.947185516357422
inFamous: Festival of Blood    8.947185516357422

Why the first two results have the same relevance?

È stato utile?

Soluzione

Full text search in MySQL ignores two types of words: stop words and words shorted than some threshhold.

You can read the list of stop words here. Of particular interest in your case is the word 'second'.

By default, only words with 4 characters or longer are kept for search purposes. Hence, 'son' is ignored. So, your query is equivalent to:

SELECT name, MATCH (name,aliases) AGAINST ('inFamous:') AS relevance
FROM games_search
ORDER BY relevance DESC;

I am not sure why these are higher than the last two. I speculate that the relevancy is treating a perfect match (minus stop words and short words) as slightly higher than an imperfect match.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top