douzhuan1432 2010-08-27 09:36
浏览 31

如何制作“频繁搜索”引擎?

My first idea was start storing every word in the database ignoring words with 2 or fewer characters and every time a word is repeated just add one to a counter row (say importance) to appear first on the list of frequent searches. Sounds good until you think that normally you search for various words not just one word, eg.: for big house, you may want to store big house as a frequent search, not big and house.

I'm a little bit confused about how to do this and do it right. Has anyone done something similar? What do you think about the right way to do this?

  • 写回答

3条回答 默认 最新

  • dongzhong1929 2010-08-27 09:48
    关注

    Hmm, I would create 2 tables

    Searches and SearchFrequency

    Searches would contain all searches, and search frequency would be a list of searches that has been repeated so it would look like so

    ------------------------------------------------------
    frequency_id     frequency_sid     frequency_counter
    ------------------------------------------------------
    1                3                 33
    2                56                66
    3                33                128
    .....
    

    Then you can do

    SELECT * FROM Searches,SearchFrequency WHERE search_id = frequency_sid ORDER BY frequency_counter DESC LIMIT 30
    

    and just update the tables so,

    id = INSERT INTO Searches ....
    INSERT INTO SearchFrequency (frequency_sid,frequency_counter) VALUES (id,frequency_counter + 1);
    

    This would keep both tables updated and you can also then track individal searchs with IP,Related Searches etc etc.

    You can then also set up a SearchKeywordsFrequency table so that you can explode the searches and store the individual words, and then create a many-to-many relation ship with SearchFrequency

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?