Sphinx and “did you mean … ?” suggestions idea. WIll it work?

前端 未结 3 1456
迷失自我
迷失自我 2021-01-18 18:21

I\'m trying to come up with the fastest way to make search suggestions. At first I thought a Levenstein UDF function combined with a mysql table would do the job. But using

3条回答
  •  无人及你
    2021-01-18 19:14

    You could just log every search query that's entered, along with a next search query that the user enters.

    Lets assume that lots of users search for rhinosorous but actually mean rhinoceros. Because users will correct their query, this will mean there will be a lot of rhinosorous queries with rhinoceros as the next query.

    You can select suggestions like this:

    SELECT id, query, next_query, COUNT(id) AS count FROM queries GROUP BY query ORDER BY COUNT(id) DESC
    

    If the top result has a count that's a high % of all queries for that keyword, display a message.

    I haven't tested this, its just an idea.

提交回复
热议问题