Vasyl Fomin2019-11-10 22:12:02
Vasyl Fomin, 2019-11-10 22:12:02

How to properly implement "popular queries" on the site?

Hello! I need advice on what architecture the following system should have (if anything, I use PHP, Laravel, MySQL,):
The site has a search field (like google search :) ), in which users enter search phrases, for example, the name of products. It is necessary that the user be loaded automatically with "popular queries" (again, like in google), which, it turns out, are set earlier. Or, if at first no queries are set, then it turns out to display the names of the goods (since at first there are simply no "popular queries"). And when the user clicks on one of the search results, then he goes to the page with the category of the product he clicked on (the search string (query) must be linked to a specific product)
I won’t use a search engine like sphinx, elasticsearch, therefore,
While I see a variant using the SQL construct - MATCH AGAINST (as in the answer here ) - resp. the database table will be of type MyIsam.
But I need advice on where to get these search queries, how to set their popularity, and how to link products to them? - Except how to manually fill the base, I did not come up with :(

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Ilya Lisin, 2018-10-19

Use line-profiler to find out the weakest points in your code. And then it will be clear where to improve the algorithm. I recently improved my speed 6 times thanks to him. Since you can try different options in a narrow place and immediately see the result.

Dimonchik, 2018-10-17

The task takes two files, one with passwords, the other with keywords (I didn’t attach it, because there was an error in checking the password; everything else is fine)

and everything is fine

FanatPHP, 2019-11-10

"popular queries" is such a fool for the really unlucky visitors who will take at face value this list of products that marketers need to sell at the moment.
If you want to make a truly list of popular products, then you need to show not what you were looking for, but what you bought. The list of orders searches for products that occur most often

Shohruh Shaimardonov, 2019-11-10

I agree with FanatPHP and a hint. At the very end, he gave a hint on how to implement.
Just add a number_of_visits field and increment each time. And to find popular ones, just select the maximum n records from the table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question